Пример #1
0
 def job_abort(self):
     if len(self.args) >= 2:
         job_or_source_id_or_name = unicode_safe(self.args[1])
     else:
         print("Please provide a job id or source name/id")
         sys.exit(1)
     print(utils.abort_job(job_or_source_id_or_name))
Пример #2
0
 def create_harvest_job(self):
     if len(self.args) >= 2:
         source_id_or_name = unicode_safe(self.args[1])
     else:
         print("Please provide a source id")
         sys.exit(1)
     print(utils.create_job(source_id_or_name))
Пример #3
0
 def clear_harvest_source(self):
     if len(self.args) >= 2:
         source_id_or_name = unicode_safe(self.args[1])
     else:
         print("Please provide a source id")
         sys.exit(1)
     utils.clear_harvest_source(source_id_or_name)
Пример #4
0
    def clear_harvest_source_history(self):
        keep_current = bool(self.options.keep_current)
        source_id = None
        if len(self.args) >= 2:
            source_id = unicode_safe(self.args[1])

        print(utils.clear_harvest_source_history(source_id, keep_current))
Пример #5
0
    def abort_failed_jobs(self):
        job_life_span = False
        if len(self.args) >= 2:
            job_life_span = unicode_safe(self.args[1])

        utils.abort_failed_jobs(job_life_span,
                                include=self.options.include_sources,
                                exclude=self.options.exclude_sources)
Пример #6
0
    def show_harvest_source(self):

        if len(self.args) >= 2:
            source_id_or_name = unicode_safe(self.args[1])
        else:
            print("Please provide a source name")
            sys.exit(1)
        print(utils.show_harvest_source(source_id_or_name))
Пример #7
0
    def run_test_harvest(self):
        # Determine the source
        force_import = None
        if len(self.args) >= 2:
            if len(self.args) >= 3 and self.args[2].startswith(
                    'force-import='):
                force_import = self.args[2].split('=')[-1]
            source_id_or_name = unicode_safe(self.args[1])
        else:
            print("Please provide a source id")
            sys.exit(1)

        utils.run_test_harvester(source_id_or_name, force_import)
Пример #8
0
    def create_harvest_source(self):

        if len(self.args) >= 2:
            name = unicode_safe(self.args[1])
        else:
            print("Please provide a source name")
            sys.exit(1)
        if len(self.args) >= 3:
            url = unicode_safe(self.args[2])
        else:
            print("Please provide a source URL")
            sys.exit(1)
        if len(self.args) >= 4:
            type = unicode_safe(self.args[3])
        else:
            print("Please provide a source type")
            sys.exit(1)

        if len(self.args) >= 5:
            title = unicode_safe(self.args[4])
        else:
            title = None
        if len(self.args) >= 6:
            active = not (self.args[5].lower() == "false"
                          or self.args[5] == "0")
        else:
            active = True
        if len(self.args) >= 7:
            owner_org = unicode_safe(self.args[6])
        else:
            owner_org = None
        if len(self.args) >= 8:
            frequency = unicode_safe(self.args[7])
            if not frequency:
                frequency = "MANUAL"
        else:
            frequency = "MANUAL"
        if len(self.args) >= 9:
            source_config = unicode_safe(self.args[8])
        else:
            source_config = None
        try:
            result = utils.create_harvest_source(name, url, type, title,
                                                 active, owner_org, frequency,
                                                 source_config)
        except ValidationError as e:
            print("An error occurred:")
            print(str(e.error_dict))
            raise e

        print(result)
Пример #9
0
    def import_stage(self):

        if len(self.args) >= 2:
            source_id_or_name = unicode_safe(self.args[1])
            context = {
                "model": model,
                "session": model.Session,
                "user": self.admin_user["name"],
            }
            source = get_action("harvest_source_show")(context, {
                "id": source_id_or_name
            })
            source_id = source["id"]
        else:
            source_id = None
        utils.import_stage(
            source_id,
            self.options.no_join_datasets,
            self.options.harvest_object_id,
            self.options.guid,
            self.options.package_id,
            self.options.segments,
        )