提交 a55bd6dd 编写于 作者: W wuzewu

Fix the bug that the module cannot be reinstalled when the local model fails to load

上级 e6d10813
...@@ -218,7 +218,7 @@ class LocalModuleManager(object): ...@@ -218,7 +218,7 @@ class LocalModuleManager(object):
try: try:
module = self._local_modules[name] = HubModule.load(module_dir) module = self._local_modules[name] = HubModule.load(module_dir)
except: except:
utils.record_exception('An error was encountered while loading {}.'.format(name)) utils.record_exception('An error was encountered while loading {}'.format(name))
if not module: if not module:
return None return None
...@@ -238,7 +238,7 @@ class LocalModuleManager(object): ...@@ -238,7 +238,7 @@ class LocalModuleManager(object):
try: try:
self._local_modules[subdir] = HubModule.load(fulldir) self._local_modules[subdir] = HubModule.load(fulldir)
except: except:
utils.record_exception('An error was encountered while loading {}.'.format(subdir)) utils.record_exception('An error was encountered while loading {}'.format(subdir))
return [module for module in self._local_modules.values()] return [module for module in self._local_modules.values()]
...@@ -339,7 +339,7 @@ class LocalModuleManager(object): ...@@ -339,7 +339,7 @@ class LocalModuleManager(object):
hub_module_cls = HubModule.load(directory) hub_module_cls = HubModule.load(directory)
# Uninstall local module # Uninstall local module
if self.search(hub_module_cls.name): if os.path.exists(self._get_normalized_path(hub_module_cls.name)):
self.uninstall(hub_module_cls.name) self.uninstall(hub_module_cls.name)
shutil.copytree(directory, self._get_normalized_path(hub_module_cls.name)) shutil.copytree(directory, self._get_normalized_path(hub_module_cls.name))
......
...@@ -61,7 +61,7 @@ class GitSource(object): ...@@ -61,7 +61,7 @@ class GitSource(object):
# reload modules # reload modules
self.load_hub_modules() self.load_hub_modules()
except: except:
utils.record_exception('An error occurred while checkout {}.'.format(self.path)) utils.record_exception('An error occurred while checkout {}'.format(self.path))
def update(self): def update(self):
'''Update the current repo.''' '''Update the current repo.'''
...@@ -71,7 +71,7 @@ class GitSource(object): ...@@ -71,7 +71,7 @@ class GitSource(object):
self.load_hub_modules() self.load_hub_modules()
except: except:
self.hub_modules = OrderedDict() self.hub_modules = OrderedDict()
utils.record_exception('An error occurred while update {}.'.format(self.path)) utils.record_exception('An error occurred while update {}'.format(self.path))
def load_hub_modules(self): def load_hub_modules(self):
if 'hubconf' in sys.modules: if 'hubconf' in sys.modules:
...@@ -86,7 +86,7 @@ class GitSource(object): ...@@ -86,7 +86,7 @@ class GitSource(object):
self.hub_modules[_item.name] = _item self.hub_modules[_item.name] = _item
except: except:
self.hub_modules = OrderedDict() self.hub_modules = OrderedDict()
utils.record_exception('An error occurred while loading {}.'.format(self.path)) utils.record_exception('An error occurred while loading {}'.format(self.path))
sys.path.remove(self.path) sys.path.remove(self.path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册