示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
 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'])
示例#6
0
        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)
示例#7
0
 def entry(args=None, sys_exit=True):
     return quickapp_main(cls, args=args, sys_exit=sys_exit)
示例#8
0
    
    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)
    

示例#9
0
 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)
示例#10
0
def subcommands_test1():
    args = ['-o', 'quickapp_test1',
            '-c', 'make all', '--param1', '10', '--param2', '42']
    quickapp_main(DemoApp, args=args)
示例#11
0
        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)
    
示例#12
0
 def entry(args=None, sys_exit=True):
     return quickapp_main(cls, args=args, sys_exit=sys_exit)
示例#13
0
 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'])
示例#14
0
文件: app.py 项目: kpykc/rcl
def aer_video_main():
    quickapp_main(AERVideoApp)
示例#15
0
文件: app.py 项目: AndreaCensi/rcl
def aer_video_main():
    quickapp_main(AERVideoApp)