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


Python job.Job类代码示例

本文整理汇总了Python中job.Job的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_run_too_soon

 def test_run_too_soon(self):
     job = Job(name='testsuite-job', username='digits-testsuite')
     job.status = Status.WAIT
     job.status = Status.RUN
     # Status.WAIT should be removed so the len should be 2 rather
     # than 3.
     assert len(job.status_history) == 2, 'history length should be 2'
开发者ID:GarfieldEr007,项目名称:DIGITS,代码行数:7,代码来源:test_status.py

示例2: notify

    def notify(self, evt):
        Job.notify(self, evt)
        log.debug("Notified of event: %s" % str(evt.__class__))
        if isinstance(evt, simple.ConnectCompleteEvent) and \
            evt.getSource() == self.connect_job:
            self.conn = evt.getConnection()
            self.run()
        elif isinstance(evt, simple.ConnectFailedEvent) and \
              evt.getSource() == self.connect_job:
            log.error("Failed to connect to agent")
            print "Failed to connect to agent"
            self.getAgent().setState(agent.STOPPING)

        elif isinstance(evt, agent.MessageReceivedEvent) and \
              isinstance(evt.getMessage(), message.Response):

            if isinstance(evt.getMessage(), agent.OkResponse) and \
               self.key == evt.getMessage().getRequestKey():
                print "Shutdown Acknowledged"
                self.getAgent().setState(agent.STOPPING)

            elif isinstance(evt.getMessage(), agent.DeniedResponse) and \
               self.key == evt.getMessage().getRequestKey():
                print "Shutdown Denied"
                self.getAgent().setState(agent.STOPPING)
开发者ID:rhettg,项目名称:JoeAgent,代码行数:25,代码来源:shutdown.py

示例3: test_run_timeout

    def test_run_timeout(self):

        from job_dictator import JobDictator
        from job import Job
        from worker import Worker

        dictator = JobDictator()
        dictator.client = mock.MagicMock()
        dictator.client.keys.return_value = ["job-", "jm-"]
        job = Job("running", "something")
        job.run_started_on = datetime.now() - timedelta(minutes=10)
        worker = Worker("job-", None)
        dictator.client.get.side_effect = [pickle.dumps(job), pickle.dumps(worker)]
        self.request_mock.get = mock.MagicMock()
        dictator.settings = mock.MagicMock()
        dictator.settings.job_timeout = 1
        dictator.headers = mock.MagicMock()
        returner = mock.MagicMock()
        returner.content = "status:ok"
        self.request_mock.get.return_value = returner
        dictator.pull = mock.MagicMock()

        dictator.aladeen()

        assert dictator.client.keys.call_count == 2
        assert dictator.client.get.call_count == 2
        assert dictator.client.set.call_count == 1
        assert dictator.client.publish.call_count == 1
        assert dictator.pull.call_count == 0
        assert pickle.loads(dictator.client.set.call_args_list[0][0][1]).state == "broken"
开发者ID:Deltares,项目名称:dcs,代码行数:30,代码来源:wjc_tests.py

示例4: search

def search(query):
    job = Job(query) #use name prep from job init
    result = cache.get(job.hashtag)
    if not result:
        result = json.dumps(job.execute()) 
        cache.add(job.hashtag, result)
    return result
开发者ID:mzweilin,项目名称:HashTag-Understanding,代码行数:7,代码来源:server.py

示例5: testJobExecuteOnce

    def testJobExecuteOnce(self):
        work_data = [1.111111] * 5
        test_job = Job(0, 0, work_data)

        test_job.execute_next()

        self.assertEqual(int(test_job.work_data[0]), 1112)
开发者ID:Xuefeng-Zhu,项目名称:Load-Balancer,代码行数:7,代码来源:job_test.py

示例6: Move

        def Move(self, pv_src_obj, pv_source_range, pv_dest_obj,
                 pv_dest_range, move_options):
            pv_dest = None
            pv_src = cfg.om.get_by_path(pv_src_obj)
            if pv_src:
                if pv_dest_obj != '/':
                    pv_dest_t = cfg.om.get_by_path(pv_dest_obj)
                    if not pv_dest_t:
                        raise dbus.exceptions.DBusException(
                            interface_name, 'pv_dest_obj (%s) not found' %
                            pv_src_obj)
                    pv_dest = pv_dest_t.lvm_id

                rc, out, err = cmdhandler.pv_move_lv(
                    move_options,
                    self.lvm_id,
                    pv_src.lvm_id,
                    pv_source_range,
                    pv_dest,
                    pv_dest_range)

                if rc == 0:
                    # Create job object for monitoring
                    job_obj = Job(self.lvm_id, None)
                    cfg.om.register_object(job_obj)
                    cfg.kick_q.put("wake up!")
                    return job_obj.dbus_object_path()
                else:
                    raise dbus.exceptions.DBusException(
                        interface_name,
                        'Exit code %s, stderr = %s' % (str(rc), err))
            else:
                raise dbus.exceptions.DBusException(
                    interface_name, 'pv_src_obj (%s) not found' % pv_src_obj)
开发者ID:vpodzime,项目名称:lvm-dubstep,代码行数:34,代码来源:lv.py

示例7: main

def main():
	pygame.init()
	fpsClock = pygame.time.Clock()
	size = 1920, 1200
	background = pygame.image.load("go.jpg")
	screen = pygame.display.set_mode(size)
	screen.blit(background,(0,0))
	width = 0

	while 1:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				sys.exit()
			elif event.type==pygame.KEYDOWN:
				if event.key==pygame.K_ESCAPE:
					sys.exit()
									
		pseudoJob = Job(0)
		myjob = pseudoJob.getData()
		
		for n in range(0, len(myjob)):
			drawing(width, myjob[n], screen)
			if (n != len(myjob) -1):
				width += (myjob[n].node * myjob[n].core) / 5
			else:
				width = 0
		print myjob[0].qtime
		pygame.display.flip()
		fpsClock.tick(30)
开发者ID:66eli77,项目名称:VIS_198,代码行数:29,代码来源:drawD.py

示例8: test_run_too_soon

 def test_run_too_soon(self):
     job = Job('test')
     job.status = Status.WAIT
     job.status = Status.RUN
     # Status.WAIT should be removed so the len should be 2 rather
     # than 3.
     assert len(job.status_history) == 2, 'history length should be 2'
开发者ID:chintak,项目名称:DIGITS,代码行数:7,代码来源:test_status.py

示例9: do_job

 def do_job(self, line):
     conn = self.conn()
     if conn:
         #print "Line = %s" % line
         r = cmd.Cmd.parseline(self, line)
         print "job = " , r
         if r[0] and r[1]:
             print "Sending JOB : %s" % r[0]
             conn.send('job')
             ## On doit recevoir  Ok send your job
             print "Srv => ", conn.recv()
             j=Job()
             j.name=r[0]
             j.cmd=r[1]
             conn.send(j)
             ## On doit recevoir Job receiveing ou erreur "
             print "Srv => ", conn.recv()
             ## On doit recevoir Job job finish"
             print "Srv => ", conn.recv()
             ## On doit recevoir le job
             j = conn.recv()
             ## On doit recevoir Invite de fin OK see your soon"
             print "Srv => ", conn.recv()
             ## la connexion doit se terminer
             ## Affichage du resultat
             j.pr()
         else:
             print "Job incorrecte [%s] [%s]" % (r[0], r[1])
     else:
         print "Not connected"
     ## Dans tout les cas la connexion est ferme
     conn=None
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:32,代码来源:cli_sav.py

示例10: create_job

 def create_job(self,filename,**kwargs):
     """Create a job and try to set the source. Returns bool success."""
     job = Job(**kwargs)
     # Get the default material
     job.material = self.get_material()
     try:
         job.set_source(filename)
         self.job = job
         self.session.add(self.job)
         msg = 'Loaded %s'%os.path.basename(job.name or 'File')
         self.get_window('inkcut').set_title("*%s - Inkcut"%job.name)
         self.flash(msg)
         self.on_plot_feed_distance_changed(self.get_widget('plot-properties','plot-feed'))
         self._update_ui()
         return False
     except Exception, err:
         # update the ui with job info
         log.debug(traceback.format_exc())
         msg = Gtk.MessageDialog(type=Gtk.MessageType.ERROR,
             buttons=Gtk.ButtonsType.OK,
             message_format="Issue loading file")
         msg.format_secondary_text(err)
         msg.run()
         msg.destroy()
         return False
开发者ID:pc-coholic,项目名称:Inkcut,代码行数:25,代码来源:inkcut.py

示例11: test_submit_job_to_ptburn_with_audio

    def test_submit_job_to_ptburn_with_audio(self, label_patch, required_files,
                                             glob_patch):

        required_files.return_value = True
        label = Mock(sermon_title="title", date=datetime.date(2014,1,1),
           day="SUN, AM", minister="H.L. Sheppard")
        label.get_label_key.return_value = "010114PM"
        glob_patch.return_value = ["one.mp3", "two.mp3"]
        
        new_job = Job(1, self.connection)
        new_job.printonly = False
        new_job.label = label
        new_job.submit_job_to_ptburn("/audio/", "/labels/","/tmp/")

        self.assertTrue(os.path.exists("/tmp/JOB_1.jrq"))
        job_file = open("/tmp/JOB_1.jrq").readlines()
        self.assertEquals(len(job_file), 11)
        self.assertTrue("JobID = 1\n" in job_file)
        self.assertTrue("VolumeName = 010114PM\n" in job_file)
        self.assertTrue("AudioFile = one.mp3\n" in job_file)
        self.assertTrue("AudioFile = two.mp3\n" in job_file)
        self.assertTrue("CloseDisc = YES\n" in job_file)
        self.assertTrue("Copies = 1\n" in job_file)
        self.assertTrue("PrintLabel = /labels/cd-label.std\n" in job_file)
        self.assertTrue("MergeField = title\n" in job_file)
        self.assertTrue("MergeField = 01/01/2014\n" in job_file)
        self.assertTrue("MergeField = SUN, AM\n" in job_file)
        self.assertTrue("MergeField = H.L. Sheppard\n" in job_file)
开发者ID:cplazas,项目名称:church-scripts,代码行数:28,代码来源:test_job.py

示例12: test

def test():
    print "Start test"
    global dbName
    dbName = "test.db"

    clear()
    jobs = loadJobs()
    assert len(jobs) == 0

    newJob = Job("test")
    addNewJob(newJob)
    jobs = loadJobs()
    assert len(jobs) == 1
    assert jobs.index(newJob) >= 0

    newJob = jobs[newJob.id]
    newJob.recipeRef = "new test"
    saveJobs(jobs)
    jobs = loadJobs()
    assert newJob.recipeRef == jobs[newJob.id].recipeRef

    clear()
    jobs = loadJobs()
    assert len(jobs) == 0

    print "End test"
开发者ID:baumartig,项目名称:paperboy,代码行数:26,代码来源:shelve_job_handler.py

示例13: load

 def load(self,source=None,source_filename=None,selected_nodes=None):
     # Check if similar job exists
     jobs = self.session.query(Job).filter(Job.source_filename == unicode(source_filename)).all()
     if len(jobs)==0:
         job = Job(source=source,source_filename=source_filename,selected_nodes=selected_nodes)
         job.material = self.session.query(Material).first()
         if job.load():
             # update the ui with job info
             self.job = job
             self._flash(0,'%s loaded'%os.path.basename(job.source_filename or 'File'))
             self._update_preview()
             return True
         else:
             msg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                 buttons=gtk.BUTTONS_CLOSE,
                 message_format=job.messages.pop())
             msg.set_title('Error opening file')
             msg.run()
             msg.destroy()
             return False
     else:
         # open a new job or
         msg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
             buttons=gtk.BUTTONS_CLOSE,
             message_format='A similar job was already found, do you want to load that?')
         msg.set_title('File Already Found opening file')
         msg.run()
         msg.destroy()
         return False
开发者ID:pc-coholic,项目名称:Inkcut,代码行数:29,代码来源:inkcut.py

示例14: _add_gc_job

 def _add_gc_job(self):
     job = Job()
     job.name = 'gc'
     job.job_func= self.gc
     job.set_frequency(10, 'minutes')
     self._add_job(job)
     self.instantiate(job)
开发者ID:zaviichen,项目名称:scheduler,代码行数:7,代码来源:schedule.py

示例15: __init__

	def __init__(self,doc):
		Job.__init__(self, doc)
		try:
			self.format = self.format
		except AttributeError:
			self.format = "json"
		try:
			self.coll_type = self.coll_type
		except AttributeError:
			self.coll_type = None
		
		self._dict_values = {}
		self._dict_values["sources"] = {
							"filename": "%s/export_%s_sources_%s.%s" %(self.project_name, self.name, self.date, self.format),
							"format": self.format,
							"fields": 'url,origin,date.date',
							}
		self._dict_values["logs"] = {
							"filename": "%s/export_%s_logs_%s.%s" %(self.project_name,self.name, self.date, self.format), 
							"format":self.format,
							"fields": 'url,code,scope,status,msg',
							}
		self._dict_values["results"] = {
							"filename": "%s/export_%s_results_%s.%s" %(self.project_name,self.name, self.date, self.format), 
							"format":self.format,
							"fields": 'url,domain,title,content.content,outlinks.url,crawl_date',
							}	
开发者ID:c24b,项目名称:crawlex,代码行数:27,代码来源:export_job.py


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