예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    def post(self):
        args = parser.parse_args()
        for worker_id in list_integers_string(args['id']):
            worker = Worker.query.get(worker_id)
            worker.status = args['status']
            http_rest_request(worker.manager.host, '/workers/' + worker_id, 'patch', dict(status=worker.status))

        return '', 204
예제 #4
0
파일: __init__.py 프로젝트: Anuga/flamenco
    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
예제 #5
0
    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
예제 #6
0
    def put(self):
        """Run a command against a list of jobs.
        """
        args = list_command_parser.parse_args()
        # Parse the string list of job IDs into a real integers list
        args['id'] = list_integers_string(args['id'])
        fun = None
        # Set a status variable, for returning a status to display in the UI
        status = None
        if args['command'] == "start":
            fun = JobApi.start
            status = "waiting"
        elif args['command'] == "stop":
            fun = JobApi.stop
            status = "canceled"
        elif args['command'] == "reset":
            fun = JobApi.reset
            status = "reset"
        elif args['command'] == "respawn":
            fun = self.respawn
            status = "respawned"
        elif args['command'] == "archive":
            fun = JobApi.archive
            status = "archived"
        else:
            logging.error("command not found")
            return args, 400

        try:
            # Run the right function (according to the command specified) against
            # a list of job IDs
            map(fun, args['id'])
            # Return a dictionary with the IDs list, the command that was run
            # agains them and the status they have after such command has been
            # executed
            return dict(
                id=args['id'], command=args['command'], status=status), 200
        except KeyError:
            return args, 404

        args['status'] = 'waiting'
        return args, 200
예제 #7
0
    def put(self):
        """Run a command against a list of jobs.
        """
        args = list_command_parser.parse_args()
        # Parse the string list of job IDs into a real integers list
        args['id'] = list_integers_string(args['id'])
        fun = None
        # Set a status variable, for returning a status to display in the UI
        status = None
        if args['command'] == "start":
            fun = JobApi.start
            status = "waiting"
        elif args['command'] == "stop":
            fun = JobApi.stop
            status = "canceled"
        elif args['command'] == "reset":
            fun = JobApi.reset
            status = "reset"
        elif args['command'] == "respawn":
            fun = self.respawn
            status = "respawned"
        elif args['command'] == "archive":
            fun = JobApi.archive
            status = "archived"
        else:
            logging.error("command not found")
            return args, 400

        try:
            # Run the right function (according to the command specified) against
            # a list of job IDs
            map(fun, args['id'])
            # Return a dictionary with the IDs list, the command that was run
            # agains them and the status they have after such command has been
            # executed
            return dict(
                id=args['id'], command=args['command'], status=status), 200
        except KeyError:
            return args, 404

        args['status'] = 'waiting'
        return args, 200
예제 #8
0
    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))
                if exists(path):
                    rmtree(path)

                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
예제 #9
0
    def put(self):
        args = status_parser.parse_args()
        fun = None
        if args['status'] == "start":
            fun = self.start
        elif args['status'] == "stop":
            fun = self.stop
        elif args['status'] == "reset":
            fun = self.reset
        elif args['status'] == "respawn":
            fun = self.respawn
        else:
            print "command not found"
            return args, 400

        try:
            map(fun, list_integers_string(args['id']))
        except KeyError:
            return args, 404

        args['status'] = 'running'
        return args, 200
예제 #10
0
    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:
                #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()
                logging.info("Deleted job {0}".format(j))
            else:
                logging.error("Job {0} not found".format(j))
                return '', 404

        return '', 204
예제 #11
0
    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:
                #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()
                logging.info("Deleted job {0}".format(j))
            else:
                logging.error("Job {0} not found".format(j))
                return '', 404

        return '', 204