This is an automated email from the git hooks/post-receive script. smcv pushed a commit to branch master in repository game-data-packager.
commit b61f633f3d350f899fc2df122f3cdde66467f38c Author: Simon McVittie <[email protected]> Date: Sat Jan 17 17:57:21 2015 +0000 Add --download, --no-download command-line arguments --- lib/game_data_packager/__init__.py | 29 +++++++++++++++++++++++++---- lib/game_data_packager/games/lgeneral.py | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py index f3d0e15..ec75ca1 100644 --- a/lib/game_data_packager/__init__.py +++ b/lib/game_data_packager/__init__.py @@ -109,6 +109,9 @@ class NoPackagesPossible(Exception): class DownloadsFailed(Exception): pass +class DownloadNotAllowed(Exception): + pass + class HashedFile(object): def __init__(self, name): self.name = name @@ -1540,7 +1543,7 @@ class GameData(object): try: ready = self.prepare_packages(packages, - build_demos=args.demo) + build_demos=args.demo, download=args.download) except NoPackagesPossible: logger.error('Unable to complete any packages.') if self.missing_tools: @@ -1553,6 +1556,10 @@ class GameData(object): # what they should have added self.argument_parser.print_help() raise SystemExit(1) + except DownloadNotAllowed: + logger.error('Unable to complete any packages because ' + + 'downloading missing files was not allowed.') + raise SystemExit(1) except DownloadsFailed: # we already logged an error logger.error('Unable to complete any packages because downloads failed.') @@ -1576,7 +1583,7 @@ class GameData(object): if install_debs: self.install_packages(debs) - def prepare_packages(self, packages, build_demos=False): + def prepare_packages(self, packages, build_demos=False, download=True): possible = set() for package in packages: @@ -1632,14 +1639,20 @@ class GameData(object): continue logger.debug('will produce %s', package.name) - if self.fill_gaps(package=package, download=True, - log=True) is FillResult.COMPLETE: + result = self.fill_gaps(package=package, download=download, + log=True) + if result is FillResult.COMPLETE: ready.add(package) + elif result is FillResult.DOWNLOAD_NEEDED and not download: + logger.warning('As requested, not downloading necessary ' + + 'files for %s', package.name) else: logger.error('Failed to download necessary files for %s', package.name) if not ready: + if not download: + raise DownloadNotAllowed() raise DownloadsFailed() return ready @@ -1836,6 +1849,13 @@ def run_command_line(): dest='search', help='only look in paths provided on the command line') + group = base_parser.add_mutually_exclusive_group() + group.add_argument('--download', action='store_true', + help='automatically download necessary files if possible ' + + '(default)') + group.add_argument('--no-download', action='store_false', + dest='download', help='do not download anything') + parser = argparse.ArgumentParser(prog='game-data-packager', description='Package game files.', parents=(base_parser,)) @@ -1850,6 +1870,7 @@ def run_command_line(): parsed = argparse.Namespace( compress=None, destination=None, + download=True, install=False, search=True, ) diff --git a/lib/game_data_packager/games/lgeneral.py b/lib/game_data_packager/games/lgeneral.py index d51f962..c76cb36 100644 --- a/lib/game_data_packager/games/lgeneral.py +++ b/lib/game_data_packager/games/lgeneral.py @@ -34,14 +34,14 @@ class LGeneralGameData(GameData): 'if necessary)') return parser - def prepare_packages(self, packages, build_demos=False): + def prepare_packages(self, packages, build_demos=False, download=True): # don't bother even trying if it isn't going to work if which('lgc-pg') is None: logger.error('The "lgc-pg" tool is required for this package.') raise NoPackagesPossible() ready = super(LGeneralGameData, self).prepare_packages(packages, - build_demos=build_demos) + build_demos=build_demos, download=download) # would have raised an exception if not assert self.packages['lgeneral-data-nonfree'] in ready -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

