Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit e95e61e

Browse files
haobibolbustelo
authored andcommitted
fix bower command issue on windows (#543)
On windows, use `cmd /C bower` for `UrthImportHandler.get()` so that GET request to http://jupyter_notebook:8888/urth_import can work.
1 parent 63c353d commit e95e61e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

nb-extension/python/urth/widgets/ext/urth_import.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
widgets_dir = ''
1616
logger = None
1717

18+
# In Windows`bower` is not an `.exe` (see #373)
19+
cmd_bower = ['cmd', '/C', 'bower'] if os.name == 'nt' else ['bower']
1820

1921
class UrthImportHandler(RequestHandler):
2022

@@ -26,7 +28,7 @@ def initialize(self, executor):
2628
def get(self):
2729
os.chdir(widgets_dir)
2830
try:
29-
proc = subprocess.check_output(['bower', 'list', '--allow-root', '--config.interactive=false', '-o', '-p', '-j'])
31+
proc = subprocess.check_output(cmd_bower + ['list', '--allow-root', '--config.interactive=false', '-o', '-p', '-j'])
3032
d = json.loads(proc.decode('utf-8'))
3133
for k in d.keys():
3234
v = d[k]
@@ -64,11 +66,8 @@ def post(self):
6466
# and non-zero for an error.
6567
def do_install(package_name):
6668
logger.info('Installing %r', package_name)
67-
args = ['bower', 'install', package_name, '--allow-root',
69+
args = cmd_bower + ['install', package_name, '--allow-root',
6870
'--config.interactive=false', '--production', '--quiet']
69-
# In Windows`bower` is not an `.exe` (see #373)
70-
if os.name == 'nt':
71-
args = ['cmd', '/C'] + args
7271
try:
7372
subprocess.check_call(args, cwd=widgets_dir)
7473
except subprocess.CalledProcessError as e:

0 commit comments

Comments
 (0)