Пример #1
0
def main():
    config_file = None

    if len(sys.argv) > 1:
        config_file = sys.argv[1]

    config_reader = DistGitConfigReader(config_file)
    try:
        opts = config_reader.read()
    except Exception:
        print("Failed to read config file, used file location: `{}`".format(
            config_file))
        # sys.exit(1)
        sys.exit(1)

    logging.basicConfig(
        filename=os.path.join(opts.log_dir, "main.log"),
        level=logging.DEBUG,
        format=
        '[%(asctime)s][%(levelname)s][%(name)s][%(module)s:%(lineno)d] %(message)s',
        datefmt='%H:%M:%S')

    logging.getLogger('requests.packages.urllib3').setLevel(logging.WARN)
    logging.getLogger('urllib3').setLevel(logging.WARN)

    log.info("Logging configuration done")
    log.info("Using configuration: \n" "{}".format(opts))
    importer = DistGitImporter(opts)
    importer.run()
Пример #2
0
    def setup_method(self, method):
        self.tmp_dir_name = self.make_temp_dir()
        self.lookaside_location = os.path.join(self.tmp_dir_name, "lookaside")
        self.per_task_location = os.path.join(self.tmp_dir_name,
                                              "per-task-logs")
        os.mkdir(self.per_task_location)
        self.opts = Bunch({
            "frontend_base_url": "http://front",
            "frontend_auth": "secure_password",
            "lookaside_location": self.lookaside_location,
            "cgit_pkg_list_location": self.tmp_dir_name,
            "sleep_time": 10,
            "pool_busy_sleep_time": 0.5,
            "log_dir": self.tmp_dir_name,
            "per_task_log_dir": self.per_task_location,
            "multiple_threads": True,
        })

        self.dgi = DistGitImporter(self.opts)

        self.USER_NAME = "foo"
        self.PROJECT_NAME = "bar"
        self.PACKAGE_NAME = "bar_app"
        self.PACKAGE_VERSION = "2:0.01-1.fc20"
        self.BRANCH = "f22"
        self.FILE_HASH = "1234abc"
        self.task_data_1 = {
            "task_id": 123,
            "user": self.USER_NAME,
            "project": self.PROJECT_NAME,
            "branch": self.BRANCH,
            "source_type": SourceType.SRPM_LINK,
            "source_json":
            json.dumps({"url": "http://example.com/pkg.src.rpm"})
        }
        self.task_data_2 = {
            "task_id": 124,
            "user": self.USER_NAME,
            "project": self.PROJECT_NAME,
            "branch": self.BRANCH,
            "source_type": SourceType.SRPM_UPLOAD,
            "source_json": json.dumps({
                "tmp": "tmp_2",
                "pkg": "pkg_2.src.rpm"
            })
        }

        self.task_1 = ImportTask.from_dict(self.task_data_1, self.opts)
        self.task_2 = ImportTask.from_dict(self.task_data_2, self.opts)

        self.fetched_srpm_path = "/tmp/none/"
Пример #3
0
def main():
    config_file = None

    if len(sys.argv) > 1:
        config_file = sys.argv[1]

    config_reader = DistGitConfigReader(config_file)
    try:
        opts = config_reader.read()
    except Exception:
        print("Failed to read config file, used file location: `{}`".format(
            config_file))
        sys.exit(1)

    logging.basicConfig(
        filename=os.path.join(opts.log_dir, "main.log"),
        level=logging.DEBUG,
        format=
        '[%(asctime)s][%(levelname)s][%(name)s][%(module)s:%(lineno)d] %(message)s',
        datefmt='%H:%M:%S')

    logging.getLogger('requests.packages.urllib3').setLevel(logging.WARN)
    logging.getLogger('urllib3').setLevel(logging.WARN)

    log.info("Make sure per-task-logs dir exists at: {}".format(
        opts.per_task_log_dir))
    try:
        os.makedirs(opts.per_task_log_dir)
    except OSError:
        if not os.path.isdir(opts.per_task_log_dir):
            log.error(
                "Could not create per-task-logs directory at path {}".format(
                    opts.per_task_log_dir))
            sys.exit(1)

    log.info("Logging configuration done")
    log.info("Using configuration: \n" "{}".format(opts))
    importer = DistGitImporter(opts)
    importer.run()