7155: Support creating directories in various scenarios

This commit is contained in:
Paul Franklin 2015-03-18 14:02:35 -07:00
parent ab0dfc8d68
commit 706437f57d
2 changed files with 20 additions and 7 deletions

View File

@ -527,13 +527,20 @@ class ReportDialog(ManagedWindow):
# we will need to create the file/dir # we will need to create the file/dir
# need to make sure we can create in the parent dir # need to make sure we can create in the parent dir
parent_dir = os.path.dirname(os.path.normpath(self.target_path)) parent_dir = os.path.dirname(os.path.normpath(self.target_path))
if not os.access(parent_dir, os.W_OK): if os.path.isdir(parent_dir):
ErrorDialog(_('Permission problem'), if not os.access(parent_dir, os.W_OK):
_("You do not have permission to create " ErrorDialog(_('Permission problem'),
"%s\n\n" _("You do not have permission to create "
"Please select another path or correct " "%s\n\n"
"the permissions.") % self.target_path "Please select another path or correct "
) "the permissions.") % self.target_path
)
return None
else:
ErrorDialog(_('No directory'),
_('There is no directory %s.\n\n'
'Please select another directory '
'or create it.') % parent_dir )
return None return None
self.set_default_directory(os.path.dirname(self.target_path) + os.sep) self.set_default_directory(os.path.dirname(self.target_path) + os.sep)

View File

@ -140,6 +140,12 @@ class GrampsXmlWriter(UpdateCallback):
"Please make sure you have write access to the " "Please make sure you have write access to the "
"directory and try again.")) "directory and try again."))
return 0 return 0
else:
raise DbWriteFailure(_('No directory'),
_('There is no directory %s.\n\n'
'Please select another directory '
'or create it.') % base )
return 0
if os.path.exists(filename): if os.path.exists(filename):
if not os.access(filename, os.W_OK): if not os.access(filename, os.W_OK):