diff --git a/paddlehub/commands/show.py b/paddlehub/commands/show.py index e160da0210556072450cee679b5f2c9a16fd5f5a..6e54d0863a39353423d73ec8724a627777cfc6af 100644 --- a/paddlehub/commands/show.py +++ b/paddlehub/commands/show.py @@ -125,8 +125,6 @@ class ShowCommand(BaseCommand): cwd = os.getcwd() module_dir = default_module_manager.search_module(module_name) - module_dir = (os.path.join(cwd, module_name), - None) if not module_dir else module_dir if not module_dir or not os.path.exists(module_dir[0]): print("%s is not existed!" % module_name) return True diff --git a/paddlehub/module/manager.py b/paddlehub/module/manager.py index acab88d1cefce720983c275f870d40e2f3954e5e..9e6caf182a17ab6cf95c2739578ee821951679b1 100644 --- a/paddlehub/module/manager.py +++ b/paddlehub/module/manager.py @@ -85,6 +85,7 @@ class LocalModuleManager(object): upgrade=False, extra=None): md5_value = installed_module_version = None + from_user_dir = True if module_dir else False if module_name: self.all_modules(update=True) module_info = self.modules_dict.get(module_name, None) @@ -135,6 +136,7 @@ class LocalModuleManager(object): size = len(file_names) - 1 module_dir = os.path.split(file_names[0])[0] module_dir = os.path.join(hub.CACHE_HOME, module_dir) + # remove cache if os.path.exists(module_dir): shutil.rmtree(module_dir) for index, file_name in enumerate(file_names): @@ -160,8 +162,11 @@ class LocalModuleManager(object): fp.write(md5_value) save_path = os.path.join(MODULE_HOME, module_name) if os.path.exists(save_path): - shutil.rmtree(save_path) - shutil.move(module_dir, save_path) + shutil.move(save_path) + if from_user_dir: + shutil.copytree(module_dir, save_path) + else: + shutil.move(module_dir, save_path) module_dir = save_path tips = "Successfully installed %s" % module_name if installed_module_version: