Ejemplo n.º 1
0
    def processObject(self, obj):
        """Operate on the provided job object."""

        # ask the user if we should continue
        if not obj.pre(self, "Change the crews of the job?"):
            return

        if self.opts.add or self.opts.remove:
            # make sure everything is unique
            origcrews = listutil.getUnion(obj.crews)
            # make a copy so we can add/remove crews
            newcrews = list(origcrews)
            for crew in self.opts.add or self.opts.remove:
                if self.opts.add:
                    newcrews.append(crew)
                else:
                    if crew in origcrews:
                        newcrews.remove(crew)
                    else:
                        obj.post(self, "crew %s is not in crews %s" % (crew, origcrews))
            # make sure everything is unique again
            newcrews = listutil.getUnion(newcrews)
            if newcrews == origcrews:
                obj.post(self, "doesn't need to change")
                return
            crews = newcrews
        else:
            crews = listutil.getUnion(self.opts.crews)

        # try to run the operation
        query.chcrews(obj, crews=crews)
        obj.post(self, "crews changed")
Ejemplo n.º 2
0
    def processObject(self, obj):
        """Operate on the provided job object."""

        # ask the user if we should continue
        if not obj.pre(self, "Change the crews of the job?"):
            return

        if self.opts.add or self.opts.remove:
            # make sure everything is unique
            origcrews = listutil.getUnion(obj.crews)
            # make a copy so we can add/remove crews
            newcrews = list(origcrews)
            for crew in (self.opts.add or self.opts.remove):
                if self.opts.add:
                    newcrews.append(crew)
                else:
                    if crew in origcrews:
                        newcrews.remove(crew)
                    else:
                        obj.post(
                            self,
                            "crew %s is not in crews %s" % (crew, origcrews))
            # make sure everything is unique again
            newcrews = listutil.getUnion(newcrews)
            if newcrews == origcrews:
                obj.post(self, "doesn't need to change")
                return
            crews = newcrews
        else:
            crews = listutil.getUnion(self.opts.crews)

        # try to run the operation
        query.chcrews(obj, crews=crews)
        obj.post(self, "crews changed")
Ejemplo n.º 3
0
Archivo: test.py Proyecto: utsdab/usr
def test_job_ops(job):
    print "chcrews"
    tq.chcrews(job, crews=["newcrew1", "newcrew2"])
    print "chpri"
    tq.chpri(job, priority=123)
    print "jattr"
    tq.jattr(job, key="comment", value="new comment")
    print "pause"
    tq.pause(job)
    print "unpause"
    tq.unpause(job)
    print "lock"
    tq.lock(job)
    print "unlock"
    tq.unlock(job)
    print "interrupt"
    try:
        tq.interrupt(job)
    except EngineClient.TransactionError, err:
        print "received exception for interrupting job - we should fix that"