(self)
Non-looping work function, calls command function.
Non-looping work function, calls command function.
Non - looping work function calls command function .
def work(self):
        """Non-looping work function, calls command function."""

        self.set_single_loop(1)

        cmd = self.args[1]
        cmdargs = self.args[2:]

        # find function
        fname = "cmd_" + cmd.replace('-', '_')
        if not hasattr(self, fname):
            self.log.error('bad subcommand, see --help for usage')
            sys.exit(1)
        fn = getattr(self, fname)

        # check if correct number of arguments
        (args, varargs, varkw, defaults) = inspect.getargspec(fn)
        n_args = len(args) - 1 # drop 'self'
        if varargs is None and n_args != len(cmdargs):
            helpstr = ""
            if n_args:
                helpstr = ": " + " ".join(args[1:])
            self.log.error("command '%s' got %d args, but expects %d%s"
                    % (cmd, len(cmdargs), n_args, helpstr))
            sys.exit(1)

        # run command
        fn(*cmdargs)
def work ( self ) : self . set_single_loop ( 1 ) cmd = self . args [ 1 ] cmdargs = self . args [ 2 : ] # find function fname = "cmd_" + cmd . replace ( '-' , '_' ) if not hasattr ( self , fname ) : self . log . error ( 'bad subcommand, see --help for usage' ) sys . exit ( 1 ) fn = getattr ( self , fname ) # check if correct number of arguments ( args , varargs , varkw , defaults ) = inspect . getargspec ( fn ) n_args = len ( args ) - 1 # drop 'self' if varargs is None and n_args != len ( cmdargs ) : helpstr = "" if n_args : helpstr = ": " + " " . join ( args [ 1 : ] ) self . log . error ( "command '%s' got %d args, but expects %d%s" % ( cmd , len ( cmdargs ) , n_args , helpstr ) ) sys . exit ( 1 ) # run command fn ( * cmdargs )