|
1 |
| -import subprocess, os, time, json, psutil |
| 1 | +import subprocess, os, time, json,logging |
| 2 | +import psutil |
| 3 | + |
2 | 4 | from browserstack.local_binary import LocalBinary
|
3 | 5 | from browserstack.bserrors import BrowserStackLocalError
|
4 | 6 |
|
| 7 | +logger = logging.getLogger(__name__) |
| 8 | + |
5 | 9 | class Local:
|
6 | 10 | def __init__(self, key=None, binary_path=None, **kwargs):
|
7 | 11 | self.key = os.environ['BROWSERSTACK_ACCESS_KEY'] if 'BROWSERSTACK_ACCESS_KEY' in os.environ else key
|
@@ -51,22 +55,25 @@ def start(self, **kwargs):
|
51 | 55 | if "onlyCommand" in kwargs and kwargs["onlyCommand"]:
|
52 | 56 | return
|
53 | 57 |
|
54 |
| - self.proc = subprocess.Popen(self._generate_cmd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 58 | + self.proc = subprocess.Popen('ls', stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
55 | 59 | (out, err) = self.proc.communicate()
|
56 | 60 |
|
57 | 61 | os.system('echo "" > "'+ self.local_logfile_path +'"')
|
58 | 62 | try:
|
59 | 63 | if out:
|
60 |
| - data = json.loads(out.decode()) |
| 64 | + output_string = out.decode() |
61 | 65 | else:
|
62 |
| - data = json.loads(err.decode()) |
| 66 | + output_string = err.decode() |
| 67 | + |
| 68 | + data = json.loads(output_string) |
63 | 69 |
|
64 | 70 | if data['state'] != "connected":
|
65 | 71 | raise BrowserStackLocalError(data["message"]["message"])
|
66 | 72 | else:
|
67 | 73 | self.pid = data['pid']
|
68 | 74 | except ValueError:
|
69 |
| - raise BrowserStackLocalError('Error parsing JSON output from daemon') |
| 75 | + logger.error("BinaryOutputParseError: Raw String = '{}'".format(output_string) ) |
| 76 | + raise BrowserStackLocalError('Error parsing JSON output from daemon. Raw String = "{}"'.format(output_string)) |
70 | 77 |
|
71 | 78 | def isRunning(self):
|
72 | 79 | return hasattr(self, 'pid') and psutil.pid_exists(self.pid)
|
|
0 commit comments