How to use the lastversion.ProjectHolder.ProjectHolder function in lastversion

To help you get started, we’ve selected a few lastversion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dvershinin / lastversion / tests / test_lastversion.py View on Github external
def test_version_parse_dev2():
    v = '7.18.1-rc.2'

    h = ProjectHolder()

    v = h.sanitize_version(v, pre_ok=True)

    assert v.is_prerelease is True
github dvershinin / lastversion / tests / test_lastversion.py View on Github external
def test_version_parse_dev():
    v = '1.19rc1'

    h = ProjectHolder()

    v = h.sanitize_version(v, pre_ok=True)

    assert v.is_prerelease is True
github dvershinin / lastversion / lastversion / LocalVersionSession.py View on Github external
# special case, private use now
# nginx version is taken as version of stable (written by rpm check script)
# to /usr/local/share/builder/nginx-stable.ver
import logging as log  # for verbose output
from .ProjectHolder import ProjectHolder


class LocalVersionSession(ProjectHolder):
    DEFAULT_HOSTNAME = None

    def __init__(self, repo, hostname):
        super(LocalVersionSession, self).__init__()
        self.repo = repo
        self.hostname = hostname

    def get_latest(self, pre_ok=False, major=None):
        if pre_ok:
            log.info('--pre is not supported for local version sources')
        if not major:
            major = 'stable'
        ver_file = '/usr/local/share/builder/{}-{}.ver'.format(self.repo, major)
        with open(ver_file, 'r') as file:
            version = file.read().replace('\n', '')
            return {
github dvershinin / lastversion / lastversion / MercurialRepoSession.py View on Github external
import feedparser
import datetime

from .ProjectHolder import ProjectHolder


class MercurialRepoSession(ProjectHolder):
    REPO_URL_PROJECT_COMPONENTS = 1
    KNOWN_REPO_URLS = {
        'nginx.org': {
            'repo': 'nginx',
            'hostname': 'hg.nginx.org',
            'branches': {
                'stable': '\\.\\d?[02468]\\.',
                'mainline': '\\.\\d?[13579]\\.'
            }
        }
    }

    KNOWN_REPOS_BY_NAME = {
        'nginx': KNOWN_REPO_URLS['nginx.org']
    }
github dvershinin / lastversion / lastversion / ProjectHolder.py View on Github external
def __init__(self):
        super(ProjectHolder, self).__init__()
        self.headers.update({'User-Agent': 'lastversion/{}'.format(__version__)})
        log.info('Using {} project holder'.format(type(self).__name__))
        self.branches = None
github dvershinin / lastversion / lastversion / GitHubRepoSession.py View on Github external
import logging as log  # for verbose output
import os
import re
import time

import feedparser
from dateutil import parser

from .ProjectHolder import ProjectHolder
from .utils import asset_does_not_belong_to_machine, ApiCredentialsError, BadProjectError


class GitHubRepoSession(ProjectHolder):
    DEFAULT_HOSTNAME = 'github.com'
    DEFAULT_HOLDER = True

    def __init__(self, repo, hostname):
        super(GitHubRepoSession, self).__init__()
        self.api_token = os.getenv("GITHUB_API_TOKEN")
        self.hostname = hostname
        if not self.hostname:
            self.hostname = self.DEFAULT_HOSTNAME
        # Explicitly specify the API version that we want:
        self.headers.update({
            'Accept': 'application/vnd.github.v3+json'
        })
        if self.api_token:
            log.info('Using API token.')
            self.headers.update({'Authorization': "token {}".format(self.api_token)})
github dvershinin / lastversion / lastversion / lastversion.py View on Github external
def parse_version(tag):
    h = ProjectHolder()
    return h.sanitize_version(tag, pre_ok=True)
github dvershinin / lastversion / lastversion / BitBucketRepoSession.py View on Github external
from dateutil import parser

from .ProjectHolder import ProjectHolder


class BitBucketRepoSession(ProjectHolder):
    DEFAULT_HOSTNAME = 'bitbucket.org'
    KNOWN_REPO_URLS = {
        'mmonit.com': {'repo': 'tildeslash/monit'}
    }

    KNOWN_REPOS_BY_NAME = {
        'monit': KNOWN_REPO_URLS['mmonit.com']
    }

    def __init__(self, repo, hostname):
        super(BitBucketRepoSession, self).__init__()
        self.hostname = hostname
        if not self.hostname:
            self.hostname = self.DEFAULT_HOSTNAME
        self.repo = repo
github dvershinin / lastversion / lastversion / GitLabRepoSession.py View on Github external
import logging as log  # for verbose output
import os

from dateutil import parser

from .ProjectHolder import ProjectHolder


class GitLabRepoSession(ProjectHolder):
    DEFAULT_HOSTNAME = 'gitlab.com'

    def __init__(self, repo, hostname):
        super(GitLabRepoSession, self).__init__()
        self.pa_token = os.getenv("GITLAB_PA_TOKEN")
        self.hostname = hostname
        if not self.hostname:
            self.hostname = self.DEFAULT_HOSTNAME
        if self.pa_token:
            log.info('Using Personal Access token.')
            self.headers.update({'Private-Token': "{}".format(self.pa_token)})
        self.api_base = 'https://{}/api/v4'.format(self.hostname)
        self.repo = repo
        self.repo_id = self.repo.replace('/', '%2F')

    def repo_query(self, uri):