* src/Report.py (parse_target_frame): Check permissions for the
specified file. svn: r5516
This commit is contained in:
parent
c4d894920b
commit
65050b3a40
@ -18,6 +18,8 @@
|
||||
of the person happened over 150 years ago; (too_old): add
|
||||
function; (not_too_old): require definite year for a positive
|
||||
decision.
|
||||
* src/Report.py (parse_target_frame): Check permissions for the
|
||||
specified file.
|
||||
|
||||
2005-12-07 Eero Tamminen <eerot@sf>
|
||||
* src/po/fi.po: Translation update to latest template
|
||||
|
@ -1409,20 +1409,51 @@ class ReportDialog(BareReportDialog):
|
||||
if not self.target_path:
|
||||
return None
|
||||
|
||||
if not self.get_target_is_directory() and os.path.isdir(self.target_path):
|
||||
ErrorDialog(_("Invalid file name"),
|
||||
_("The filename that you gave is a directory.\n"
|
||||
"You need to provide a valid filename."))
|
||||
return None
|
||||
# First we check whether the selected path exists
|
||||
if os.path.exists(self.target_path):
|
||||
|
||||
if os.path.isfile(self.target_path):
|
||||
a = OptionDialog(_('File already exists'),
|
||||
_('You can choose to either overwrite the file, or change '
|
||||
'the selected filename.'),
|
||||
_('_Overwrite'),None,
|
||||
_('_Change filename'),None)
|
||||
# selected path is an existing dir
|
||||
if os.path.isdir(self.target_path):
|
||||
# check whether we asked for a dir
|
||||
if not self.get_target_is_directory():
|
||||
ErrorDialog(_("Invalid file name"),
|
||||
_("The filename that you gave is a "
|
||||
"directory.\n"
|
||||
"You need to provide a valid filename."))
|
||||
return None
|
||||
# check whether the dir has rwx permissions
|
||||
if not os.access(self.target_path,os.R_OK|os.W_OK|os.X_OK):
|
||||
ErrorDialog(_('Permission problem'),
|
||||
_("You do not have permissions to write "
|
||||
"under the directory %s\n\n"
|
||||
"Please select another directory or correct"
|
||||
"the permissions." % self.target_path)
|
||||
)
|
||||
return None
|
||||
|
||||
# selected path is an exsting file
|
||||
if os.path.isfile(self.target_path):
|
||||
a = OptionDialog(_('File already exists'),
|
||||
_('You can choose to either overwrite the '
|
||||
'file, or change the selected filename.'),
|
||||
_('_Overwrite'),None,
|
||||
_('_Change filename'),None)
|
||||
|
||||
if a.get_response() == gtk.RESPONSE_YES:
|
||||
if a.get_response() == gtk.RESPONSE_YES:
|
||||
return None
|
||||
|
||||
# selected path does not exist yet
|
||||
else:
|
||||
# we will need to create the file/dir
|
||||
# need to make sure we can create in the parent dir
|
||||
parent_dir = os.path.dirname(os.path.normpath(self.target_path))
|
||||
if not os.access(self.parent_dir,os.W_OK):
|
||||
ErrorDialog(_('Permission problem'),
|
||||
_("You do not have permissions to create "
|
||||
"%s\n\n"
|
||||
"Please select another path or correct"
|
||||
"the permissions." % self.target_path)
|
||||
)
|
||||
return None
|
||||
|
||||
self.set_default_directory(os.path.dirname(self.target_path) + os.sep)
|
||||
|
Loading…
x
Reference in New Issue
Block a user