diff --git a/dvc/check_updates.py b/dvc/check_updates.py index e113d8061..5a0e4b826 100644 --- a/dvc/check_updates.py +++ b/dvc/check_updates.py @@ -1,19 +1,36 @@ -from github import Github +import os +import time +import json +import requests from dvc import VERSION_BASE from dvc.logger import Logger -GITHUB_USER = 'dataversioncontrol' -GITHUB_REPO = 'dvc' +DVCAPI_URL = 'https://4ki8820rsf.execute-api.us-east-2.amazonaws.com/prod/latest-version' +CHECK_UPDATES_FILE = '.check_updates' +TIMEOUT = 7 * 24 * 60 * 60 #every week -def check_updates(): +def check_updates(dvc_dir): current = VERSION_BASE + if os.getenv('CI'): + return + + fname = os.path.join(dvc_dir, CHECK_UPDATES_FILE) + if os.path.isfile(fname): + ctime = os.path.getctime(fname) + if time.time() - ctime < TIMEOUT: + msg = '{} is not old enough to check for updates' + Logger.debug(msg.format(CHECK_UPDATES_FILE)) + return + + os.unlink(fname) + try: - gh = Github() - user = gh.get_user(GITHUB_USER) - repo = user.get_repo(GITHUB_REPO) - latest = repo.get_latest_release().title + r = requests.get(DVCAPI_URL) + j = json.loads(r.content) + latest = j['version'] + open(fname, 'w+').close() except Exception as exc: Logger.debug('Failed to obtain latest version: {}'.format(str(exc))) return diff --git a/dvc/project.py b/dvc/project.py index 6c151f527..72d64cada 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -53,7 +53,7 @@ class Project(object): self.logger = Logger(self.config._config[Config.SECTION_CORE].get(Config.SECTION_CORE_LOGLEVEL, None)) self.cloud = DataCloud(cache=self.cache, config=self.config._config) - check_updates() + check_updates(self.dvc_dir) @staticmethod def init(root_dir=os.curdir, no_scm=False): diff --git a/requirements.txt b/requirements.txt index eaed5ed0f..2283e5f3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,4 +20,4 @@ paramiko>=2.4.1 binaryornot==0.4.4 jsonpath-rw==1.4.0 reflink==0.2.0 -PyGithub>=1.39 +requests>=2.18.4 diff --git a/setup.py b/setup.py index 767c7c14f..5212b0186 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ install_requires = [ "binaryornot==0.4.4", "jsonpath-rw==1.4.0", "reflink==0.2.0", - "PyGithub>=1.39", + "requests>=2.18.4", ] setup(