Skip to content

Commit

Permalink
Cleaned up a fixed the auto-generated driver program
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Lee committed Nov 29, 2019
1 parent 0e08033 commit a4843d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyrunner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def setup():

print('Creating Driver Program: {}/{}.py'.format(app_root, app_name))
with open('{}/{}.py'.format(app_root, app_name), 'w') as main_file:
main_file.write(constants.DRIVER_TEMPLATE)
main_file.write(constants.DRIVER_TEMPLATE.format(app_name=app_name))

os.chmod('{}/{}.py'.format(app_root, app_name), 0o744)

Expand Down
33 changes: 14 additions & 19 deletions pyrunner/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,24 @@

ROOT_NODE_NAME = 'PyRunnerRootNode'

DRIVER_TEMPLATE = """
#!/usr/bin/env python3
DRIVER_TEMPLATE = """#!/usr/bin/env python3
import sys
import os, sys
from pyrunner import PyRunner
from pathlib import Path
def main():
app = PyRunner()
# Assign default config and .lst file
app.source_config_file(Path('{}/app_profile'.format(app.config['config_dir'])))
app.load_from_file(Path('{}/{}.lst'.format(app.config['config_dir'], app.config['app_name'])))
# Parse command line args
app.parse_args()
# Initiate job
exit_status = app.execute()
# Ensure job exit status is passed to the caller
sys.exit(exit_status)
abs_dir_path = os.path.dirname(os.path.realpath(__file__))
app = PyRunner()
# Assign default config and .lst file
app.config_file = '{{}}/config/app_profile'.format(abs_dir_path)
app.proc_file = '{{}}/config/{app_name}.lst'.format(abs_dir_path)
# Parse command line args
app.parse_args()
if __name__ == '__main__':
main()
# Initiate job and exit driver with return code
sys.exit(app.execute())
"""
2 changes: 1 addition & 1 deletion pyrunner/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.1.1'
__version__ = '4.1.2'

0 comments on commit a4843d3

Please sign in to comment.