Skip to content

Commit d2a3030

Browse files
committed
Merge pull request #486 from cchampet/clean_samTools
Clean sam do/ls
2 parents 5dbb538 + 3777fbc commit d2a3030

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

applications/sam/sam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def getBestSamTools():
8383
tool.command,
8484
help=tool.help,
8585
description=tool.description,
86-
epilog=(tool.epilog if tool.epilog else None),
86+
epilog=tool.epilog,
8787
formatter_class=argparse.RawTextHelpFormatter,
8888
add_help=(False if tool.command == 'do' else True))
8989
tool.fillParser(toolParser)

applications/sam/sam_do.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ def __init__(self):
3636
self._geometryPorcessing = colored.blue('Geometry processing during conversion')
3737
self._colorProcessing = colored.blue('Color processing during conversion')
3838
self._imgSeqNumbering = colored.blue('Image Sequence Numbering')
39-
self.processingOptions = colored.blue('Processing options')
39+
self._processingOptions = colored.blue('Processing options')
40+
self._tuttleVersion = colored.green('TuttleOFX project [v' + str(tuttle.TUTTLE_HOST_VERSION_MAJOR)+'.'+str(tuttle.TUTTLE_HOST_VERSION_MINOR)+'.'+str(tuttle.TUTTLE_HOST_VERSION_MICRO)+']')
41+
self._tuttleWebSite = colored.green('http://www.tuttleofx.org/')
4042
if clintVersion >= '0.3.3':
4143
self._pluginOption.bold=True
4244
self._generatorsAndViewers.bold=True
4345
self._imgSeqConversion.bold=True
4446
self._geometryPorcessing.bold=True
4547
self._colorProcessing.bold=True
4648
self._imgSeqNumbering.bold=True
47-
self.processingOptions.bold=True
49+
self._processingOptions.bold=True
50+
self._tuttleVersion.bold=True
51+
self._tuttleWebSite.bold=True
4852

4953
self.epilog = '''
5054
''' + self._pluginOption + '''
@@ -88,11 +92,12 @@ def __init__(self):
8892
Frames 1 to 100 padding 5: image.#####.jpg
8993
Printf style padding 4: image.%04d.jpg
9094
91-
''' + self.processingOptions + '''
95+
''' + self._processingOptions + '''
9296
Range process: sam do reader [email protected] // writer [email protected] --ranges 50 100
9397
Single process: sam do reader [email protected] // writer [email protected] --ranges 59
9498
Continues whatever happens: sam do reader [email protected] // writer [email protected] --continue-on-error
95-
'''
99+
100+
''' + self._tuttleVersion + ''' ''' + self._tuttleWebSite
96101

97102
def fillParser(self, parser):
98103
# Arguments
@@ -155,7 +160,7 @@ def _displayPlugins(self):
155160
plugins = []
156161
for plugin in tuttle.core().getPlugins():
157162
plugins.append(plugin.getIdentifier().ljust(30) + ' (v' + str(plugin.getVersionMajor()) + '.' + str(plugin.getVersionMinor()) + ')')
158-
for plugin in sorted(plugins):
163+
for plugin in sorted(set(plugins)):
159164
puts(plugin)
160165

161166
def _displayFileFormats(self):
@@ -391,7 +396,7 @@ def _getTuttleGraph(self, splitCmdGraph):
391396
# Plugin not found
392397
if not nodeFullName:
393398
nodeFullName = splitCmdNode._pluginId
394-
self.logger.warning('Cannot create node "' + nodeFullName + '": the node will be skipped from the command line.')
399+
self.logger.error('Cannot create node "' + nodeFullName + '": the node will be skipped from the command line.')
395400
self.logger.debug(e)
396401
continue
397402
# sam-do node --help
@@ -448,11 +453,6 @@ def run(self, parser):
448453
# Parse command-line
449454
args, unknown = parser.parse_known_args()
450455

451-
# sam-do --help
452-
if len(args.inputs) == 0 and ('-h' in unknown or '--help' in unknown):
453-
self._displayCommandLineHelp(parser)
454-
exit(0)
455-
456456
# Set sam log level
457457
self.setLogLevel(args.verbose)
458458
# set tuttle host log level
@@ -478,6 +478,11 @@ def run(self, parser):
478478
self._displayFileFormats()
479479
exit(0)
480480

481+
# sam-do --help
482+
if len(args.inputs) == 0 and (len(unknown) == 0 or '-h' in unknown or '--help' in unknown):
483+
self._displayCommandLineHelp(parser)
484+
exit(0)
485+
481486
# Add unknown options to the command line to process
482487
args.inputs.extend(unknown)
483488

@@ -532,7 +537,7 @@ def run(self, parser):
532537
try:
533538
graph.compute(nodes[-1], options)
534539
except Exception as e:
535-
self.logger.error('Tuttle graph computation failed.')
540+
self.logger.error('Tuttle graph computation has failed.')
536541
self.logger.debug(e)
537542
self.logger.info('Memory usage: ' + str(int(samUtils.memoryUsageResource())) + 'KB')
538543

applications/sam/sam_ls.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def fillParser(self, parser):
3838
parser.add_argument('-d', '--directories', dest='directories', action='store_true', help='handle directories')
3939
parser.add_argument('-s', '--sequences', dest='sequences', action='store_true', help='handle sequences')
4040
parser.add_argument('-f', '--files', dest='files', action='store_true', help='handle files')
41-
parser.add_argument('-e', '--expression', dest='expression', help='use a specific pattern, ex: "*.jpg", "*.png"')
41+
parser.add_argument('-e', '--expression', dest='expression', action='append', default=[], help='use a specific pattern, ex: "*.jpg", "*.png"')
4242

4343
parser.add_argument('-l', '--long-listing', dest='longListing', action='store_true', help='use a long listing format (display in this order: type | permissions | owner | group | last update | minSize | maxSize | totalSize | name)')
4444
parser.add_argument('--format', dest='format', choices=['default', 'nuke', 'rv'], default='default', help='specify formatting of the sequence padding')
@@ -201,9 +201,14 @@ def run(self, parser):
201201

202202
# inputs to scan
203203
inputs = []
204-
if args.inputs:
205-
inputs = args.inputs
206-
else:
204+
for input in args.inputs:
205+
# if exists add the path
206+
if os.path.exists(input):
207+
inputs.append(input)
208+
# else use it as a filter expression
209+
else:
210+
args.expression.append(input)
211+
if not inputs:
207212
inputs.append(os.getcwd())
208213

209214
# sam-ls -a
@@ -221,8 +226,8 @@ def run(self, parser):
221226

222227
# sam-ls -e
223228
filters = []
224-
if args.expression:
225-
filters.append(args.expression)
229+
for expression in args.expression:
230+
filters.append(expression)
226231

227232
# get list of items for each inputs
228233
for input in inputs:

libraries/tuttle/src/tuttle/host/tuttle.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
21
%module tuttle
32

43
%module(directors="1", threads="1") tuttle
54

5+
%include <tuttle/host/version.hpp>
6+
67
%include "global.i"
78
%include "Core.i"
89
%include "ImageEffectNode.i"
@@ -17,4 +18,3 @@
1718
%include "thumbnail/ThumbnailDiskCache.i"
1819
%include "Callback.i"
1920
%include <tuttle/common/utils/Formatter.i>
20-

0 commit comments

Comments
 (0)