mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-14 22:49:23 +01:00
Misc: update version fetching to the new branches
master is now used for main development, so PyPI has to be used instead to get the latest release
This commit is contained in:
parent
dcd95d3a77
commit
9a4dca8054
@ -342,21 +342,31 @@ class Misc(callbacks.Plugin):
|
|||||||
Returns the version of the current bot.
|
Returns the version of the current bot.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
newestUrl = 'https://api.github.com/repos/progval/Limnoria/' + \
|
versions = []
|
||||||
'commits/%s'
|
|
||||||
versions = {}
|
# fetch from PyPI
|
||||||
for branch in ('master', 'testing'):
|
data = json.loads(utils.web.getUrl(
|
||||||
data = json.loads(utils.web.getUrl(newestUrl % branch)
|
'https://pypi.org/pypi/limnoria/json'
|
||||||
.decode('utf8'))
|
).decode('utf8'))
|
||||||
version = data['commit']['committer']['date']
|
release_version = data['info']['version']
|
||||||
# Strip the last 'Z':
|
# zero-left-pad months and days
|
||||||
version = version.rsplit('T', 1)[0].replace('-', '.')
|
release_version = re.sub(
|
||||||
if minisix.PY2 and isinstance(version, unicode):
|
r'\.([0-9])\b', lambda m: '.0' + m.group(1), release_version
|
||||||
version = version.encode('utf8')
|
)
|
||||||
versions[branch] = version
|
|
||||||
newest = _('The newest versions available online are %s.') % \
|
# fetch from Git
|
||||||
', '.join([_('%s (in %s)') % (y,x)
|
data = json.loads(utils.web.getUrl(
|
||||||
for x,y in versions.items()])
|
'https://api.github.com/repos/progval/Limnoria/'
|
||||||
|
'commits/master'
|
||||||
|
).decode('utf8'))
|
||||||
|
git_version = data['commit']['committer']['date']
|
||||||
|
# Strip the last 'Z':
|
||||||
|
git_version = git_version.rsplit('T', 1)[0].replace('-', '.')
|
||||||
|
|
||||||
|
newest = _(
|
||||||
|
'The newest version available online is %(release_version)s, '
|
||||||
|
'or %(git_version)s in Git'
|
||||||
|
) % {'release_version': release_version, 'git_version': git_version}
|
||||||
except utils.web.Error as e:
|
except utils.web.Error as e:
|
||||||
self.log.info('Couldn\'t get website version: %s', e)
|
self.log.info('Couldn\'t get website version: %s', e)
|
||||||
newest = _('I couldn\'t fetch the newest version '
|
newest = _('I couldn\'t fetch the newest version '
|
||||||
|
Loading…
Reference in New Issue
Block a user