Skip to content

Commit 2af60c9

Browse files
author
Nathan Lee
committed
Merge branch 'develop'
2 parents 0e36d31 + 2514146 commit 2af60c9

2 files changed

Lines changed: 74 additions & 73 deletions

File tree

pyrunner/core/pyrunner.py

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, **kwargs):
5252
self.config['proc_file'] = kwargs.get('proc_file')
5353
self.config['restart'] = kwargs.get('restart', False)
5454

55-
self.parse_args()
55+
self.parse_args(kwargs.get('parse_args', True))
5656

5757
if self.dup_proc_is_running():
5858
raise OSError('Another process for "{}" is already running!'.format(self.config['app_name']))
@@ -336,7 +336,7 @@ def is_restartable(self):
336336
return False
337337
return True
338338

339-
def parse_args(self):
339+
def parse_args(self, run_getopts=True):
340340
abort = False
341341

342342
opt_list = 'c:l:n:e:x:N:D:A:t:drhiv'
@@ -351,77 +351,78 @@ def parse_args(self):
351351
'max-procs=', 'serde=', 'exec-loop-interval='
352352
]
353353

354-
try:
355-
opts, _ = getopt.getopt(sys.argv[1:], opt_list, longopt_list)
356-
except getopt.GetoptError as e:
357-
print(str(e))
358-
self.show_help()
359-
sys.exit(1)
360-
361-
for opt, arg in opts:
362-
if opt == '-c':
363-
self.config['config_file'] = arg
364-
elif opt == '-l':
365-
self.config['proc_file'] = arg
366-
elif opt in ['-d', '--debug']:
367-
self.config['debug'] = True
368-
elif opt in ['-n', '--max-procs']:
369-
self.config['max_procs'] = int(arg)
370-
elif opt in ['-r', '--restart']:
371-
self.config['restart'] = True
372-
elif opt in ['-x', '--exec-only']:
373-
self.config['exec_only_list'] = [ int(id) for id in arg.split(',') ]
374-
elif opt in ['-N', '--norun']:
375-
self.config['exec_disable_list'] = [ int(id) for id in arg.split(',') ]
376-
elif opt in ['-D', '--from', '--descendents']:
377-
self.config['exec_from_id'] = int(arg)
378-
elif opt in ['-A', '--to', '--ancestors']:
379-
self.config['exec_to_id'] = int(arg)
380-
elif opt in ['-e', '--email']:
381-
self.config['email'] = arg
382-
elif opt in ['--email-on-fail']:
383-
self.config['email_on_fail'] = arg
384-
elif opt in ['--email-on-success']:
385-
self.config['email_on_success'] = arg
386-
elif opt == '--env':
387-
parts = arg.split('=')
388-
os.environ[parts[0]] = parts[1]
389-
elif opt == '--cvar':
390-
parts = arg.split('=')
391-
self.config['cvar_list'].append((parts[0], parts[1]))
392-
elif opt == '--nozip':
393-
self.config['nozip'] = True
394-
elif opt == '--dump-logs':
395-
self.config['dump_logs'] = True
396-
elif opt == '--dryrun':
397-
self.config['dryrun'] = True
398-
elif opt in ['-i', '--interactive']:
399-
self.engine.context.interactive = True
400-
elif opt in ['-t', '--tickrate']:
401-
self.config['tickrate'] = int(arg)
402-
elif opt in ['--time-between-tasks']:
403-
self.config['time_between_tasks'] = int(arg)
404-
elif opt in ['--preserve-context']:
405-
self.preserve_context = True
406-
elif opt in ['--allow-duplicate-jobs']:
407-
self.config['allow_duplicate_jobs'] = True
408-
elif opt in ['--exec-proc-name']:
409-
self.config['exec_proc_name'] = arg
410-
elif opt == '--abort':
411-
abort = True
412-
elif opt in ['--serde']:
413-
if arg.lower() == 'json':
414-
self.plugin_serde(serde.JsonSerDe())
415-
elif opt == '--setup':
416-
pass
417-
elif opt in ('-h', '--help'):
354+
if run_getopts:
355+
try:
356+
opts, _ = getopt.getopt(sys.argv[1:], opt_list, longopt_list)
357+
except getopt.GetoptError as e:
358+
print(str(e))
418359
self.show_help()
419-
sys.exit(0)
420-
elif opt in ('-v', '--version'):
421-
print('PyRunner v{}'.format(__version__))
422-
sys.exit(0)
423-
else:
424-
raise ValueError("Error during parsing of opts")
360+
sys.exit(1)
361+
362+
for opt, arg in opts:
363+
if opt == '-c':
364+
self.config['config_file'] = arg
365+
elif opt == '-l':
366+
self.config['proc_file'] = arg
367+
elif opt in ['-d', '--debug']:
368+
self.config['debug'] = True
369+
elif opt in ['-n', '--max-procs']:
370+
self.config['max_procs'] = int(arg)
371+
elif opt in ['-r', '--restart']:
372+
self.config['restart'] = True
373+
elif opt in ['-x', '--exec-only']:
374+
self.config['exec_only_list'] = [ int(id) for id in arg.split(',') ]
375+
elif opt in ['-N', '--norun']:
376+
self.config['exec_disable_list'] = [ int(id) for id in arg.split(',') ]
377+
elif opt in ['-D', '--from', '--descendents']:
378+
self.config['exec_from_id'] = int(arg)
379+
elif opt in ['-A', '--to', '--ancestors']:
380+
self.config['exec_to_id'] = int(arg)
381+
elif opt in ['-e', '--email']:
382+
self.config['email'] = arg
383+
elif opt in ['--email-on-fail']:
384+
self.config['email_on_fail'] = arg
385+
elif opt in ['--email-on-success']:
386+
self.config['email_on_success'] = arg
387+
elif opt == '--env':
388+
parts = arg.split('=')
389+
os.environ[parts[0]] = parts[1]
390+
elif opt == '--cvar':
391+
parts = arg.split('=')
392+
self.config['cvar_list'].append((parts[0], parts[1]))
393+
elif opt == '--nozip':
394+
self.config['nozip'] = True
395+
elif opt == '--dump-logs':
396+
self.config['dump_logs'] = True
397+
elif opt == '--dryrun':
398+
self.config['dryrun'] = True
399+
elif opt in ['-i', '--interactive']:
400+
self.engine.context.interactive = True
401+
elif opt in ['-t', '--tickrate']:
402+
self.config['tickrate'] = int(arg)
403+
elif opt in ['--time-between-tasks']:
404+
self.config['time_between_tasks'] = int(arg)
405+
elif opt in ['--preserve-context']:
406+
self.preserve_context = True
407+
elif opt in ['--allow-duplicate-jobs']:
408+
self.config['allow_duplicate_jobs'] = True
409+
elif opt in ['--exec-proc-name']:
410+
self.config['exec_proc_name'] = arg
411+
elif opt == '--abort':
412+
abort = True
413+
elif opt in ['--serde']:
414+
if arg.lower() == 'json':
415+
self.plugin_serde(serde.JsonSerDe())
416+
elif opt == '--setup':
417+
pass
418+
elif opt in ('-h', '--help'):
419+
self.show_help()
420+
sys.exit(0)
421+
elif opt in ('-v', '--version'):
422+
print('PyRunner v{}'.format(__version__))
423+
sys.exit(0)
424+
else:
425+
raise ValueError("Error during parsing of opts")
425426

426427
# We need to check for and source the app_profile/config file ASAP,
427428
# but only after --env vars are processed

pyrunner/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '5.1.0'
1+
__version__ = '5.1.1'

0 commit comments

Comments
 (0)