• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python task.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: spawnImmediateTask

    def spawnImmediateTask(self, jobid, taskid_complex=None, params=None):
        '''
        Run task immediately using basic configuration of job
        
        @param jobid:int
        @param taskid_complex: string 
        @param params: string
        '''
        job = Job.getByJobID(jobid)
        if not job:
            raise ValueError("Job(id:%d) is not existed or not enabled." % (jobid))
        if params :
            job.set_command(job._substituteReservedWord(params))

        if taskid_complex:
            task = Task(job.get_jobid(), uuid.uuid1().hex, datetime.now(),
                            job.getCommandToExcute(), job.get_retry(), job, job.get_depend(), taskid_complex)
        else:
            task = Task(job.get_jobid(), uuid.uuid1().hex, datetime.now(),
                            job.getCommandToExcute(), job.get_retry(), job, job.get_depend())
        t = TaskRunner(0, task, self._status, self, params)
        t.daemon = True
        task.save()
        self._status.add_waiting_task(task, t)
        t.start()
        
        return task
开发者ID:magus0219,项目名称:clockwork,代码行数:27,代码来源:jobmanager.py


示例2: add_function

def add_function(subparsers, module, funcname):
    func = getattr(module, funcname)
    if getattr(func, 'ignore', False) or not inspect.isfunction(func):
        return
    depends = getattr(func, "depends", None)
    task = Task(funcname, func, depends)
    rules[funcname] = task

    subparser = subparsers.add_parser(funcname, help=func.__doc__)
    args, varargs, keywords, defaults = inspect.getargspec(func)
    defaults = defaults or []
    args = args or []
    n_args = len(args) - len(defaults)
    for arg in args[:n_args]:
        subparser.add_argument(arg)
        task.args.append(arg)
    if varargs:
        subparser.add_argument(varargs,
                nargs="*")
        task.varargs = varargs
    for arg, default in zip(args[n_args:], defaults):
        task.args.append(arg)
        task.defaults[arg] = default
        name = ('-' if len(arg) == 1 else '--') + arg
        if isinstance(default, bool):
            action = "store_" + str(not default).lower()
            subparser.add_argument(name, default=default, action=action)
        elif isinstance(default, int):
            subparser.add_argument(name, default=default,
                    action="store", type=int)
        else:
            subparser.add_argument(name, default=default,
                    action="store")
开发者ID:kespindler,项目名称:pymake,代码行数:33,代码来源:main.py


示例3: __init__

	def __init__(self, project, name):
		Task.__init__(self)
		Persistent.__init__(self, project.persistent, name)
		self.name = name
		self.fhs = FHS.shared(project)
		project.option_collector.option_decls.add(self.__class__)
		self.check_missing = project.options.get('check-missing', 'yes') != 'no'
开发者ID:psycledelics,项目名称:wonderbuild,代码行数:7,代码来源:install.py


示例4: compile_enb

 def compile_enb(self, build_arguments, log_suffix=""):
     log("INFO: ALU test: compile softmodem on " + self.enb_machine)
     envcomp = list(self.env)
     envcomp.append('BUILD_ARGUMENTS="' + build_arguments + '"')
     #we don't care about BUILD_OUTPUT but required (TODO: change that)
     envcomp.append('BUILD_OUTPUT=/')
     logdir = self.logdir + "/compile_log"
     remote_files = "'/tmp/oai_test_setup/oai/cmake_targets/log/*'"
     post_action = "mkdir -p "+ logdir + \
             " && sshpass -p " + self.oai_password + \
             " scp -r " + self.oai_user + \
             "@" + self.enb_machine + ":" + remote_files + " " + logdir + \
             " || true"
     task = Task("actions/compilation.bash",
             "compile_softmodem",
             self.enb_machine,
             self.oai_user,
             self.oai_password,
             envcomp,
             self.logdir + "/compile_softmodem." + log_suffix + \
                 self.enb_machine,
             post_action=post_action)
     ret = task.wait()
     if ret != 0:
         log("ERROR: softmodem compilation failure");
         raise TestFailed()
     task.postaction()
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:27,代码来源:alu_test.py


示例5: start_epc

    def start_epc(self):
        #launch HSS, wait for prompt
        log("INFO: ALU test: run HSS")
        self.task_hss = Task("actions/alu_hss.bash",
                "alu_hss",
                self.epc_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/alu_hss." + self.epc_machine,
                event=self.event)
        self.task_hss.waitlog('S6AS_SIM-> ')

        #then launch EPC, wait for connection on HSS side
        log("INFO: ALU test: run EPC")
        task_epc = Task("actions/alu_epc.bash",
                "ALU EPC",
                self.epc_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/alu_epc." + self.epc_machine)
        ret = task_epc.wait()
        if ret != 0:
            log("ERROR: EPC start failure");
            raise TestFailed()
        self.task_hss.waitlog('Connected\n')
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:27,代码来源:alu_test.py


示例6: __init__

    def __init__(self, conf):
        Task.__init__(self, conf)
        self.name = "Nginx"
        self.addRequiredFields(["base_dir", "domain_name", "nginx_template_url"])
        self.packages = ["nginx"]

        self.checkRequiredConf(conf)
开发者ID:xavicolomer,项目名称:Automata,代码行数:7,代码来源:nginx.py


示例7: get

  def get(self, project, queue, task):
    """ Get the named task in a queue.

    Args:
      project: A string containing an application ID.
      queue: A string containing a queue name.
      task: A string containing a task ID.
    """
    task = Task({'id': task, 'queueName': queue})

    requested_fields = self.get_argument('fields', None)
    if requested_fields is None:
      fields = TASK_FIELDS
    else:
      fields = parse_fields(requested_fields)

    omit_payload = False
    if 'payloadBase64' not in fields:
      omit_payload = True

    queue = self.queue_handler.get_queue(project, queue)
    if queue is None:
      write_error(self, HTTPCodes.NOT_FOUND, 'Queue not found.')
      return

    task = queue.get_task(task, omit_payload=omit_payload)
    self.write(json.dumps(task.json_safe_dict(fields=fields)))
开发者ID:,项目名称:,代码行数:27,代码来源:


示例8: menu

def menu(arguments):
    if arguments['list']:
        if arguments['--recursive']:
            task_lineage(arguments)

        else:
            task_list(arguments)

    else:
        try:
            if arguments['create']:
                Task.create(**_task_create_kwargs(arguments))

            elif arguments['read']:
                task_read(arguments)

            elif arguments['set']:
                task_set(arguments)

            elif arguments['delete']:
                Task(arguments['<name>']).delete()

            elif arguments['reset']:
                task_reset(arguments)

        except NameError as exc:
            print(PACKAGE_NAME, 'Error!', exc)
            sys.exit(1)
开发者ID:avitalyahel,项目名称:autolite,代码行数:28,代码来源:autolite_task.py


示例9: read_tasks

 def read_tasks(cls, infile):
     tasks = []
     default_tz = pytz.utc
     for event, elem in etree.iterparse(infile, events=("start", "end")):
         if event == "start":
             if elem.tag == "defaults":
                 in_defaults = True
         else:
             # Stop reading as soon as the </tasks> tag is encountered.
             if elem.tag == "tasks":
                 break
             elif elem.tag == "defaults":
                 in_defaults = False
             # Otherwise, parse each <task> element in accordance to the way
             # it was output.
             elif elem.tag == "task":
                 attrs = elem.attrib
                 # XXX When project of a task becomes something more than
                 # just a string, the code will probably break on the
                 # following line.
                 if "project" in attrs:
                     project = attrs["project"]
                 else:
                     project = ""
                 task = Task(name=elem.text, project=project, id=int(attrs["id"]))
                 if "done" in attrs:
                     task.done = bool(int(attrs["done"]))
                 if "time" in attrs:
                     task.time = cls._timedelta_fromrepr(attrs["time"])
                 if "deadline" in attrs:
                     task.deadline = cls._read_time(attrs, "deadline", default_tz=default_tz)
                 tasks.append(task)
             elif elem.tag == "timezone" and in_defaults:
                 default_tz = pytz.timezone(elem.text)
     return tasks
开发者ID:RichardLitt,项目名称:wyrd-django-dev,代码行数:35,代码来源:xml.py


示例10: __init__

	def __init__(self, message, hosts):
		Task.__init__(self)
		self.__message = message
		self.__hosts = hosts
		with database.transaction() as t:
			t.execute("SELECT CURRENT_TIMESTAMP AT TIME ZONE 'UTC'")
			(self.__batch_time,) = t.fetchone()
开发者ID:CZ-NIC,项目名称:ucollect,代码行数:7,代码来源:cert.py


示例11: __init__

 def __init__(self, url, path=None, overwrite=False, **kwargs):
     Task.__init__(self)
     self.url = url
     self.path = path
     self.overwrite = overwrite
     self.kwargs = kwargs
     self.size = 0
开发者ID:robmcmullen,项目名称:dinoteeth,代码行数:7,代码来源:download.py


示例12: ffmpeg

def ffmpeg(arg):
	
	torun = Task(createfrom=arg)

	# Get the output file extension:
	destExtension = torun.outfile.split(".")[-1]
	print torun.outfile.split(".")
	tmpfile = "tmp." + destExtension

	codeccheck = subprocess.Popen(["ffmpeg", "-codecs"], stdout=subprocess.PIPE)
	allcodecs = codeccheck.communicate()[0]
	if allcodecs.find("libfdk_aac") == -1:
		print "Install libfdk_aac for better audio quality!"
		if torun.forcefdk == True:
			print "Server has disabled workers without libfdk_aac!"
			sys.exit()
		else:
			if "libfdk_aac" in torun.arguments:
				libfdk_pos = torun.arguments.index("libfdk_aac")
				torun.arguments[libfdk_pos] = "aac"
				torun.arguments.append("-strict")
				torun.arguments.append("-2")

	out=subprocess.call(["ffmpeg","-i", torun.infile]+torun.arguments+[tmpfile])
	if not out == 0:
		print "FFMPEG FAILED"
	else:
		shutil.move(tmpfile,torun.outfile)
		os.remove(torun.infile)

	try:
		os.remove(tmpfile)
	except:
		pass
开发者ID:magmastonealex,项目名称:ffproc,代码行数:34,代码来源:worker.py


示例13: __init__

    def __init__(self, conf):
        Task.__init__(self,conf) 
        self.name = 'Django Install'
        self.addRequiredFields(['django_url','base_dir','domain_name']) 
	self.packages = ['cron','python-mysqldb']

        self.checkRequiredConf(conf)
开发者ID:xavicolomer,项目名称:Automata,代码行数:7,代码来源:django.py


示例14: create_valid_task

def create_valid_task():
    unit_id = "3c82ef61-0875-41d3-99ba-101672d79d6b"
    task_id = uuid.uuid4().hex
    valid_json_dict = {
        "title": "Blank", 
        "task_id": task_id, 
        "chronicle": [
                                        {
                                            "time_ms": 0.3,
                                            "unit_id": unit_id,
                                            "hop": 1
                                        }
                                    ], 
        "from_unit": unit_id, 
        "to_unit": "a789ada1-edb5-4cfe-b1f9-8584abbf8a2f", 
        "command": {
            "announce": {}
        }, 
        "response": {}
    }
    valid_command = Task(unit_id, **valid_json_dict)
    valid_response = Task(unit_id, **valid_json_dict)
    valid_response.add_response(response = {"response":"yes"})
    
    return valid_command, valid_response   
开发者ID:EnableThing,项目名称:enablething-pythonlibrary,代码行数:25,代码来源:test_unit.py


示例15: __init__

    def __init__(self, robot, link, target, **kwargs):
        if hasattr(target, 'robot_link'):  # used for ROS communications
            target.robot_link = link.index  # dirty
        elif type(target) is list:
            target = array(target)

        def _pos_residual(target_pose):
            residual = target_pose - link.pose
            if dot(residual[0:4], residual[0:4]) > 1.:
                return _oppose_quat * target_pose - link.pose
            return residual

        if hasattr(target, 'pose'):
            def pos_residual():
                return _pos_residual(target.pose)
        elif type(target) is ndarray:
            def pos_residual():
                return _pos_residual(target)
        else:  # link frame target should be a pose
            raise Exception("Target %s has no 'pose' attribute" % type(target))

        def jacobian():
            return robot.compute_link_pose_jacobian(link)

        self.link = link
        Task.__init__(self, jacobian, pos_residual=pos_residual, **kwargs)
开发者ID:stephane-caron,项目名称:pymanoid,代码行数:26,代码来源:contact.py


示例16: __init__

 def __init__(self, conf):
     Task.__init__(self,conf) 
     self.name = 'MySql'
     self.packages = ['mysql-server','mysql-client']
     self.addRequiredFields(['mysql_username','mysql_database_name','mysql_password'])
     
     Task.checkRequiredConf(self,conf) 
开发者ID:xavicolomer,项目名称:Automata,代码行数:7,代码来源:mysql.py


示例17: __init__

 def __init__(self, foot = core.Kick.RIGHT, desiredDistance = 2000.0):
   Task.__init__(self)
   self.kickRunning = False
   self.postKick = False
   self.foot = foot
   self.desiredDistance = desiredDistance
   self.sm = SimpleStateMachine(['startup', 'kicking', 'finish'])
开发者ID:rdspring1,项目名称:cs393r,代码行数:7,代码来源:kicks.py


示例18: wait

    def wait(self, wait_time=0):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``False`` if it timeouts.

        :arg wait_time: Time in seconds to wait, default is infinite.

        :return: :class:`~retask.task.Task` object from the queue or False if it timeouts.

        .. doctest::

           >>> from retask.queue import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> task = q.wait()
           >>> print task.data
           {u'name': u'kushal'}

        .. note::

            This is a blocking call, you can specity wait_time argument for timeout.

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        data = self.rdb.brpop(self._name, wait_time)
        if data:
            task = Task()
            task.__dict__ = json.loads(data[1])
            return task
        else:
            return False
开发者ID:ralphbean,项目名称:retask,代码行数:33,代码来源:queue.py


示例19: install

    def install(self):
        print "Installing " + self.name + "..."

        Task.install_packages(self)

        """ Open template and substitute variables """
        f = open(self.nginx_template_url, "r")
        template = f.read()

        template = re.sub("{{domain_name}}", self.domain_name, template)
        template = re.sub("{{base_dir}}", self.base_dir, template)

        f = open(self.base_dir + "/" + self.domain_name + "/conf/nginx.conf", "w")
        f.write(template)
        f.close()

        """ Link files to nginx """
        result = call(
            "ln -s "
            + self.base_dir
            + "/"
            + self.domain_name
            + "/conf/nginx.conf /etc/nginx/sites-available/"
            + self.domain_name,
            shell=True,
        )
        result = call(
            "ln -s /etc/nginx/sites-available/" + self.domain_name + "  /etc/nginx/sites-enabled/" + self.domain_name,
            shell=True,
        )

        """ Restart Nginx """
        result = call("/etc/init.d/nginx restart", shell=True)

        return True
开发者ID:xavicolomer,项目名称:Automata,代码行数:35,代码来源:nginx.py


示例20: dequeue

    def dequeue(self):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``None`` if the
        queue is empty.

        :return: :class:`~retask.task.Task` object from the queue

        If the queue is not connected then it will raise
        :class:`retask.ConnectionError`

        .. doctest::

           >>> from retask.queue import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> t = q.dequeue()
           >>> print t.data
           {u'name': u'kushal'}

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        if self.rdb.llen(self._name) == 0:
            return None

        data = self.rdb.rpop(self._name)
        task = Task()
        task.__dict__ = json.loads(data)
        return task
开发者ID:ralphbean,项目名称:retask,代码行数:31,代码来源:queue.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python task.ValidationException类代码示例发布时间:2022-05-27
下一篇:
Python task.Register类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap