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


Python tasks.TaskApi类代码示例

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


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

示例1: reset

    def reset(job_id):
        job = Job.query.get(job_id)
        if job:
            if job.status in ['active', 'waiting']:
                logging.error("Job {0} is running".format(job_id))
                response = jsonify({
                    'code' : 400,
                    'message': "This job is running, stop it first."})
                response.status_code = 400
                return response
            else:
                log = "Status changed from {0} to {1}".format(job.status, 'waiting')
                job.status = 'waiting'
                job.tasks_status = json.dumps({
                    'count': job.tasks.count(),
                    'completed': 0,
                    'failed': 0,
                    'canceled': 0})
                job.date_edit = datetime.now()
                db.session.commit()
                log_to_database(job_id, 'job', log)

                TaskApi.delete_tasks(job.id)
                TaskApi.create_tasks(job)
                logging.info('Job {0} reset end ready'.format(job_id))

        else:
            logging.error("Job {0} not found".format(job_id))
            raise KeyError
开发者ID:Anuga,项目名称:flamenco,代码行数:29,代码来源:__init__.py

示例2: reset

    def reset(job_id):
        job = Job.query.get(job_id)
        if job:
            if job.status == 'running':
                logging.error("Job {0} is running".format(job_id))
                response = jsonify({
                    'code' : 400,
                    'message': "This job is running, stop it first."})
                response.status_code = 400
                return response
            else:
                log = "Status changed from {0} to {1}".format(job.status, 'ready')
                job.status = 'ready'
                job.date_edit = datetime.now()
                db.session.commit()
                log_to_database(job_id, 'job', log)

                TaskApi.delete_tasks(job.id)
                TaskApi.create_tasks(job)

                # Security check
                # insecure_names = [None, "", "/", "\\", ".", ".."]
                # path = join(job.project.render_path_server, str(job.id))
                # if job.project.render_path_server not in insecure_names and str(job.id) not in insecure_names:
                #     if exists(path):
                #         rmtree(path)
                logging.info('Job {0} reset end ready'.format(job_id))

        else:
            logging.error("Job {0} not found".format(job_id))
            raise KeyError
开发者ID:madmouser1,项目名称:flamenco,代码行数:31,代码来源:__init__.py

示例3: respawn

    def respawn(self, job_id):
        job = Job.query.get(job_id)
        if job:
            if job.status == 'active':
                self.stop(job_id)

            tasks = db.session.query(Task).filter(
                Task.job_id == job_id, Task.status.notin_(
                    ['completed','failed'])).all()
            best_managers = db.session.query(Manager).join(
                JobManagers, Manager.id == JobManagers.manager_id)\
                    .filter(JobManagers.job_id == job_id)\
                    .filter(Manager.has_virtual_workers == 1)\
                    .first()

            if best_managers:
                fun = partial(TaskApi.start_task, best_managers)
                map(fun, tasks)
            else:
                map(lambda t : setattr(t, 'status', 'waiting'), tasks)
                db.session.commit()
                TaskApi.dispatch_tasks()
        else:
            logging.error('Job %d not found' % job_id)
            raise KeyError
开发者ID:pedromaltez-forks,项目名称:flamenco,代码行数:25,代码来源:__init__.py

示例4: post

    def post(self):
        args = id_list.parse_args()
        print Job.query.all()
        print args['id']
        int_list = list_integers_string(args['id'])
        for j in int_list:
            TaskApi.delete_tasks(j)
            job = Job.query.get(j)
            if job:
                #path = os.path.join(job.project.render_path_server, str(j))
                #Security check
                #insecure_names=[None, "", "/", "\\", ".", ".."]
                #if job.project.render_path_server not in insecure_names and str(j) not in insecure_names:
                #    if exists(path):
                #        rmtree(path)

                db.session.query(JobManagers).filter(JobManagers.job_id == job.id).delete()
                db.session.delete(job)
                db.session.commit()
                print "[info] Deleted job %d" % j
            else:
                print "[error] Job %d not found" % j
                return '', 404

        return '', 204
开发者ID:EVMosaic,项目名称:flamenco,代码行数:25,代码来源:__init__.py

示例5: reset

    def reset(job_id):
        job = Job.query.get(job_id)
        if job.status == 'running':
            logging.error('Job {0} is running'.format(job_id))
            response = jsonify({
                'code' : 400,
                'message': 'This job is running, stop it first.'})
            response.status_code = 400
            return response
        else:
            job.current_frame = job.frame_start
            job.status = 'ready'
            db.session.add(job)
            db.session.commit()

            TaskApi.delete_tasks(job.id)
            TaskApi.create_tasks(job)

            #Security check
            insecure_names=[None, "", "/", "\\", ".", ".."]
            path = os.path.join(job.project.render_path_server, str(job.id))
            if job.project.render_path_server not in insecure_names and str(job.id) not in insecure_names:
                if os.path.exists(path):
                    rmtree(path)
            logging.info('Job {0} reset end ready'.format(job_id))
开发者ID:EVMosaic,项目名称:flamenco,代码行数:25,代码来源:__init__.py

示例6: post

    def post(self):
        args = job_parser.parse_args()

        """job_settings = {
            'frame_start' : args['frame_start'],
            'frame_end' : args['frame_end'],
            'chunk_size' : args['chunk_size'],
            'filepath' : args['filepath'],
            'render_settings' : args['render_settings'],
            'format' : args['format'],
            }"""

        status = 'ready'
        if args['start_job'] and args['start_job'] == 'True':
            status = 'running'

        job = Job(
           project_id=args['project_id'],
           settings=args['settings'],
           name=args['name'],
           status=status,
           type=args['type'],
           priority=args['priority'],
           date_edit=datetime.now())

        db.session.add(job)
        db.session.commit()

        serverstorage = app.config['SERVER_STORAGE']
        projectpath = join(serverstorage, str(job.project_id))

        try:
            os.mkdir(projectpath)
        except:
            pass

        # Try to make a folder for the job
        jobpath = join(projectpath, str(job.id))
        try:
            os.mkdir(jobpath)
        except:
            pass

        # If we provided a file with the request, we save it there
        if args['jobfile']:
            args['jobfile'].save(join(jobpath, 'jobfile_{0}.zip'.format(job.id)))


        allowed_managers = args['managers']
        for m in allowed_managers:
            logging.info("Allowed managers: {0}".format(int(m)))
            db.session.add(JobManagers(job_id=job.id, manager_id=int(m)))

        db.session.commit()
        TaskApi.create_tasks(job)
        return job, 201
开发者ID:madmouser1,项目名称:flamenco,代码行数:56,代码来源:__init__.py

示例7: stop

 def stop(job_id):
     logging.info('Stopping job {0}'.format(job_id))
     job = Job.query.get(job_id)
     if job.status != 'stopped':
         TaskApi.stop_tasks(job.id)
         job.status = 'stopped'
         db.session.add(job)
         db.session.commit()
     else:
         pass
开发者ID:msimoncz,项目名称:brender,代码行数:10,代码来源:__init__.py

示例8: start

 def start(job_id):
     job = Job.query.get(job_id)
     if job.status != 'running':
         job.status = 'running'
         db.session.add(job)
         db.session.commit()
         logging.info('Dispatching tasks')
     else:
         pass
         # TODO (fsiddi): proper error message if jobs is already running
     TaskApi.dispatch_tasks()
开发者ID:msimoncz,项目名称:brender,代码行数:11,代码来源:__init__.py

示例9: patch

    def patch(self, manager_id):
        from application.modules.tasks import TaskApi

        args = parser_manager.parse_args()
        manager = Manager.query.get_or_404(manager_id)

        # TODO add try except statement to safely handle .one() query
        manager.total_workers = args['total_workers']
        db.session.add(manager)
        db.session.commit()
        TaskApi.dispatch_tasks()
        return jsonify(dict(total_workers=manager.total_workers))
开发者ID:Anuga,项目名称:flamenco,代码行数:12,代码来源:__init__.py

示例10: stop

 def stop(self, job_id):
     print '[info] Stopping job', job_id
     # first we delete the associated jobs (no foreign keys)
     job = Job.query.get(job_id)
     if job:
         if job.status not in ['stopped', 'completed', 'failed']:
             job.status = 'stopped'
             db.session.add(job)
             db.session.commit()
             TaskApi.stop_tasks(job.id)
     else:
         print('[error] Job %d not found' % job_id)
         raise KeyError
开发者ID:EVMosaic,项目名称:flamenco,代码行数:13,代码来源:__init__.py

示例11: stop

 def stop(self, job_id):
     logging.info("Stopped job {0}".format(job_id))
     # first we stop the associated tasks (no foreign keys)
     job = Job.query.get(job_id)
     if job:
         if job.status not in ['stopped', 'completed', 'failed']:
             job.status = 'stopped'
             db.session.add(job)
             db.session.commit()
             TaskApi.stop_tasks(job.id)
     else:
         logging.error("Job {0} not found".format(job_id))
         raise KeyError
开发者ID:dineshbhoopathy,项目名称:flamenco,代码行数:13,代码来源:__init__.py

示例12: patch

    def patch(self, manager_uuid):
        from application.modules.tasks import TaskApi

        args = parser.parse_args()
        try:
            manager = Manager.query.filter_by(uuid=manager_uuid).one()
        except NoResultFound:
            logging.warning("No manager found in Database")
            return '', 404

        # TODO add try except statement to safely handle .one() query
        manager.total_workers = args['total_workers']
        db.session.add(manager)
        db.session.commit()
        TaskApi.dispatch_tasks()
        return jsonify(dict(total_workers=manager.total_workers))
开发者ID:EVMosaic,项目名称:flamenco,代码行数:16,代码来源:__init__.py

示例13: stop

 def stop(job_id):
     logging.info("Stopped job {0}".format(job_id))
     # first we stop the associated tasks (no foreign keys)
     job = Job.query.get(job_id)
     if job:
         if job.status not in ['canceled', 'completed', 'failed']:
             log = "Status changed from {0} to {1}".format(job.status, 'canceled')
             job.status = 'canceled'
             job.date_edit = datetime.now()
             db.session.add(job)
             db.session.commit()
             log_to_database(job_id, 'job', log)
             TaskApi.stop_tasks(job.id)
     else:
         logging.error("Job {0} not found".format(job_id))
         raise KeyError
开发者ID:pedromaltez-forks,项目名称:flamenco,代码行数:16,代码来源:__init__.py

示例14: post

    def post(self):
        args = id_list.parse_args()
        int_list = list_integers_string(args['id'])
        for j in int_list:
            TaskApi.delete_tasks(j)
            job = Job.query.get(j)
            if job:
                db.session.query(JobManagers)\
                    .filter(JobManagers.job_id == job.id).delete()
                db.session.delete(job)
                db.session.commit()
                logging.info("Deleted job {0}".format(j))
            else:
                logging.error("Job {0} not found".format(j))
                return '', 404

        return '', 204
开发者ID:Anuga,项目名称:flamenco,代码行数:17,代码来源:__init__.py

示例15: respawn

    def respawn(self, job_id):
        job = Job.query.get(job_id)
        if job:
            if job.status == 'running':
                self.stop(job_id)

            tasks = db.session.query(Task).filter(Task.job_id == job_id, Task.status.notin_(['finished','failed']))
            best_managers = filter(lambda m : m.total_workers is None, app.config['MANAGERS'])

            if best_managers:
                fun = partial(TaskApi.start_task, best_managers[0])
                map(fun, tasks)
            else:
                TaskApi.dispatch_tasks(job_id)
        else:
            logging.error('Job %d not found' % job_id)
            raise KeyError
开发者ID:msimoncz,项目名称:brender,代码行数:17,代码来源:__init__.py


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