Skip to content

Commit

Permalink
Check if the labelfile can be written to
Browse files Browse the repository at this point in the history
In previous versions of DisPass it will report a successful action
when the only problem is that the label file can’t be written to.
  • Loading branch information
ryuslash committed Dec 24, 2016
1 parent 54c37d7 commit f05f622
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dispass/commands/decorators/write_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def run(inst, *args, **kwargs):
if not lf.promptForCreation(silent=inst.flags['silent']):
return 1

if not lf.is_writeable():
print('error: can\'t save to "{loc}", not writeable'
.format(loc=lf.file_location))
return 1

func(inst, lf, *args, **kwargs)

if not inst.flags['dry-run']:
Expand Down
3 changes: 3 additions & 0 deletions dispass/filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,6 @@ def promptForCreation(self, silent=False):
else:
return False
return True

def is_writeable(self):
return os.access(self.file_location, os.W_OK)

0 comments on commit f05f622

Please sign in to comment.