def run_quickapp(self, qapp, cmd): args = ['-o', self.root0, '-c', cmd] self.assertEqual(0, quickapp_main(qapp, args, sys_exit=False)) # tell the context that it's all good jobs = all_jobs(self.db) self.cc.reset_jobs_defined_in_this_session(jobs)
def compapp_test1(self): cases = [] def add(args, ret): cases.append(dict(args=args, ret=ret)) add('--compress --contracts -c clean;make --param1 10 --param2 1', 0) # parse error add('--compress --contracts -c clean;make --param1 10 --parm2 1 ', QUICKAPP_USER_ERROR) # computation exception add('--compress --contracts -c clean;make --param1 10 --param2 -1 ', QUICKAPP_COMPUTATION_ERROR) for c in cases: args = c['args'] if isinstance(args, str): args = args.split() tmpdir = mkdtemp() args = ['-o', tmpdir] + args ret = c['ret'] with open(os.path.join(tmpdir, '.compmake.rc'), 'w') as f: f.write('config echo 1\n') ret_found = quickapp_main(QuickAppDemo2, args, sys_exit=False) msg = 'Expected %d, got %d.\nArguments: %s ' % (ret, ret_found, c['args']) self.assertEqual(ret, ret_found, msg) rmtree(tmpdir)
def run_quickapp(self, qapp, cmd: str): args = ['-o', self.root0, '-c', cmd, '--compress'] self.assertEqual(0, quickapp_main(qapp, args, sys_exit=False)) # tell the context that it's all good jobs = all_jobs(self.db) self.cc.reset_jobs_defined_in_this_session(jobs)
def compapp_test1(self): cases = [] def add(args, ret): cases.append(dict(args=args, ret=ret)) add('--contracts -c clean;make --param1 10 --param2 1', 0) # parse error add('--contracts -c clean;make --param1 10 --parm2 1', QUICKAPP_USER_ERROR) # computation exception add('--contracts -c clean;make --param1 10 --param2 -1', QUICKAPP_COMPUTATION_ERROR) for c in cases: args = c['args'] if isinstance(args, str): args = args.split() tmpdir = mkdtemp() args = ['-o', tmpdir] + args ret = c['ret'] ret_found = quickapp_main(QuickAppDemo2, args, sys_exit=False) msg = 'Expected %d, got %d.\nArguments: %s ' % (ret, ret_found, c['args']) self.assertEqual(ret, ret_found, msg) rmtree(tmpdir)
def compapp_test1(self): args = '--contracts -o %s -c make --compress' % self.root0 ret_found = quickapp_main(QuickAppDemoChild, args.split(), sys_exit=False) self.assertEqual(0, ret_found) print('jobs in %s: %s' % (self.db, list(all_jobs(self.db)))) self.assertJobsEqual('all', ['a-f', 'b-f', 'c-f'])
add('--compress --contracts -c clean;make --param1 10 --param2 1', 0) # parse error add('--compress --contracts -c clean;make --param1 10 --parm2 1 ', QUICKAPP_USER_ERROR) # computation exception add('--compress --contracts -c clean;make --param1 10 --param2 -1 ', QUICKAPP_COMPUTATION_ERROR) for c in cases: args = c['args'] if isinstance(args, str): args = args.split() tmpdir = mkdtemp() args = ['-o', tmpdir] + args ret = c['ret'] with open(os.path.join(tmpdir, '.compmake.rc'), 'w') as f: f.write('config echo 1\n') ret_found = quickapp_main(QuickAppDemo2, args, sys_exit=False) msg = 'Expected %d, got %d.\nArguments: %s ' % (ret, ret_found, c['args']) self.assertEqual(ret, ret_found, msg) rmtree(tmpdir) if __name__ == '__main__': quickapp_main(QuickAppDemo2)
def entry(args=None, sys_exit=True): return quickapp_main(cls, args=args, sys_exit=sys_exit)
def compapp_test1(self): cases = [] def add(args, ret): cases.append(dict(args=args, ret=ret)) add('--contracts -o quickapp_test1 -c clean;make --param1 10 --param2 1', 0) # parse error add('--contracts -o quickapp_test2 -c clean;make --param1 10 --parm2 1', QUICKAPP_USER_ERROR) # computation exception add('--contracts -o quickapp_test2 -c clean;make --param1 10 --param2 -1', QUICKAPP_COMPUTATION_ERROR) for c in cases: args = c['args'] if isinstance(args, str): args = args.split() ret = c['ret'] ret_found = quickapp_main(QuickAppDemo2, args, sys_exit=False) msg = 'Expected %d, got %d.\nArguments: %s ' % (ret, ret_found, c['args']) self.assertEqual(ret, ret_found, msg) if __name__ == '__main__': quickapp_main(QuickAppDemo2)
def get_sys_main(cls): """ Returns a function to be used as main function for a script. """ from quickapp import quickapp_main return lambda: quickapp_main(cls, args=None, sys_exit=True)
def subcommands_test1(): args = ['-o', 'quickapp_test1', '-c', 'make all', '--param1', '10', '--param2', '42'] quickapp_main(DemoApp, args=args)
params.add_int('param2', help='Second parameter') def define_jobs(self): options = self.get_options() self.info('My param2 is %r.' % options.param2) class DemoAppCmd2(DemoApp.sub): cmd = 'cmd2' short = 'Second command' def define_options(self, params): params.add_int('param1', help='First parameter', default=1) def define_jobs(self): pass def subcommands_test1(): args = ['-o', 'quickapp_test1', '-c', 'make all', '--param1', '10', '--param2', '42'] quickapp_main(DemoApp, args=args) if __name__ == '__main__': quickapp_main(DemoApp)
def compapp_test1(self): args = '--contracts -o %s -c make' % self.root0 ret_found = quickapp_main(QuickAppDemoChild, args.split(), sys_exit=False) self.assertEqual(0, ret_found) self.assertJobsEqual('all', ['a-f', 'b-f', 'c-f'])
def aer_video_main(): quickapp_main(AERVideoApp)