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


Python Task.id方法代码示例

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


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

示例1: calculate

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
	def calculate(self, loadcases, input_list):
		"""
		For all items in input_list create Task instance and run them.
		Return ids of created Tasks
		"""
		if not isinstance(loadcases, list):
			loadcases = [loadcases]
		# if some loadcases needed in filetransfer, run ftp server
		# for loadcase in loadcases:
		# 	if loadcase.need_filetransfer:
		# 		run_fileserver()
		# 		break
		result_ids = []
		if isinstance(input_list, dict):
			input_list = _dict_to_list(input_list)
		# if even though one loadcase need local work, run all all loadcases on client computer
		#  TODO think about case, when client couldn't run particular loadcase
		is_local_loadcases = False
		for lc in loadcases:
			is_local_loadcases |= lc.is_local
		for item in input_list:
			task = Task(loadcases, item)
			if not self._is_local_work and not is_local_loadcases:
				async_result = remote_run.delay(task)
				task.id = async_result.task_id
				result_ids.append(task.id)
			else:
				self._task_counter += 1
				result_ids.append(self._task_counter)
				#TODO error handling
				self._id_to_task[self._task_counter] = local_run(task)
		return result_ids
开发者ID:MSTU,项目名称:grid,代码行数:34,代码来源:modelgrid.py

示例2: onApply

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
    def onApply(self, data):
        """Reads the information from the dialog and saves the task."""
        # Get the information from the dialog and save it to the database
        t = Task()

        # Make sure that there was text in the text box
        if len(self.widgets.get_widget('TaskEntry').get_text()) > 1:
            # Set the task name to the value of the text box
            t.name = self.widgets.get_widget('TaskEntry').get_text()

            # Set the priority to the value of the combo box
            t.priority = self.widgets.get_widget('PriorityEntry').get_active()

            # Set the status to not completed
            t.status = self.widgets.get_widget('StatusEntry').get_active()

            # Set the id of the task
            t.id = self.taskid

            # Set the due date of the task
            t.duedate = self.widgets.get_widget('DateEntry').get_date()

            # Save the task in the database
            self.db.saveTask(t)

        # Close the dialog
        self.dialog.destroy()
开发者ID:Alwnikrotikz,项目名称:tuxedo,代码行数:29,代码来源:editdialog.py

示例3: add_task

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
    def add_task(self, start_date, name, message, completeness, priority=1):
        if passed_date(start_date):
            return False

        if not start_date in self.todos.keys():
            self.todos[start_date] = []

        target_task = Task(start_date, name, message, completeness, priority)
        target_task.id = self.get_id()
        self.todos[start_date].append(target_task)
        return True
开发者ID:nkvelkov,项目名称:Pyganizer,代码行数:13,代码来源:scheduler.py

示例4: start_shakecast

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
 def start_shakecast(self):
     try:
         status = ''
         message = ''
         task_names = [task.name for task in self.queue]
         if 'geo_json' not in task_names:
             task = Task()
             task.id = int(time.time() * 1000000)
             task.func = geo_json
             task.loop = True
             task.interval = 60
             task.db_use = True
             task.name = 'geo_json'
         
             self.queue += [task]
             message += 'Started monitoring earthquake feed \n'
         else:
             pass
         
         if 'check_new' not in task_names:
             task = Task()
             task.id = int(time.time() * 1000000)
             task.func = check_new
             task.loop = True
             task.interval = 3
             task.db_use = True
             task.name = 'check_new'
             
             self.queue += [task]
             message += "Waiting for new events"
         else:
             pass
         status = 'finished'
     except:
         status = 'failed'
     
     
     return {'status': status,
             'message': message}
开发者ID:LTurner-CT,项目名称:shakecast,代码行数:41,代码来源:server.py

示例5: start_shakecast

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
    def start_shakecast(self):
        logging.info('Starting ShakeCast Server... ')
        try:
            status = ''
            message = ''
            task_names = [task.name for task in self.queue]

            if 'fast_geo_json' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.geo_json
                task.loop = True
                task.interval = 60
                task.db_use = True
                task.name = 'fast_geo_json'
                task.args_in = {'query_period': 'hour'}
            
                self.queue += [task]
                message += 'Started monitoring earthquake feed \n'
            
            if 'check_new' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.check_new
                task.loop = True
                task.interval = 3
                task.db_use = True
                task.name = 'check_new'
                
                self.queue += [task]
                message += "Waiting for new events"

            if 'check_for_updates' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = f.check_for_updates
                task.loop = True
                task.interval = 60
                task.name = 'check_for_updates'
                
                self.queue += [task]
                message += "Looking for updates"

            if 'record_messages' not in task_names:
                task = Task()
                task.id = int(time.time() * 1000000)
                task.func = self.record_messages
                task.loop = True
                task.interval = 5
                task.name = 'record_messages'

                self.queue += [task]
                message += "Recording messages"

            status = 'finished'
        except:
            status = 'failed'
        
        
        return {'status': status,
                'message': message}
开发者ID:dslosky-usgs,项目名称:shakecast,代码行数:63,代码来源:server.py

示例6: Task

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import id [as 别名]
        except sqlite.Error, message:
            errordialog = gtk.MessageDialog(None, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, 'Error in reading a task from database:\n\n' + message.message)
            errordialog.run()
            errordialog.destroy()

        # Fetch one result and store it
        result = cursor.fetchone()

        # Create a Task object to store the information in
        t = Task()

        # Set the values from the database results
        t.name = result[0]
        t.priority = result[1]
        t.status = result[2]
        t.id = result[3]
        t.duedate = (result[4], result[5], result[6])

        # Return the task object
        return t

    def readTasks(self):
        """Reads all of the tasks from the database and returns them in a list"""
        # Create a cursor for the database
        cursor = sqlite.connect(DBPATH).cursor()

        # Create a tuple with the constant for completed tasks for the query
        data = task.TASK_COMPLETED,

        # Try to get all of the tasks that are not completed
        try:
开发者ID:Alwnikrotikz,项目名称:tuxedo,代码行数:33,代码来源:database.py


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