浏览代码

Fix handling of should_build and add logging

Steven Silvester 8 年之前
父节点
当前提交
9e97cc3d2c
共有 1 个文件被更改,包括 25 次插入16 次删除
  1. 25 16
      jupyterlab/labextensions.py

+ 25 - 16
jupyterlab/labextensions.py

@@ -44,13 +44,15 @@ class BaseExtensionApp(JupyterApp):
 
 class InstallLabExtensionApp(BaseExtensionApp):
     description = "Install labextension(s)"
-    should_build = True
+    should_build = Bool(True, config=True,
+        help="Whether to build the app after the action")
 
     def start(self):
         self.extra_args = self.extra_args or [os.getcwd()]
-        [install_extension(arg, self.app_dir) for arg in self.extra_args]
+        [install_extension(arg, self.app_dir, logger=self.log)
+         for arg in self.extra_args]
         if self.should_build:
-            build(self.app_dir)
+            build(self.app_dir, logger=self.log)
 
 
 class LinkLabExtensionApp(BaseExtensionApp):
@@ -62,51 +64,56 @@ class LinkLabExtensionApp(BaseExtensionApp):
     package is manually re-installed from its source location when
     `jupyter lab build` is run.
     """
-    should_build = True
+    should_build = Bool(True, config=True,
+        help="Whether to build the app after the action")
 
     def start(self):
         self.extra_args = self.extra_args or [os.getcwd()]
-        [link_package(arg, self.app_dir) for arg in self.extra_args]
+        [link_package(arg, self.app_dir, logger=self.log)
+         for arg in self.extra_args]
         if self.should_build:
-            build(self.app_dir)
+            build(self.app_dir, logger=self.log)
 
 
 class UnlinkLabExtensionApp(BaseExtensionApp):
     description = "Unlink labextension(s) or packages by name or path"
-    should_build = True
+    should_build = Bool(True, config=True,
+        help="Whether to build the app after the action")
 
     def start(self):
         self.extra_args = self.extra_args or [os.getcwd()]
-        ans = any([unlink_package(arg, self.app_dir)
+        ans = any([unlink_package(arg, self.app_dir, logger=self.log)
                    for arg in self.extra_args])
         if ans and self.should_build:
-            build(self.app_dir)
+            build(self.app_dir, logger=self.log)
 
 
 class UninstallLabExtensionApp(BaseExtensionApp):
     description = "Uninstall labextension(s) by name"
-    should_build = True
+    should_build = Bool(True, config=True,
+        help="Whether to build the app after the action")
 
     def start(self):
         self.extra_args = self.extra_args or [os.getcwd()]
-        ans = any([uninstall_extension(arg, self.app_dir)
+        ans = any([uninstall_extension(arg, self.app_dir, logger=self.log)
                    for arg in self.extra_args])
         if ans and self.should_build:
-            build(self.app_dir)
+            build(self.app_dir, logger=self.log)
 
 
 class ListLabExtensionsApp(BaseExtensionApp):
     description = "List the installed labextensions"
 
     def start(self):
-        list_extensions(self.app_dir)
+        list_extensions(self.app_dir, logger=self.log)
 
 
 class ListLinkedLabExtensionsApp(BaseExtensionApp):
     description = "List the linked packages"
 
     def start(self):
-        for path in _get_linked_packages(self.app_dir).values():
+        linked = _get_linked_packages(self.app_dir, logger=self.log)
+        for path in linked.values():
             print(path)
 
 
@@ -114,14 +121,16 @@ class EnableLabExtensionsApp(BaseExtensionApp):
     description = "Enable labextension(s) by name"
 
     def start(self):
-        [enable_extension(arg, self.app_dir) for arg in self.extra_args]
+        [enable_extension(arg, self.app_dir, logger=self.log)
+         for arg in self.extra_args]
 
 
 class DisableLabExtensionsApp(BaseExtensionApp):
     description = "Disable labextension(s) by name"
 
     def start(self):
-        [disable_extension(arg, self.app_dir) for arg in self.extra_args]
+        [disable_extension(arg, self.app_dir, logger=self.log)
+         for arg in self.extra_args]
 
 
 _examples = """