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


Python Task.Task类代码示例

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


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

示例1: test_sort_backlog_alphanumeric

    def test_sort_backlog_alphanumeric(self):
        StorageDouble.reset()
        #            [Summary, id, due_date]
        tasksTruth = [["Task1", 1, 9],
                      ["Task2", 2, 8],
                      ["Task3", 3, 7],
                      ["Task4", 4, 6],
                      ["Taske", 5, None],
                      ["Taskd", 6, None],
                      ["Taskc", 7, None],
                      ["Taskb", 8, None],
                      ["Taska", 9, None]]

        # Add some tasks and set due dates
        for truth in tasksTruth:
            task = Task(truth[0], "", 0)
            task.id = truth[1]
            task.set_due_date(truth[2])
            StorageDouble.add_task(task)

        # Verify they get sorted correctly
        self.assertTrue(self._runTsk('sort_backlog -a'))
        idOrderTruth = [4, 3, 2, 1, 9, 8, 7, 6, 5]
        idOrder = [ t.id for t in StorageDouble.tasks ]
        self.assertEquals(idOrderTruth, idOrder)
开发者ID:absolom,项目名称:tsk,代码行数:25,代码来源:TskTest.py

示例2: __init__

 def __init__(self, goal):
     Task.__init__(self)
     self.goal = goal
     self.path_request = None
     self.path = deque()
     self.stuck = False
     self.update = self.__request_path
开发者ID:elemel,项目名称:siblings-in-arms,代码行数:7,代码来源:tasks.py

示例3: test_increase_cost

 def test_increase_cost(self):
     task = Task('test_task', 50, 50, None)
     cost = 50
     for i in range(100, 150):
         cost += i
         task.increase_cost(i)
         self.assertTrue(task.actual_cost == cost)
开发者ID:ianfhunter,项目名称:TeamCrab,代码行数:7,代码来源:test_task.py

示例4: __init__

 def __init__(self, engine, controlnum, samprate=44100):
   Task.__init__(self)
   self.engine = engine
   self.controlnum = controlnum
   devnum = self.engine.input.controls.micDevice[controlnum]
   if devnum == -1:
     devnum = None
     self.devname = pa.get_default_input_device_info()['name']
   else:
     self.devname = pa.get_device_info_by_index(devnum)['name']
   self.mic = pa.open(samprate, 1, pyaudio.paFloat32, input=True, input_device_index=devnum, start=False)
   if Config.get('game', 'use_new_pitch_analyzer') or not have_pypitch:
     self.analyzer = Analyzer(samprate)
   else:
     self.analyzer = pypitch.Analyzer(samprate)
   self.mic_started = False
   self.lastPeak    = 0
   self.detectTaps  = True
   self.tapStatus   = False
   self.tapThreshold = -self.engine.input.controls.micTapSensitivity[controlnum]
   self.passthroughQueue = []
   passthroughVolume = self.engine.input.controls.micPassthroughVolume[controlnum]
   if passthroughVolume > 0.0:
     Log.debug('Microphone: creating passthrough stream at %d%% volume' % round(passthroughVolume * 100))
     self.passthroughStream = Audio.MicrophonePassthroughStream(engine, self)
     self.passthroughStream.setVolume(passthroughVolume)
   else:
     Log.debug('Microphone: not creating passthrough stream')
     self.passthroughStream = None
开发者ID:Gamer125,项目名称:fofix,代码行数:29,代码来源:Microphone.py

示例5: __init__

    def __init__(self, name, **kwds):
        Task.__init__(self)
        self._name = name
        self._input_list = []
        self._output_list = []
        self._message_list = []

        # Optional arguments.
        if 'version' in kwds:
            self.version = kwds['version']

        # Update default user number.
        if self.userno == -1:
            self.userno = AIPS.userno

        # See if there is a proxy that can hand us the details for
        # this task.
        params = None
        for proxy in AIPS.proxies:
            try:
                inst = getattr(proxy, self.__class__.__name__)
                params = inst.params(name, self.version)
            except Exception, exception:
                if AIPS.debuglog:
                    print >>AIPS.debuglog, exception
                continue
            break
开发者ID:kernsuite-debian,项目名称:parseltongue,代码行数:27,代码来源:AIPSTask.py

示例6: __init__

    def __init__(self):
        Task.__init__(self)
        self.mouse                = pygame.mouse
        self.mouseListeners       = []
        self.keyListeners         = []
        self.systemListeners      = []
        self.priorityKeyListeners = []
        self.controls             = Controls()
        self.disableKeyRepeat()

        # Initialize joysticks
        pygame.joystick.init()
        self.joystickAxes = {}
        self.joystickHats = {}

        self.joysticks = [pygame.joystick.Joystick(id) for id in range(pygame.joystick.get_count())]
        for j in self.joysticks:
            j.init()
            self.joystickAxes[j.get_id()] = [0] * j.get_numaxes() 
            self.joystickHats[j.get_id()] = [(0, 0)] * j.get_numhats() 
        Log.debug("%d joysticks found." % (len(self.joysticks)))

        # Enable music events
        Audio.Music.setEndEvent(MusicFinished)

        # Custom key names
        self.getSystemKeyName = pygame.key.name
        pygame.key.name       = self.getKeyName
开发者ID:Hawkheart,项目名称:fof-reborn,代码行数:28,代码来源:Input.py

示例7: __init__

 def __init__(self, engine, mic):
   Task.__init__(self)
   self.engine = engine
   self.channel = None
   self.mic = mic
   self.playing = False
   self.volume = 1.0
开发者ID:HugoLnx,项目名称:fofix,代码行数:7,代码来源:Audio.py

示例8: taskEditPost

def taskEditPost(handler, ids, p_hours, p_status, p_goal, p_assigned=[], p_include={}):
    handler.title("Edit tasks")
    requirePriv(handler, "Write")

    allIDs = map(int, uniq(ids.split(",")))
    ids = map(lambda i: to_int(i, "include", ErrorBox.die), p_include.keys())
    if not set(ids) <= set(allIDs):
        ErrorBox.die("Included tasks don't match query arguments")

    tasks = dict((id, Task.load(id)) for id in ids)
    if not all(tasks.values()):
        ids = [str(id) for (id, task) in tasks.iteritems() if not task]
        ErrorBox.die(
            "No %s with %s %s"
            % ("task" if len(ids) == 1 else "tasks", "ID" if len(ids) == 1 else "IDs", ", ".join(ids))
        )
    tasks = [tasks[id] for id in ids]
    if len(set(task.sprint for task in tasks)) > 1:
        ErrorBox.die("All tasks must be in the same sprint")
    sprint = (tasks[0] if len(tasks) > 0 else Task.load(allIDs[0])).sprint
    if sprint.isHidden(handler.session["user"]):
        ErrorBox.die(
            "No %s with %s %s"
            % ("task" if len(ids) == 1 else "tasks", "ID" if len(ids) == 1 else "IDs", ", ".join(ids))
        )
    if not sprint.canEdit(handler.session["user"]):
        ErrorBox.die("You don't have permission to modify this sprint")

    assignedids = set(to_int(i, "assigned", ErrorBox.die) for i in p_assigned)

    changes = {
        "assigned": False if assignedids == set() else {User.load(assignedid) for assignedid in assignedids},
        "hours": False if p_hours == "" else int(p_hours),
        "status": False if p_status == "" else p_status,
        "goal": False if p_goal == "" else Goal.load(int(p_goal)),
    }

    if changes["assigned"] and not all(changes["assigned"]):
        ErrorBox.die("Invalid assignee")
    if changes["assigned"] and not set(changes["assigned"]).issubset(sprint.members):
        ErrorBox.die("Unable to assign tasks to non-sprint members")
    if changes["goal"] and changes["goal"].sprint != sprint:
        ErrorBox.die("Unable to set goal to a goal outside the sprint")

    changed = set()
    for task in tasks:
        for field, value in changes.iteritems():
            if value is not False and getattr(task, field) != value:
                setattr(task, field, value)
                changed.add(task)
                Event.taskUpdate(handler, task, field, value)

    if len(changed) == 0:
        delay(handler, WarningBox("No changes necessary", close=3, fixed=True))
    else:
        for task in changed:
            task.saveRevision(handler.session["user"])
        delay(handler, SuccessBox("Updated %d %s" % (len(changed), "task" if len(changed) == 1 else "tasks")))
    redirect("/sprints/%d" % sprint.id)
开发者ID:nolandda,项目名称:Sprint,代码行数:59,代码来源:tasks.py

示例9: InitActions

    def InitActions(self):
        impression = Task()
        talk = Task()

        impression.set_c_attribute("Pre", self)

        self.__actions["Impression"] = impression
        self.__actions["Talk"] = talk
开发者ID:Krypticdator,项目名称:First,代码行数:8,代码来源:Character.py

示例10: __init__

 def __init__(self, server, command):
     Task.__init__(self)
     self.server= server
     self.command=command
     
     self.name="ExecuteRemoteWinCommandTask"
     self.description= "this task is used to execute command on remote machine through rpyc"
     self.stat=TaskStatus.RUNNING
开发者ID:zhangjianleaves,项目名称:Dahe,代码行数:8,代码来源:ExecuteRemoteCommandTask.py

示例11: newTaskPost

def newTaskPost(handler, p_group, p_name, p_goal, p_status, p_hours, p_assigned=[]):
    def die(msg):
        print msg
        done()

    requirePriv(handler, "User")
    handler.wrappers = False

    groupid = to_int(p_group, "group", die)
    group = Group.load(groupid)
    if not group or group.sprint.isHidden(handler.session["user"]):
        die("No group with ID <b>%d</b>" % groupid)

    sprint = group.sprint
    if not (sprint.isActive() or sprint.isPlanning()):
        die("Unable to modify inactive sprint")
    elif not sprint.canEdit(handler.session["user"]):
        die("You don't have permission to modify this sprint")

    if p_name.strip() == "":
        die("Task must have a non-empty name")

    assignedids = set(to_int(i, "assigned", die) for i in p_assigned)
    assigned = set(User.load(assignedid) for assignedid in assignedids)
    if assigned == set():
        assigned.add(handler.session["user"] if handler.session["user"] in sprint.members else sprint.owner)
    if not all(assigned):
        die("Invalid assignee")

    goalid = to_int(p_goal, "goal", die)
    if goalid != 0:
        goal = Goal.load(goalid)
        if not goal:
            die("No goal with ID <b>%d</b>" % goalid)
        if goal.sprint != group.sprint:
            die("Goal does not belong to the correct sprint")

    hours = to_int(p_hours, "hours", die)

    task = Task(groupid, group.sprintid, handler.session["user"].id, goalid, p_name, p_status, hours)
    task.assigned |= assigned
    task.save()

    handler.responseCode = 299
    delay(
        handler,
        """
<script type=\"text/javascript\">
$(document).ready(function() {
	$('#task%d').effect('highlight', {}, 3000);
});
</script>"""
        % task.id,
    )
    delay(handler, SuccessBox("Added task <b>%s</b>" % task.safe.name, close=3, fixed=True))
    Event.newTask(handler, task)
开发者ID:nolandda,项目名称:Sprint,代码行数:56,代码来源:tasks.py

示例12: importTasks

def importTasks():

# ---  Read tasks from files.	
	global taskList,resourceFileName,taskFileName,dependencyFileName
	global resources
	fptasks = open(taskFileName,"r")#"tasks.txt","r")

	for line in fptasks.readlines():		
		newTask = Task()
		t = line.split(",")	
		newTask.name = t[1]		
		newTask.id = int(t[0])
		newTask.duration = int(t[2])
		adjacencyList[newTask.id] = []
		taskList.append(newTask)	
	fptasks.close()			

#---- Read resources
	fpresources = open(resourceFileName,"r")#("resources.txt","r")
	
	for line in fpresources.readlines():
		r = line.strip().split(",")
		newResource = Resource(int(r[0]),r[1])
		resources += [newResource]
				
	fpresources.close()

# ---- Read depedencies and create predecessor list -----
	fpdependencies = open(dependencyFileName,"r")#("dependencies.txt","r")	

	for line in fpdependencies.readlines():
		line = line.rstrip()
		print(line)		
		x = line.split(",")
		if(len(x)>1):
			task = getTaskFromId(int(x[0]))
			for i in range(1,len(x)):
				task.predecessors.append(int(x[i]))
		"""if len(x) >1:			
			z = x[1]		
			for task in taskList:
				if task.id == int(x[0]):			 					
					y = z.strip().split(",")	
					for b in y:
						task.predecessors.append(int(b))"""								
				#print(x[0],task.predecessor)
	fpdependencies.close()


# ---- Create successor list ----
	for succTask in taskList:
		#succTask = getTaskFromId()
		for predId in succTask.predecessors:
			task = getTaskFromId(predId)
			task.successors.append(succTask.id)
 			adjacencyList[task.id] = task.successors
开发者ID:vishs005,项目名称:Task-Scheduler-Python,代码行数:56,代码来源:scheduler.py

示例13: test_open

    def test_open(self):
        task = Task("Task", "", 0)
        task.id = 1
        task.close()
        StorageDouble.add_task(task)

        self.assertTrue(self._runTsk('open 1'))
        self.assertTrue(StorageDouble.get_task(1).is_open())

        self.assertFalse(self._runTsk('open 2'))
开发者ID:absolom,项目名称:tsk,代码行数:10,代码来源:TskTest.py

示例14: __init__

 def __init__(self, machinename, localfile, remotefile):
     Task.__init__(self)
     
     self.name="DownloadFileTask"
     self.description="This task is used to download file from rpyc server"
     self.stat=TaskStatus.RUNNING
     
     self.machinename=machinename
     self.localfile=localfile
     self.remotefile=remotefile
开发者ID:zhangjianleaves,项目名称:Dahe,代码行数:10,代码来源:DownloadFileTask.py

示例15: newTask

 def newTask(self, name=None, estimated=None, tag=""):
   name = colored("Untitled","red") if name == None else name
   estimated = 0.0 if estimated == None else estimated
   try:
     self.pauseCurrentTask()
   except TaskNotFoundException as nte:
     pass
   t = Task({ "name": name, "tag": tag, "estimated": estimated, })
   t.start()
   Taskr.tasks.append(t)
开发者ID:mbenitezm,项目名称:taskr,代码行数:10,代码来源:Taskr.py


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