automatically delete old snapshots

This commit is contained in:
Maximilian Hils 2016-02-12 21:57:48 +01:00
parent c75951d1cb
commit 16433ccb0c

View File

@ -13,6 +13,7 @@ import tarfile
import platform import platform
import click import click
import pysftp import pysftp
import fnmatch
from six.moves import shlex_quote from six.moves import shlex_quote
# https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes # https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes
@ -362,6 +363,11 @@ def upload_snapshot(host, port, user, private_key, private_key_password, sdist,
remote_filename = f.replace(get_version(project), get_snapshot_version(project)) remote_filename = f.replace(get_version(project), get_snapshot_version(project))
symlink_path = "../{}".format(f.replace(get_version(project), "latest")) symlink_path = "../{}".format(f.replace(get_version(project), "latest"))
old_version = f.replace(get_version(project), "*")
for f in sftp.listdir():
if fnmatch.fnmatch(f, old_version):
sftp.remove(f)
print("Uploading {} as {}...".format(f, remote_filename)) print("Uploading {} as {}...".format(f, remote_filename))
with click.progressbar(length=os.stat(local_path).st_size) as bar: with click.progressbar(length=os.stat(local_path).st_size) as bar:
sftp.put( sftp.put(