Skip to content

Commit

Permalink
sam rm: added try/catch around browse instructions
Browse files Browse the repository at this point in the history
In case of permission denied for example.
  • Loading branch information
Clement Champetier committed Aug 19, 2016
1 parent ac249f4 commit 805ca01
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions applications/sam/sam_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ def _removeItems(self, items, args, detectionMethod, filters):

# sam-rm -R
if args.recursive and itemType == sequenceParser.eTypeFolder:
subFolder = os.path.join(item.getFolder(), item.getFilename())
self.logger.debug('Browse in sub folder"' + subFolder + '" with the following filters: ' + str(filters))
newItems = sequenceParser.browse(subFolder, detectionMethod, filters)
self._removeItems(newItems, args, detectionMethod, filters)
try:
subFolder = os.path.join(item.getFolder(), item.getFilename())
self.logger.debug('Browse in sub folder"' + subFolder + '" with the following filters: ' + str(filters))
newItems = sequenceParser.browse(subFolder, detectionMethod, filters)
self._removeItems(newItems, args, detectionMethod, filters)
except IOError as e:
self.logger.error(e)
error = 1

if toRemove:
# store folder and delete it after all other elements
Expand Down Expand Up @@ -207,8 +211,13 @@ def run(self, parser):
filterToBrowse.extend(filters)
filterToBrowse.append(os.path.basename(inputPath))
# browse
self.logger.debug('Browse in "' + pathToBrowse + '" with the following filters: ' + str(filterToBrowse))
items = sequenceParser.browse(pathToBrowse, detectionMethod, filterToBrowse)
try:
self.logger.debug('Browse in "' + pathToBrowse + '" with the following filters: ' + str(filterToBrowse))
items = sequenceParser.browse(pathToBrowse, detectionMethod, filterToBrowse)
except IOError as e:
self.logger.error(e)
error = 1
continue

# print error if no items were found
if len(items) == 0:
Expand Down

0 comments on commit 805ca01

Please sign in to comment.