Exemple #1
0
 def coro():
     yield command.ping('Are you there?')
     yield command.PING('Hello World!')
     yield command.Command('dump')
     yield command.run('/usr/bin/bash', args=['-c','echo $ZZ1; echo $ZZ2'], env=dict(ZZ1='Zzzz...', ZZ2='__ZZZZ__'))
     yield 'end' # start monitoring 'end'
     yield command.Command('dump')
     yield WAIT
     yield command.Command('dump')
     return
Exemple #2
0
    def testMain(self):

        be = backends.CmdOnlyBackend()
        be.set_controller(FakeController(test_case=self, expected=command.no_output()))

        def test(be, input, output):
            be.controller.expected = output
            be.proc_input(input)

        test(be, 'ping', command.ping())
        test(be, 'PING a message', command.PING('a message'))
        test(be, 'run a_task', command.run('a_task'))
    def testRun(self):

        self._test_('r a',
                command.run(os.path.abspath('a'),
                    name='a', args=[], env={}))

        self._test_('run a_task',
                command.run(os.path.abspath('a_task'),
                    name='a_task', args=[], env={}))

        self._test_('run -n NAME a_task',
                command.run(os.path.abspath('a_task'),
                    name='NAME', args=[], env={}))

        self._test_('run -D VAR=VAL -D VAR2=VAL2 a_task',
                command.run(os.path.abspath('a_task'),
                    name='a_task', args=[], env={'VAR':'VAL', 'VAR2':'VAL2'}))

        self._test_('run a_task arg1 arg2',
                command.run(os.path.abspath('a_task'),
                    name='a_task', args=['arg1', 'arg2'], env={}))
Exemple #4
0
    def testMain(self):

        be = backends.CmdOnlyBackend()
        be.set_controller(
            FakeController(test_case=self, expected=command.no_output()))

        def test(be, input, output):
            be.controller.expected = output
            be.proc_input(input)

        test(be, 'ping', command.ping())
        test(be, 'PING a message', command.PING('a message'))
        test(be, 'run a_task', command.run('a_task'))
Exemple #5
0
def beah_check(task):
    '''
    Run beah-check.

    Try running as "original" task - i.e. with same BEAH_TID.

    If it can not be started via beah run it anyway...

    '''
    run_cmd = command.run('/bin/bash',
            name='beah-check',
            env={'TASKID': task.id_},
            args=('-c', 'BEAH_TID=%s beah-check' % task.id_))
    if not task.backend.send_cmd(run_cmd):
        os.spawnlp(os.P_WAIT, 'beah-check')
Exemple #6
0
    def testRun(self):

        self._test_(
            'r a', command.run(os.path.abspath('a'), name='a', args=[],
                               env={}))

        self._test_(
            'run a_task',
            command.run(os.path.abspath('a_task'),
                        name='a_task',
                        args=[],
                        env={}))

        self._test_(
            'run -n NAME a_task',
            command.run(os.path.abspath('a_task'),
                        name='NAME',
                        args=[],
                        env={}))

        self._test_(
            'run -D VAR=VAL -D VAR2=VAL2 a_task',
            command.run(os.path.abspath('a_task'),
                        name='a_task',
                        args=[],
                        env={
                            'VAR': 'VAL',
                            'VAR2': 'VAL2'
                        }))

        self._test_(
            'run a_task arg1 arg2',
            command.run(os.path.abspath('a_task'),
                        name='a_task',
                        args=['arg1', 'arg2'],
                        env={}))
Exemple #7
0
def beah_check(task):
    '''
    Run beah-check.

    Try running as "original" task - i.e. with same BEAH_TID.

    If it can not be started via beah run it anyway...

    '''
    run_cmd = command.run('/bin/bash',
                          name='beah-check',
                          env={'TASKID': task.id_},
                          args=('-c', 'BEAH_TID=%s beah-check' % task.id_))
    if not task.backend.send_cmd(run_cmd):
        os.spawnlp(os.P_WAIT, 'beah-check')
Exemple #8
0
 def proc_cmd_run(self, cmd, cmd_args):
     opts, args = self.__run_opt.parse_args(cmd_args)
     if len(args) < 1:
         raise exceptions.RuntimeError('file to run must be provided.')
     variables = {}
     if opts.variables:
         for pair in opts.variables:
             key, value = self.__varre.match(pair).group(1, 2)
             variables[key] = value
     if cmd == 'runthis':
         f = open(os.path.abspath(args[0]), 'r')
         try:
             script = f.read()
             return command.run_this(script, name=opts.name or args[0],
                     env=variables, args=args[1:])
         finally:
             f.close()
     else:
         return command.run(os.path.abspath(args[0]), name=opts.name or args[0],
                 env=variables, args=args[1:])
Exemple #9
0
 def proc_cmd_run(self, cmd, cmd_args):
     opts, args = self.__run_opt.parse_args(cmd_args)
     if len(args) < 1:
         raise exceptions.RuntimeError('file to run must be provided.')
     variables = {}
     if opts.variables:
         for pair in opts.variables:
             key, value = self.__varre.match(pair).group(1, 2)
             variables[key] = value
     if cmd == 'runthis':
         f = open(os.path.abspath(args[0]), 'r')
         try:
             script = f.read()
             return command.run_this(script,
                                     name=opts.name or args[0],
                                     env=variables,
                                     args=args[1:])
         finally:
             f.close()
     else:
         return command.run(os.path.abspath(args[0]),
                            name=opts.name or args[0],
                            env=variables,
                            args=args[1:])