コード例 #1
0
ファイル: common.py プロジェクト: KDE/propagator
def is_valid_repo(repo):
    path = os.path.join(config_general.get("repobase"), repo)
    try:
        repo = git.Repo(path)
    except (git.exc.NoSuchPathError, git.exc.InvalidGitRepositoryError):
        return False
    return True
コード例 #2
0
ファイル: slavecore.py プロジェクト: KDE/propagator
    def __init__(self, slave_name):
        # set up the logger as early as possible
        self.log = logbook.Logger("RemoteSlave-{}".format(str(os.getpid())))
        self.log.info("This is KDE Propagator {} - Remote Slave".format(version))
        self.log.info("    Starting...")

        # create the operations log handler and load in the slave, and other things
        self.opslog = self.init_slave_logger(slave_name)
        self.remote = self.init_slave_module(slave_name).Remote(self.opslog)
        self.repobase = config_general.get("repobase")
        self.max_retries = int(config_general.get("max_retries", 5))
        self.retry_step = int(config_general.get("retry_interval_step", 300)) * 1000
        self.slave_name = slave_name

        # set up the amqp channel, and bind it to the consumer callback
        self.channel = amqp.create_channel_consumer(slave_name)
        self.channel.basic_consume(self.process_single_message, amqp.queue_name_for_slave(slave_name))
コード例 #3
0
ファイル: github.py プロジェクト: KDE/propagator
    def plugin_init(self, *args, **kwargs):
        cfgpath = os.path.expanduser("~/.propagator/remotes_github.json")
        with open(cfgpath) as f:
            cfgdict = json.load(f)

        self.access_token = cfgdict["access_token"]
        self.organization = cfgdict["organization"]
        self.except_checks = ( re.compile(i) for i in cfgdict["excepts"] )
        self.repo_base = config_general.get("repobase")

        self.session = requests.Session()
        self.session.headers.update({"Accept": "application/vnd.github.v3+json"})
        self.session.headers.update({"Authorization": " ".join(("token", self.access_token))})
コード例 #4
0
ファイル: slavecore.py プロジェクト: KDE/propagator
    def init_slave_logger(self, slave_name):
        # get the logs directory and ensure that it exists
        default_logdir = os.path.expanduser("~/.propagator/logs")
        logdir = config_general.get("logs_dir", default_logdir)
        if not os.path.isdir(logdir):
            os.makedirs(logdir)

        # fire up a logger with its own handler to redirect to the file
        logpath = os.path.join(logdir, "remote.{}.log".format(slave_name))
        logger = logbook.Logger("slave-{}".format(slave_name))
        logger.handlers.append(logbook.FileHandler(logpath))

        # done, return logger
        return logger