Skip to content

Commit 08c0939

Browse files
committed
fixed logfile clear logic
1 parent 2172ec1 commit 08c0939

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

browserstack/local.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ def start(self, **kwargs):
9393
self.proc = subprocess.Popen(self._generate_cmd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9494
(out, err) = self.proc.communicate()
9595

96-
os.system('echo "" > "'+ self.local_logfile_path +'"')
96+
logfile_dir = os.path.dirname(self.local_logfile_path)
97+
if logfile_dir:
98+
os.makedirs(logfile_dir, exist_ok=True)
99+
try:
100+
with open(self.local_logfile_path, 'w') as f:
101+
f.write('')
102+
except OSError as e:
103+
raise BrowserStackLocalError('Unable to open logfile: {}'.format(e))
97104
try:
98105
if out:
99106
output_string = out.decode()

0 commit comments

Comments
 (0)