示例#1
0
    def __create_action(self, main_root):
        action_dir = os.path.join(main_root, 'action')
        safe_mkdir(action_dir)

        actions = set()
        for unit, param in self.__task.data['workflow'].items():
            actions.add(param['type'])
        self.__action_mgr.create_actions(actions, action_dir)
示例#2
0
 def __create_input(self, main_root):
     content = self.__manager.load_content()
     input_dir = os.path.join(main_root, 'input')
     try:
         content.get(self.__task.data['id'], 'input',
                     os.path.join(main_root, 'input'))
     except:
         safe_mkdir(input_dir)
示例#3
0
    def __create_action(self, main_root):
        action_dir = os.path.join(main_root, 'action')
        safe_mkdir(action_dir)

        actions = set()
        for unit, param in self.__task.data['workflow'].items():
            actions.add(param['type'])
        self.__action_mgr.create_actions(actions, action_dir)
示例#4
0
 def get(self, task_id, src, dst):
     src_abs = self.__abs_path(task_id, src)
     dst_dir = os.path.dirname(dst)
     safe_mkdir(dst_dir)
     try:
         shutil.copytree(src_abs, dst)
     except OSError as e:
         if e.errno == errno.ENOTDIR:
             shutil.copy2(src_abs, dst)
         else:
             raise
示例#5
0
 def get(self, task_id, src, dst):
     src_abs = self.__abs_path(task_id, src)
     dst_dir = os.path.dirname(dst)
     safe_mkdir(dst_dir)
     try:
         shutil.copytree(src_abs, dst)
     except OSError as e:
         if e.errno == errno.ENOTDIR:
             shutil.copy2(src_abs, dst)
         else:
             raise
示例#6
0
    def __create_scenario(self, main_root):
        scenario_dir = os.path.join(main_root, 'scenario')
        safe_mkdir(scenario_dir)

        action_default = {}
        for unit, param in self.__task.data['workflow'].items():
            action_default[unit] = self.__action_mgr.default_config(param['type'])

        navigators = self.__config_mgr.navigator()
        scenario_format = self.__navigator_mgr.scenario_format(navigators)

        self.__scenario_mgr.create_scenario_file(self.__task.data, action_default, scenario_format, scenario_dir)
示例#7
0
    def task_data(self, task_id):
        safe_mkdir(os.path.join(self.__jsub_dir, str(task_id), 'taskInfo'))
        task_path = os.path.join(self.__jsub_dir, str(task_id), 'taskInfo',
                                 'repo')
        with open(task_path, 'a+') as f:
            fcntl.flock(f, fcntl.LOCK_EX)
            f.seek(0)
            data_str = f.read()

        try:
            return json.loads(data_str)
        except ValueError as e:
            raise RepoReadError('JSON decode error on task %s: %s' %
                                (task_id, e))
示例#8
0
    def save_task(self, data):
        if 'id' not in data:
            safe_mkdir(self.__jsub_dir)
            data['id'] = self.__new_task_id()
        safe_mkdir(os.path.join(self.__jsub_dir, str(data['id']), 'taskInfo'))
        task_path = os.path.join(self.__jsub_dir, str(data['id']), 'taskInfo',
                                 'repo')

        data_str = self.__json_str(data)
        with open(task_path, 'a+') as f:
            fcntl.flock(f, fcntl.LOCK_EX)
            f.seek(0)
            f.truncate()
            f.write(data_str)
示例#9
0
    def __create_context(self, main_root):
        context_dir = os.path.join(main_root, 'context')
        safe_mkdir(context_dir)

        action_default = {}
        for unit, param in self.__task.data['workflow'].items():
            action_default[unit] = self.__action_mgr.default_config(
                param['type'])

        navigators = self.__config_mgr.navigator()
        context_format = self.__navigator_mgr.context_format(navigators)

        self.__context_mgr.create_context_file(self.__task.data,
                                               action_default, context_format,
                                               context_dir)
示例#10
0
    def handle(self):
        work_root = self.__backend_mgr.get_work_root(self.__task.data['backend'], self.__task.data['id'])

        main_root = os.path.join(work_root, 'main')

        safe_rmdir(main_root)
        safe_mkdir(main_root)

        self.__create_input(main_root)
        self.__create_scenario(main_root)
        self.__create_action(main_root)
        self.__create_navigator(main_root)
        self.__create_bootstrap(main_root)

        launcher_param = self.__create_launcher(work_root)

        self.__submit(launcher_param)
示例#11
0
    def handle(self):
        run_root = self.__backend_mgr.get_run_root(self.__task.data['backend'],
                                                   self.__task.data['id'])

        main_root = os.path.join(run_root, 'main')

        safe_rmdir(main_root)
        safe_mkdir(main_root)

        self.__create_input(main_root)
        self.__create_context(main_root)
        self.__create_action(main_root)
        self.__create_navigator(main_root)
        self.__create_bootstrap(main_root)

        launcher_param = self.__create_launcher(run_root)

        self.__submit(launcher_param)
示例#12
0
 def put_str(self, task_id, string, dst):
     dst_abs = self.__abs_path(task_id, dst)
     dst_dir = os.path.dirname(dst_abs)
     safe_mkdir(dst_dir)
     with open(dst_abs, 'w') as f:
         f.write(string)
示例#13
0
 def put(self, task_id, src, dst):
     dst_abs = self.__abs_path(task_id, dst)
     dst_dir = os.path.dirname(dst_abs)
     safe_mkdir(dst_dir)
     shutil.copy2(src, dst_abs)
示例#14
0
    def __create_navigator(self, main_root):
        navigator_dir = os.path.join(main_root, 'navigator')
        safe_mkdir(navigator_dir)

        navigators = self.__config_mgr.navigator()
        self.__navigator_mgr.create_navigators(navigators, navigator_dir)
示例#15
0
    def __create_bootstrap(self, main_root):
        bootstrap_dir = os.path.join(main_root, 'bootstrap')
        safe_mkdir(bootstrap_dir)

        bootstrap = self.__config_mgr.bootstrap()
        self.__bootstrap_mgr.create_bootstrap(bootstrap, bootstrap_dir)
示例#16
0
    def __create_navigator(self, main_root):
        navigator_dir = os.path.join(main_root, 'navigator')
        safe_mkdir(navigator_dir)

        navigators = self.__config_mgr.navigator()
        self.__navigator_mgr.create_navigators(navigators, navigator_dir)
示例#17
0
 def put(self, task_id, src, dst):
     dst_abs = self.__abs_path(task_id, dst)
     dst_dir = os.path.dirname(dst_abs)
     safe_mkdir(dst_dir)
     shutil.copy2(src, dst_abs)
示例#18
0
 def put_str(self, task_id, string, dst):
     dst_abs = self.__abs_path(task_id, dst)
     dst_dir = os.path.dirname(dst_abs)
     safe_mkdir(dst_dir)
     with open(dst_abs, 'w') as f:
         f.write(string)
示例#19
0
    def __create_bootstrap(self, main_root):
        bootstrap_dir = os.path.join(main_root, 'bootstrap')
        safe_mkdir(bootstrap_dir)

        bootstrap = self.__config_mgr.bootstrap()
        self.__bootstrap_mgr.create_bootstrap(bootstrap, bootstrap_dir)
示例#20
0
 def __create_repo_dir(self):
     safe_mkdir(self.__repo_dir)
     safe_mkdir(self.__task_dir)