Skip to content

Commit

Permalink
generate_symbols.py: switched from contextlib to subprocess
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Latosinski <[email protected]>
  • Loading branch information
glatosinski committed Nov 19, 2020
1 parent 2b90c3e commit 35b26fa
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions scripts/python-skywater-pdk/skywater_pdk/generate_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@


import sys
import symbolator
import argparse
from pathlib import Path
import errno
import contextlib
import traceback


@contextlib.contextmanager
def redirect_argv(args):
sys._argv = sys.argv
sys.argv = args
yield
sys.argv = sys._argv
import subprocess


def main(argv):
Expand Down Expand Up @@ -108,20 +100,23 @@ def main(argv):
print(f'The {out_filename} already exists')
return errno.EEXIST

arguments = (f'--libname {libname} --title -t -o {out_filename}' +
f' --output-as-filename -i {str(symbol_v_file)}' +
' --format svg')
with redirect_argv(arguments.split(' ')):
try:
symbolator.main()
except Exception:
print(
f'Failed to run: symbolator {arguments}',
file=sys.stderr
)
print('Error message:\n', file=sys.stderr)
traceback.print_exc()
err.write(f'{symbol_v_file}\n')
program = ('symbolator' +
f' --libname {libname} --title -t -o {out_filename}' +
f' --output-as-filename -i {str(symbol_v_file)}' +
' --format svg')
res = subprocess.run(
program.split(' '),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
if res.returncode != 0:
print(
f'Failed to run: {program}',
file=sys.stderr
)
print('STDOUT:\n', file=sys.stderr)
print(res.stdout.decode())
err.write(f'{symbol_v_file}\n')
return 0


Expand Down

0 comments on commit 35b26fa

Please sign in to comment.