def __init__(self, workerPort, id, runner, validationExpression, arguments):

        self.id = id
        self.requestManager = RequestManager("127.0.0.1", workerPort)
        self.workerPort = workerPort
        self.completion = 0.0
        self.message = "loading command script"
        self.arguments = arguments

        self.finalState = CMD_DONE
        self.logger = logging.getLogger("cmdwatcher")

        self.runnerErrorInExec = None
        self.runnerErrorInPostExec = None

        # check that the job type is a registered one
        from puliclient.jobs import loadCommandRunner
        try:
            runnerClass = loadCommandRunner(runner)
        except ImportError:
            self.logger.exception("Command runner loading failed.")
            self.updateCommandStatus(CMD_ERROR)
            sys.exit(1)

        self.commandValidationExpression = validationExpression

        # instanciation of the jobtype script
        try:
            self.job = runnerClass()
            self.job.associatedWatcher = self
            self.mainActions()
        except Exception:
            self.updateCommandStatus(CMD_ERROR)
            self.logger.exception("CommandWatcher failed. This is a bug, please report it.")
            sys.exit(1)
    def __init__(self, serverFullName, workerPort, id, runner, runnerPackages,
                 validationExpression, arguments):
        """Creates a new command watcher.

        :param serverFullName: Main server address
        :type serverFullName: string
        :param workerPort: Communication port opened on the worker
        :type serverFullName: int
        :param id: commandId
        :param runner: module name of the class that will be executed i.e. the 'runner'
        :param validationExpression:
        :param arguments:
        """

        self.id = id
        self.requestManager = RequestManager("127.0.0.1", workerPort)
        self.workerPort = workerPort
        self.workerFullName = socket.gethostname() + ":" + self.workerPort
        self.serverFullName = serverFullName
        self.arguments = arguments
        self.runner = runner
        self.runnerPackages = runnerPackages

        self.completion = 0.0
        self.message = "loading command script"
        self.stats = {}
        self.startDate = time.time()

        self.completionHasChanged = True
        self.messageHasChanged = True
        self.statsHasChanged = True

        self.finalState = CMD_DONE

        self.runnerErrorInExec = None
        self.runnerErrorInPostExec = None

        # check that the job type is a registered one
        runnerLabel = runner.rsplit('.', 1)[1:][0]
        logger.info("Loading class: \"%s\"" % runnerLabel)

        from puliclient.jobs import loadCommandRunner, JobTypeImportError
        try:
            runnerClass = loadCommandRunner(runner)
        except JobTypeImportError, e:
            logger.error("Command runner loading failed: %r" % e)
            self.updateCommandStatus(CMD_ERROR)
            sys.exit(1)
    def __init__(self, serverFullName, workerPort, id, runner, runnerPackages, validationExpression, arguments):
        """Creates a new command watcher.

        :param serverFullName: Main server address
        :type serverFullName: string
        :param workerPort: Communication port opened on the worker
        :type serverFullName: int
        :param id: commandId
        :param runner: module name of the class that will be executed i.e. the 'runner'
        :param validationExpression:
        :param arguments:
        """

        self.id = id
        self.requestManager = RequestManager("127.0.0.1", workerPort)
        self.workerPort = workerPort
        self.workerFullName = socket.gethostname()+":"+self.workerPort
        self.serverFullName = serverFullName
        self.arguments = arguments
        self.runner = runner
        self.runnerPackages = runnerPackages

        self.completion = 0.0
        self.message = "loading command script"
        self.stats = {}
        self.startDate = time.time()

        self.completionHasChanged = True
        self.messageHasChanged = True
        self.statsHasChanged = True

        self.finalState = CMD_DONE

        self.runnerErrorInExec = None
        self.runnerErrorInPostExec = None

        # check that the job type is a registered one
        runnerLabel = runner.rsplit('.', 1)[1:][0]
        logger.info("Loading class: \"%s\"" % runnerLabel)

        from puliclient.jobs import loadCommandRunner, JobTypeImportError
        try:
            runnerClass = loadCommandRunner(runner)
        except JobTypeImportError, e:
            logger.error("Command runner loading failed: %r" % e)
            self.updateCommandStatus(CMD_ERROR)
            sys.exit(1)