当前位置: 首页>>代码示例>>Python>>正文


Python ComponentProxy.del_jobs方法代码示例

本文整理汇总了Python中Cobalt.Proxy.ComponentProxy.del_jobs方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy.del_jobs方法的具体用法?Python ComponentProxy.del_jobs怎么用?Python ComponentProxy.del_jobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cobalt.Proxy.ComponentProxy的用法示例。


在下文中一共展示了ComponentProxy.del_jobs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: len

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_jobs [as 别名]
     try:
         directory = os.path.dirname(opts['savestate'])
         if not os.path.exists(directory):
             print "directory %s does not exist" % directory
             sys.exit(1)
         response = cqm.save(opts['savestate'])
     except Exception, e:
         print e
         sys.exit(1)
     else:
         print response
 elif kdata:
     for cmd in kdata:
         try:
             if cmd == '--delete':
                 response = cqm.del_jobs(spec, True, whoami)
             else:
                 response = cqm.del_jobs(spec, False, whoami)
         except xmlrpclib.Fault, flt:
             if flt.faultCode == JobDeleteError.fault_code:
                 args = eval(flt.faultString)
                 exc = JobDeleteError(*args)
                 print >>sys.stderr, "Job %s: ERROR - %s" % (exc.jobid, exc.message)
                 raise SystemExit, 1
             else:
                 raise
 elif opts['run']:
     location = opts['run']
     part_list = ComponentProxy("system").get_partitions([{'name': location}])
     if len(part_list) != 1:
         print "Error: cannot find partition named '%s'" % location
开发者ID:zzhou,项目名称:Qsim_PowerAware,代码行数:33,代码来源:cqadm.py

示例2: ComponentProxy

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_jobs [as 别名]
    if '-d' in sys.argv:
        level = 10
    user = pwd.getpwuid(os.getuid())[0]
    Cobalt.Logging.setup_logging('qdel', to_syslog=False, level=level)
    logger = Cobalt.Logging.logging.getLogger('qdel')
    try:
        cqm = ComponentProxy("queue-manager", defer=False)
    except ComponentLookupError:
        print >> sys.stderr, "Failed to connect to queue manager"
        sys.exit(1)
    
    for i in range(len(args)):
        if args[i] == '*':
            continue
        try:
            args[i] = int(args[i])
        except:
            logger.error("jobid must be an integer")
            raise SystemExit, 1
    
    spec = [{'tag':'job', 'user':user, 'jobid':jobid} for jobid in args]
    jobs = cqm.del_jobs(spec)
    time.sleep(1)
    if jobs:
        data = [('JobID','User')] + [(job.get('jobid'), job.get('user')) for job in jobs]
        print "      Deleted Jobs"
        Cobalt.Util.print_tabular(data)
    else:
        print "qdel: Job %s not found" % sys.argv[-1]

开发者ID:zzhou,项目名称:Qsim_PowerAware,代码行数:31,代码来源:qdel.py

示例3: test_something

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_jobs [as 别名]

#.........这里部分代码省略.........
        job_location_args = [
            {
                "jobid": jobid,
                "nodes": job["nodes"],
                "queue": job["queue"],
                "utility_score": 1,
                "threshold": 1,
                "walltime": job["walltime"],
                "attrs": {},
            }
        ]
        locations = simulator.find_job_location(job_location_args, [])
        assert locations.has_key(jobid)

        location = locations[jobid]
        cqm.run_jobs([{"jobid": jobid}], location)

        r = cqm.get_jobs([{"jobid": jobid, "state": "*", "is_active": True}])
        if not r:
            assert not "the job didn't start"

        time.sleep(20)

        r = cqm.get_jobs([{"jobid": jobid, "state": "*", "is_active": True}])
        if len(r) != 1:
            assert not "the job has stopped running prematurely"

        start_time = time.time()
        while True:
            r = cqm.get_jobs([{"jobid": jobid, "state": "*", "is_active": True}])
            if r:
                if time.time() - start_time > 240:
                    assert not "the job seems to have run overtime"
                else:
                    time.sleep(5)
            else:
                break

        # this time, we'll add a job to the queue, start the job, sleep for a bit
        # and then try to kill the job before it has finished
        nodes = partitions[0]["size"]
        jobs = cqm.add_jobs(
            [
                {
                    "queue": "default",
                    "mode": "co",
                    "command": "/bin/ls",
                    "outputdir": os.getcwd(),
                    "walltime": 4,
                    "nodes": nodes,
                    "procs": nodes,
                    "args": [],
                    "user": "nobody",
                    "jobid": "*",
                }
            ]
        )
        assert len(jobs) == 1

        job = jobs[0]
        jobid = job["jobid"]
        job_location_args = [
            {
                "jobid": jobid,
                "nodes": job["nodes"],
                "queue": job["queue"],
                "utility_score": 1,
                "threshold": 1,
                "walltime": job["walltime"],
                "attrs": {},
            }
        ]
        locations = simulator.find_job_location(job_location_args, [])
        assert locations.has_key(jobid)

        location = locations[jobid]
        cqm.run_jobs([{"jobid": jobid}], location)

        r = cqm.get_jobs([{"jobid": jobid, "state": "*", "is_active": True}])
        if not r:
            assert not "the job didn't start"

        time.sleep(20)

        r = cqm.get_jobs([{"jobid": jobid, "is_active": True}])
        if len(r) != 1:
            assert not "the job has stopped running prematurely"

        cqm.del_jobs([{"jobid": jobid}])

        start_time = time.time()
        while True:
            r = cqm.get_jobs([{"jobid": jobid, "is_active": True, "state": "*"}])
            if r:
                if time.time() - start_time > 30:
                    assert not "the job didn't die when asked to"
                else:
                    time.sleep(1)
            else:
                break
开发者ID:zzhou1985,项目名称:Qsim,代码行数:104,代码来源:TestIntegration.py

示例4: ComponentProxy

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_jobs [as 别名]
    level = 30
    if "-d" in sys.argv:
        level = 10
    user = pwd.getpwuid(os.getuid())[0]
    Cobalt.Logging.setup_logging("cqdel", to_syslog=False, level=level)
    logger = Cobalt.Logging.logging.getLogger("cqdel")
    try:
        cqm = ComponentProxy("queue-manager", defer=False)
    except ComponentLookupError:
        print >> sys.stderr, "Failed to connect to queue manager"
        sys.exit(1)

    for i in range(len(args)):
        if args[i] == "*":
            continue
        try:
            args[i] = int(args[i])
        except:
            logger.error("jobid must be an integer")
            raise SystemExit, 1

    spec = [{"tag": "job", "user": user, "jobid": jobid} for jobid in args]
    jobs = cqm.del_jobs(spec, False, user)
    Cobalt.Util.sleep(1)
    if jobs:
        data = [("JobID", "User")] + [(job.get("jobid"), job.get("user")) for job in jobs]
        print "      Deleted Jobs"
        Cobalt.Util.print_tabular(data)
    else:
        print "cqdel: Job %s not found" % sys.argv[-1]
开发者ID:ido,项目名称:cobalt-svn-old,代码行数:32,代码来源:cqdel.py


注:本文中的Cobalt.Proxy.ComponentProxy.del_jobs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。