From 960fef54c0fc19628b2aada73eebe0874143dad3 Mon Sep 17 00:00:00 2001 From: Thomas Grandjean Date: Tue, 4 Jan 2022 11:38:00 +0100 Subject: [PATCH] Update bower.py - resolves issue #16 --- djangobower/bower.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/djangobower/bower.py b/djangobower/bower.py index 700554a..80df461 100644 --- a/djangobower/bower.py +++ b/djangobower/bower.py @@ -27,9 +27,15 @@ def create_components_root(self): def call_bower(self, args): """Call bower with a list of args""" - proc = subprocess.Popen( - [self._bower_path] + list(args), - cwd=self._components_root) + try: + proc = subprocess.Popen( + [self._bower_path] + list(args), + cwd=self._components_root) + except OSError: + proc = subprocess.Popen( + [self._bower_path] + list(args), + cwd=self._components_root, + shell=True) proc.wait() def install(self, packages, *options): @@ -61,11 +67,18 @@ def _parse_package_names(self, output): def freeze(self): """Yield packages with versions list""" - proc = subprocess.Popen( - [self._bower_path, 'list', '--json', '--offline', '--no-color'], - cwd=conf.COMPONENTS_ROOT, - stdout=subprocess.PIPE, - ) + try: + proc = subprocess.Popen( + [self._bower_path, 'list', '--json', '--offline', '--no-color'], + cwd=conf.COMPONENTS_ROOT, + stdout=subprocess.PIPE, + ) + except OSError: + proc = subprocess.Popen( + [self._bower_path, 'list', '--json', '--offline', '--no-color'], + cwd=conf.COMPONENTS_ROOT, + stdout=subprocess.PIPE, + shell=True) outs, errs = proc.communicate() output = outs.decode(sys.getfilesystemencoding())