summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2022-10-07 05:29:18 +0200
committerSimeon Simeonov2022-10-07 05:29:18 +0200
commit8ca7a0d9666ede2d9d270e2a469e4b8dda492e69 (patch)
treed13a2fdda7f7d5cd7fbec9101d965c5b1e3f66b5
parente57758c93eda2330d5f81ce1d1b90bbecf7ac620 (diff)
Replace os.system with subprocess
-rw-r--r--src/etoolkit/__main__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/etoolkit/__main__.py b/src/etoolkit/__main__.py
index 299d75c..a200453 100644
--- a/src/etoolkit/__main__.py
+++ b/src/etoolkit/__main__.py
@@ -28,6 +28,7 @@ import io
28import json 28import json
29import logging 29import logging
30import os 30import os
31import subprocess
31import sys 32import sys
32 33
33import etoolkit 34import etoolkit
@@ -324,9 +325,9 @@ def main(inargs=None):
324 os.environ.update(env) 325 os.environ.update(env)
325 326
326 if args.spawn: 327 if args.spawn:
327 os.system(args.spawn) 328 subprocess.run(args.spawn.split(), check=True)
328 else: 329 else:
329 os.system(os.getenv('SHELL', 'bash')) 330 subprocess.run(os.environ.get('SHELL', 'bash').split(), check=True)
330 except KeyboardInterrupt: 331 except KeyboardInterrupt:
331 logger.debug('KeyboardInterrupt') 332 logger.debug('KeyboardInterrupt')
332 print(os.linesep) 333 print(os.linesep)
@@ -334,6 +335,9 @@ def main(inargs=None):
334 except etoolkit.EtoolkitInstanceError as e: 335 except etoolkit.EtoolkitInstanceError as e:
335 logger.error('EtoolkitInstanceError: %s', e) 336 logger.error('EtoolkitInstanceError: %s', e)
336 sys.exit(1) 337 sys.exit(1)
338 except subprocess.CalledProcessError as e:
339 logger.error('Unable to spawn shell process: %s', e)
340 sys.exit(1)
337 except Exception as e: 341 except Exception as e:
338 logger.error('Unexpected exception: %s', e) 342 logger.error('Unexpected exception: %s', e)
339 sys.exit(1) 343 sys.exit(1)