2016-11-02 21:47:42 +00:00
|
|
|
#!/usr/bin/env python
|
2015-10-16 00:55:23 +00:00
|
|
|
|
|
|
|
import glob
|
|
|
|
import json
|
|
|
|
import os.path
|
|
|
|
from distutils.version import LooseVersion
|
|
|
|
|
|
|
|
from ansible.module_utils.urls import open_url
|
|
|
|
|
|
|
|
basedir = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
for filename in glob.glob(os.path.join(basedir, '../lib/ansible/compat/*/__init__.py')):
|
|
|
|
if 'compat/tests' in filename:
|
|
|
|
# compat/tests doesn't bundle any code
|
|
|
|
continue
|
|
|
|
|
|
|
|
filename = os.path.normpath(filename)
|
|
|
|
with open(filename, 'r') as module:
|
|
|
|
for line in module:
|
|
|
|
if line.strip().startswith('_BUNDLED_METADATA'):
|
|
|
|
data = line[line.index('{'):].strip()
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print('WARNING: {0} contained no metadata. Could not check for updates'.format(filename))
|
|
|
|
continue
|
|
|
|
metadata = json.loads(data)
|
2018-06-17 12:01:18 +00:00
|
|
|
pypi_fh = open_url('https://pypi.org/pypi/{0}/json'.format(metadata['pypi_name']))
|
2016-11-02 21:47:42 +00:00
|
|
|
pypi_data = json.loads(pypi_fh.read().decode('utf-8'))
|
2015-10-16 00:55:23 +00:00
|
|
|
if LooseVersion(metadata['version']) < LooseVersion(pypi_data['info']['version']):
|
|
|
|
print('UPDATE: {0} from {1} to {2} {3}'.format(
|
|
|
|
metadata['pypi_name'],
|
|
|
|
metadata['version'],
|
|
|
|
pypi_data['info']['version'],
|
2018-06-17 12:01:18 +00:00
|
|
|
'https://pypi.org/pypi/{0}/json'.format(metadata['pypi_name'])))
|