コード例 #1
0
def get_dirs_with_naming(search_key=None, process_list=None):
    import json
    from pyasm.biz import Snapshot
    from pyasm.biz import Project
    from pyasm.search import SearchType

    dir_naming = Project.get_dir_naming()

    dirs_dict = {
        'versions': [],
        'versionless': [],
    }

    if process_list:
        processes = process_list
    else:
        from pyasm.biz import Pipeline
        sobjects = server.server._get_sobjects(search_key)
        sobject = sobjects[0]
        pipelines = Pipeline.get_by_search_type(sobject.get_base_search_type())
        processes = pipelines[0].get_process_names()

    search_type, search_code = server.split_search_key(search_key)
    search_type = search_type.split('?')[0]

    for process in processes:
        # querying sobjects every time because we need to refresh naming
        sobject = server.query(search_type,
                               filters=[('code', search_code)],
                               return_sobjects=True,
                               single=True)
        dir_naming.set_sobject(sobject)
        file_object = SearchType.create('sthpw/file')
        dir_naming.set_file_object(file_object)
        snapshot = Snapshot.create(sobject,
                                   snapshot_type='file',
                                   context=process,
                                   commit=False)
        dir_naming.set_snapshot(snapshot)
        dirs_dict['versions'].append(dir_naming.get_dir('relative'))

        snapshot_versionless = Snapshot.create(sobject,
                                               snapshot_type='file',
                                               context=process,
                                               process=process,
                                               commit=False,
                                               version=-1)
        dir_naming.set_snapshot(snapshot_versionless)
        dirs_dict['versionless'].append(dir_naming.get_dir('relative'))

    return json.dumps(dirs_dict, separators=(',', ':'))
コード例 #2
0
ファイル: task_manager_wdg.py プロジェクト: mincau/TACTIC
    def __init__(self, name='task_status', task_pipeline=None):
        '''by default, it should grab all sthpw/task pipelines'''
        if not task_pipeline:
            project_code = Project.get_project_code()
            task_pipeline = Pipeline.get_by_search_type('sthpw/task', project_code)
        if isinstance(task_pipeline, list):
            self.task_pipelines = task_pipeline
        else:
            self.task_pipelines = [Pipeline.get_by_code(task_pipeline)]

        self.process_names = []
        self.checkbox_control = None
        super(TaskStatusFilterWdg,self).__init__(name)
        self.label = "Task Status Filter: "
        self.set_persistence()
コード例 #3
0
ファイル: task_manager_wdg.py プロジェクト: zieglerm/TACTIC
    def __init__(self, name='task_status', task_pipeline=None):
        '''by default, it should grab all sthpw/task pipelines'''
        if not task_pipeline:
            project_code = Project.get_project_code()
            task_pipeline = Pipeline.get_by_search_type(
                'sthpw/task', project_code)
        if isinstance(task_pipeline, list):
            self.task_pipelines = task_pipeline
        else:
            self.task_pipelines = [Pipeline.get_by_code(task_pipeline)]

        self.process_names = []
        self.checkbox_control = None
        super(TaskStatusFilterWdg, self).__init__(name)
        self.label = "Task Status Filter: "
        self.set_persistence()
コード例 #4
0
ファイル: filter_wdg.py プロジェクト: zieglerm/TACTIC
    def get_context_data(self, search_type='', process=''):
        '''get the labels and values of contexts that can be checked in with this widget'''

        # TODO: this also shows input contexts ... it should only show output
        # contexts
        if not search_type:
            search_type = self.search_type

    

        pipelines = Pipeline.get_by_search_type(search_type, Project.get_project_code() )

        
        if not pipelines:
            return [], []
        # account for sub-pipeline
        if '/' in process:
            process = process.split('/', 1)[1]
        contexts = []
        for pipeline in pipelines:
            pipeline_contexts = []
            pipeline_processes = pipeline.get_process_names()
            if process:
                if process not in pipeline_processes:
                    continue
                pipeline_contexts = pipeline.get_output_contexts(process)
            else:
                pipeline_contexts = pipeline.get_all_contexts()
            for context in pipeline_contexts:
                # for now, cut out the sub_context, until the pipeline
                # completely defines the sub contexts as well
                if context.find("/") != -1:
                    parts = context.split("/")
                    context = parts[0]

                if context not in contexts:
                    contexts.append(context)

        labels = contexts
        values = contexts


        return labels, values
コード例 #5
0
ファイル: filter_wdg.py プロジェクト: 0-T-0/TACTIC
    def get_context_data(my, search_type='', process=''):
        '''get the labels and values of contexts that can be checked in with this widget'''

        # TODO: this also shows input contexts ... it should only show output
        # contexts
        if not search_type:
            search_type = my.search_type

    

        pipelines = Pipeline.get_by_search_type(search_type, Project.get_project_code() )

        
        if not pipelines:
            return [], []
        # account for sub-pipeline
        if '/' in process:
            process = process.split('/', 1)[1]
        contexts = []
        for pipeline in pipelines:
            pipeline_contexts = []
            pipeline_processes = pipeline.get_process_names()
            if process:
                if process not in pipeline_processes:
                    continue
                pipeline_contexts = pipeline.get_output_contexts(process)
            else:
                pipeline_contexts = pipeline.get_all_contexts()
            for context in pipeline_contexts:
                # for now, cut out the sub_context, until the pipeline
                # completely defines the sub contexts as well
                if context.find("/") != -1:
                    parts = context.split("/")
                    context = parts[0]

                if context not in contexts:
                    contexts.append(context)

        labels = contexts
        values = contexts


        return labels, values
コード例 #6
0
def get_dirs_with_naming(search_key=None):
    from pyasm.biz import Snapshot
    from pyasm.biz import Project
    from pyasm.search import SearchType
    sobjects = server.server._get_sobjects(search_key)
    sobject = sobjects[0]
    file_object = SearchType.create('sthpw/file')
    from pyasm.biz import Pipeline
    pipelines = Pipeline.get_by_search_type(sobject.get_base_search_type())
    processes = pipelines[0].get_process_names()
    dir_naming = Project.get_dir_naming()
    dir_naming.set_sobject(sobject)
    dir_naming.set_file_object(file_object)
    dirs_list = []
    for process in processes:
        snapshot = Snapshot.create(sobject,
                                   snapshot_type='file',
                                   context=process,
                                   commit=False,
                                   version=-1)
        dir_naming.set_snapshot(snapshot)
        dirs_list.append(dir_naming.get_dir('relative'))
    return dirs_list