[game-data-packager] 01/01: make start-up animation fit on screen again

Alexandre Detiste detiste-guest at moszumanska.debian.org
Sat Dec 12 10:02:52 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 d24d08012ba791f59b1148f96f6f2021d1b23f4e
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Sat Dec 12 10:47:49 2015 +0100

    make start-up animation fit on screen again
    
    It seems now that only a small fraction of the total start-up
    time is still spent in load_games();
    still it's nice to display something at some point
    if user has to wait about 12 seconds for
    an help screen in the worst cases.
    
    Maybe next optimisation step is getting 'GDP --help' to run
    without import'ing build.py and all it's dependencies.
    
    ------------------------
    
    pi2$ time ./run
    
    real    0m4.661s
    user    0m4.460s
    sys     0m0.180s
    
    pi1$ time ./run
    
    real    0m34.434s (with unattended-upgrades & omxplayer running in the background)
    user    0m13.800s
    sys     0m2.030s
---
 game_data_packager/__init__.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index e24591a..48299cf 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1234,7 +1234,7 @@ class GameData(object):
 
 def load_games(game='*', use_vfs=USE_VFS, use_yaml=False):
     progress = (game == '*' and sys.stderr.isatty() and
-            not logging.getLogger().isEnabledFor(logging.DEBUG))
+            not logger.isEnabledFor(logging.DEBUG))
     games = {}
 
     if use_vfs:
@@ -1264,13 +1264,18 @@ def load_games(game='*', use_vfs=USE_VFS, use_yaml=False):
             load_game(progress, games, jsonfile, jsondata)
 
     if progress:
-        print('\r%s\r' % (' ' * len(games)), end='', flush=True, file=sys.stderr)
+        print('\r%s\r' % (' ' * (len(games) // 4 + 1)), end='', flush=True, file=sys.stderr)
 
     return games
 
 def load_game(progress, games, filename, content):
         if progress:
-            print('.', end='', flush=True, file=sys.stderr)
+            animation = ['.','-','*','#']
+            modulo = int(load_game.counter) % len(animation)
+            if modulo > 0:
+                print('\b', end='', flush=True, file=sys.stderr)
+            print(animation[modulo], end='', flush=True, file=sys.stderr)
+            load_game.counter += 1
         try:
             g = os.path.basename(filename)
             g = g[:len(g) - 5]
@@ -1297,6 +1302,8 @@ def load_game(progress, games, filename, content):
             print('Error loading %s:\n' % filename)
             raise
 
+load_game.counter = 0
+
 def run_command_line():
     logger.debug('Arguments: %r', sys.argv)
 

-- 
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