From d3a723fd614d4f02a054a4990f197eb10ec11ed8 Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Sat, 1 Oct 2016 17:20:26 +0200 Subject: [PATCH 1/2] Fix clean_download_cache, add deleting of separate packages --- pythonforandroid/toolchain.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 5509acc5ab..f1bca48ad6 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -364,8 +364,8 @@ def add_parser(subparsers, *args, **kwargs): parents=[generic_parser]) parser_clean_recipe_build.add_argument('recipe', help='The recipe name') - parser_clear_download_cache= add_parser(subparsers, - 'clear_download_cache', aliases=['clear-download-cache'], + parser_clean_download_cache= add_parser(subparsers, + 'clean_download_cache', aliases=['clean-download-cache'], help='Delete any cached recipe downloads', parents=[generic_parser]) @@ -578,13 +578,30 @@ def clean_recipe_build(self, args): def clean_download_cache(self, args): ''' - Deletes any downloaded recipe packages. + Deletes a download cache for recipes stated as arguments. If no + argument is passed, it'll delete *all* downloaded cache. :: + + p4a clean_download_cache kivy,pyjnius This does *not* delete the build caches or final distributions. ''' ctx = self.ctx - if exists(ctx.packages_path): - shutil.rmtree(ctx.packages_path) + msg = "Download cache removed!" + + if args.unknown_args: + for package in args.unknown_args[0].split(','): + remove_path = join(ctx.packages_path, package) + if exists(remove_path): + shutil.rmtree(remove_path) + print(msg[:-1] + ' for: "{}"!'.format(package)) + else: + print('No download cache for "{}" found!'.format(package)) + else: + if exists(ctx.packages_path): + shutil.rmtree(ctx.packages_path) + print(msg) + else: + print('Nothing found at "{}"'.format(ctx.packages_path)) @require_prebuilt_dist def export_dist(self, args): From c0ed84d1ee7e10ea406d6de107782a64647eab08 Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Sat, 1 Oct 2016 18:36:44 +0200 Subject: [PATCH 2/2] Change to known argument --- pythonforandroid/toolchain.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index f1bca48ad6..0619aaa5d1 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -368,6 +368,8 @@ def add_parser(subparsers, *args, **kwargs): 'clean_download_cache', aliases=['clean-download-cache'], help='Delete any cached recipe downloads', parents=[generic_parser]) + parser_clean_download_cache.add_argument('recipe', + help='The recipe name') parser_export_dist = add_parser(subparsers, 'export_dist', aliases=['export-dist'], @@ -587,9 +589,8 @@ def clean_download_cache(self, args): ''' ctx = self.ctx msg = "Download cache removed!" - - if args.unknown_args: - for package in args.unknown_args[0].split(','): + if args.recipe: + for package in args.recipe.split(','): remove_path = join(ctx.packages_path, package) if exists(remove_path): shutil.rmtree(remove_path)