Exemplo n.º 1
0
    def __init__(self, config: SlackConfig):
        self.config = config
        if not self.config.configured:
            return
        self.logger = get_logger(__name__)

        self.http = Http('https://slack.com/api')
        self.http.add_header('Authorization', f'Bearer {self.config.token}')
Exemplo n.º 2
0
    def init(self):
        self = obj.super(Notification, self).init()
        if self is None: return None

        self.NSUserNotification = objc.lookUpClass('NSUserNotification')
        self.NSUSerNOtificationCenter = objc.lookUpClass(
            'NSUserNotificationCenter')
        self.logger = get_logger(__name__)

        return self
Exemplo n.º 3
0
    def __init__(self,
                 project_id: str,
                 token: str,
                 base='https://gitlab.com/api/v4'):
        self.project_id = project_id
        self.token = token
        self.http = Http(base)

        progressbar.streams.wrap_stdout()
        progressbar.streams.wrap_stderr()
        self.logger = get_logger(__name__)

        self.http.add_header('Private-Token', token)
Exemplo n.º 4
0
def main(config: GitLabConfig):
    logger = get_logger(__name__)

    gl = GitLab(config.project_id, config.token)

    user = gl.get_user()
    logger.info(f'Welcome {user["name"]} ({user["username"]})')

    latest_tag = gl.latest_tag()
    ci_status = gl.pipeline_status_for_tag(latest_tag.name)

    if ci_status != None:
        logger.info(f'tag: {latest_tag.name}::{ci_status.status} ({ci_status.completed_jobs} / {ci_status.job_count} -- {ci_status.pending_jobs} pending)')

    GitLabWatcher(gl, user['username']).run()
Exemplo n.º 5
0
def write_temp_file(file_extension: str, initial_content: str = None, default_editor = 'vim') -> str:
    logger = get_logger(__name__)
    filename = f'/tmp/{str(uuid.uuid4())}.{file_extension}'

    logger.debug(f'creating file {filename}')

    try:
        with open(filename, 'w') as tf:
            if initial_content != None:
                tf.writelines(initial_content)
                tf.flush()

            logger.debug(f'editing {filename} with {default_editor}')
            subprocess.call([default_editor, filename])

        with open(filename, 'r') as tf:
            return tf.read()

    finally:
        if os.path.exists(filename):
            logger.debug(f'removing file {filename}')
            os.remove(filename)
Exemplo n.º 6
0
def main(config: WatcherConfig, tag: str = None):
    logger = get_logger(__name__)
    gl = GitLab(config.gitlab_config.project_id, config.gitlab_config.token)
    sp = SlackPoster(config.slack_config)

    if tag == None:
        tag = gl.latest_tag()
    else:
        tag = gl.get_tag(tag)

    changes = list_mr_ids(tag.message)

    change_log, markdown = format_changelog(tag.name, changes)
    markdown = write_temp_file('md', markdown, 'nvim')

    mrs_to_change = [c.mr for c in changes]
    logger.info(f'check labels for labels {mrs_to_change}')
    gl.change_mr_labels(mrs_to_change)

    gl.post_release(tag.name, markdown)
    if sp.config.configured:
        sp.post_change_log(tag.name, change_log)
Exemplo n.º 7
0
    def __init__(self, gitlab: GitLab, username: str):
        self.gitlab = gitlab
        self.logger = get_logger(__name__)
        self.app = None

        self.ci_status = ''
Exemplo n.º 8
0
 def __init__(self, base: str):
     self.logger = get_logger(__name__)
     self.base = base.strip('/')
     self.headers = {}