[game-data-packager] 02/02: mirror.py: add progress bars, don't try to fill up 100% disk space

Alexandre Detiste detiste-guest at moszumanska.debian.org
Tue Nov 10 07:56:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 8dc15d7ec24ad56ac0c74f4430f3b42143dbf65c
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue Nov 10 08:52:28 2015 +0100

    mirror.py: add progress bars, don't try to fill up 100% disk space
    
    check all present files even when disk is full
---
 tools/mirror.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/mirror.py b/tools/mirror.py
index 2137c6e..1225544 100755
--- a/tools/mirror.py
+++ b/tools/mirror.py
@@ -25,6 +25,8 @@
 # you'll have to investigate by yourself
 
 WEBROOT = '/var/www/html'
+KEEP_FREE_SPACE = 250 * 1024 * 1024
+QUITE_LARGE = 10 * 1024 * 1024
 
 import os
 import subprocess
@@ -36,6 +38,8 @@ archives = []
 
 os.environ.pop('GDP_MIRROR')
 
+print('loading game definitions...')
+
 for gamename, game in load_games().items():
     game.load_file_data()
     for filename, file in game.files.items():
@@ -73,8 +77,9 @@ for a in archives:
    if not os.path.isfile(archive):
        statvfs = os.statvfs(WEBROOT)
        freespace = statvfs.f_frsize * statvfs.f_bavail
-       if a['size'] > freespace:
-           exit('out of space, can not download' % a['name'])
+       if a['size'] > freespace - KEEP_FREE_SPACE:
+           print('out of space, can not download %s' % a['name'])
+           continue
        subprocess.check_call(['wget', a['download'],
                               '-O', a['name']],
                               cwd=WEBROOT)
@@ -83,8 +88,9 @@ for a in archives:
        exit("%s is empty !!!" % archive)
    if os.path.getsize(archive) != a['size']:
        exit("%s has the wrong size !!!" % archive)
-   hf = HashedFile.from_file(archive, open(archive, 'rb'))
    print('checking %s ...' % archive)
+   hf = HashedFile.from_file(archive, open(archive, 'rb'),
+        size=a['size'], progress=(a['size'] > QUITE_LARGE))
    if a['md5'] and a['md5'] != hf.md5:
        exit("md5 doesn't match for %s !!!" % archive)
    if a['sha1'] and a['sha1'] != hf.sha1:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list