コード例 #1
0
    def set_priority(self, job_id, priority=0):
        """
        Set fixed priority to a job.

        @param job_id: job identifier
        @type  job_id: integer
        @param priority: fixed priority
        @type  priority: integer
        """
        cmd = "gwkill -9 -p %d %d" % (priority, job_id)
        code, out = exec_cmd(cmd)
        if code: raise Exception("Error updating priority for job %d" % job_id)
コード例 #2
0
    def cancel(self, job_id, hard=False):
        """
        Cancel a job.

        @param job_id: job identifier
        @type  job_id: integer
        @param hard: asynchronous cancel option
        @type  hard: boolean
        """
        cmd = "gwkill %s %d" % ('-9' if hard else '', job_id)
        code, out = exec_cmd(cmd)
        if code: raise Exception("Error canceling job %d" % job_id)
コード例 #3
0
    def status(self, job_id):
        """
        Get job status

        @param job_id: job identifier
        @type  job_id: integer

        JID DM   EM   START    END      EXEC    XFER    EXIT HOST
        33  fail ---- 09:53:18 09:56:57 0:00:00 0:01:00 --   localmachine/fork
        """
        cmd = 'gwps -n -o setxh %d' % (job_id)
        code, out = exec_cmd(cmd)
        if code: raise Exception("Error getting status for job %d" % job_id)
        header = ['DM', 'EM', 'START', 'END', 'EXEC', 'XFER', 'EXIT', 'HOST']
        return dict((key, val) for key, val in zip(header, out.split()))
コード例 #4
0
    def submit(self, job, dep=[], priority=0, type_dep="afterok"):
        """
        Submit jobs.

        @param job_id: DRM4G job
        @type  job: object
        @param dep: job dependencies
        @type  dep: list
        @param priority: fixed priority
        @type  priority: integer
        @param type_dep: type of dependency : afterok, afterany and afternotok
        @type  type_dep: string
        """
        str_template = job.create_template()
        job.create_file(str_template)
        depend = "-d %s -r %s" % (' '.join(dep), type_dep) if dep else ''
        cmd = "gwsubmit -p %d -v %s -t %s" % (priority, depend,
                                              job.get_template_file())
        code, out = exec_cmd(cmd)
        logging.debug(out)
        if code: raise Exception(out)
        job_id = int(out[8:])
        return job_id