mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use explicit locals for custom script execution, handle exception in similar fashion as Python
This commit is contained in:
parent
6d580d24ed
commit
9f9cb2f57a
1 changed files with 7 additions and 3 deletions
10
run.py
10
run.py
|
@ -65,9 +65,13 @@ def python_runtime():
|
|||
|
||||
# update passed args so they don't start with "<binary> python"
|
||||
sys.argv = sys.argv[2:]
|
||||
|
||||
with open(script) as f:
|
||||
exec(f.read())
|
||||
exec_locals = {"__name__": "__main__", "__file__": str(script), "__doc__": None}
|
||||
with open(script, encoding="utf-8") as rfh:
|
||||
try:
|
||||
exec(rfh.read(), exec_locals)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def redirect(argv):
|
||||
|
|
Loading…
Add table
Reference in a new issue