Check for latest version on pypi, fixes #31

This commit is contained in:
Julien Vehent 2015-11-23 12:08:09 -05:00
Родитель 9cb14037f7
Коммит abde6d26b7
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -140,8 +140,14 @@ def main():
dest='ignore_mac',
help="ignore Message Authentication Code "
"during decryption")
argparser.add_argument('--no-latest-check', action='store_true',
dest='nolatestcheck',
help="skip check for latest version of sops")
args = argparser.parse_args()
if not args.nolatestcheck:
check_latest_version()
kms_arns = ""
if 'SOPS_KMS_ARN' in os.environ:
kms_arns = os.environ['SOPS_KMS_ARN']
@ -1000,5 +1006,22 @@ def panic(msg, error_code=1):
sys.exit(error_code)
def check_latest_version():
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
try:
client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
latest = client.package_releases('sops')[0]
if VERSION < float(latest):
print("INFO: your version of sops is outdated. Version {latest} "
"is available, install it with "
"$ pip install 'sops=={latest}'."
.format(latest=latest), file=sys.stderr)
except:
pass
if __name__ == '__main__':
main()