mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
simple gitcafe.com support
This commit is contained in:
parent
7390202d87
commit
6cf385a73a
2 changed files with 35 additions and 0 deletions
12
README.rst
12
README.rst
|
@ -120,6 +120,18 @@ branch
|
||||||
|
|
||||||
An environment variable ``NVCHECKER_GITHUB_TOKEN`` can be set to a GitHub OAuth token in order to request more frequently than anonymously.
|
An environment variable ``NVCHECKER_GITHUB_TOKEN`` can be set to a GitHub OAuth token in order to request more frequently than anonymously.
|
||||||
|
|
||||||
|
Check GitCafe
|
||||||
|
------------
|
||||||
|
Check `GitCafe <https://gitcafe.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``.
|
||||||
|
|
||||||
|
gitcafe
|
||||||
|
The gitcafe repository, with author, e.g. ``Deepin/deepin-music``.
|
||||||
|
|
||||||
|
branch
|
||||||
|
Which branch to track? Default: ``master``.
|
||||||
|
|
||||||
|
Anonymously only. Authorization is not supported yet.
|
||||||
|
|
||||||
Check PyPI
|
Check PyPI
|
||||||
----------
|
----------
|
||||||
Check `PyPI <https://pypi.python.org/>`_ for updates.
|
Check `PyPI <https://pypi.python.org/>`_ for updates.
|
||||||
|
|
23
nvchecker/source/gitcafe.py
Normal file
23
nvchecker/source/gitcafe.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
|
||||||
|
|
||||||
|
GITCAFE_URL = 'https://gitcafe.com/%s/commits/%s'
|
||||||
|
gitcafe_pattern = re.compile(r'datetime="([^"]*)"')
|
||||||
|
|
||||||
|
def get_version(name, conf, callback):
|
||||||
|
repo = conf.get('gitcafe')
|
||||||
|
br = conf.get('branch', 'master')
|
||||||
|
url = GITCAFE_URL % (repo, br)
|
||||||
|
headers = {'Accept': "text/html"}
|
||||||
|
request = HTTPRequest(url, headers=headers, user_agent='lilydjwg/nvchecker')
|
||||||
|
AsyncHTTPClient().fetch(request, callback=partial(_gitcafe, name, callback))
|
||||||
|
|
||||||
|
def _gitcafe(name, callback, res):
|
||||||
|
body = res.body.decode('utf-8')
|
||||||
|
data = gitcafe_pattern.search(body).group(1)
|
||||||
|
version = data.split('T', 1)[0].replace('-', '')
|
||||||
|
callback(name, version)
|
Loading…
Add table
Reference in a new issue