Skip to content

Commit a4843d3

Browse files
author
Nathan Lee
committed
Cleaned up a fixed the auto-generated driver program
1 parent 0e08033 commit a4843d3

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

pyrunner/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def setup():
151151

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

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

pyrunner/core/constants.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,24 @@
3636

3737
ROOT_NODE_NAME = 'PyRunnerRootNode'
3838

39-
DRIVER_TEMPLATE = """
40-
#!/usr/bin/env python3
39+
DRIVER_TEMPLATE = """#!/usr/bin/env python3
4140
42-
import sys
41+
import os, sys
4342
from pyrunner import PyRunner
4443
from pathlib import Path
4544
46-
def main():
47-
app = PyRunner()
48-
49-
# Assign default config and .lst file
50-
app.source_config_file(Path('{}/app_profile'.format(app.config['config_dir'])))
51-
app.load_from_file(Path('{}/{}.lst'.format(app.config['config_dir'], app.config['app_name'])))
52-
53-
# Parse command line args
54-
app.parse_args()
55-
56-
# Initiate job
57-
exit_status = app.execute()
58-
59-
# Ensure job exit status is passed to the caller
60-
sys.exit(exit_status)
45+
abs_dir_path = os.path.dirname(os.path.realpath(__file__))
46+
47+
app = PyRunner()
48+
49+
# Assign default config and .lst file
50+
app.config_file = '{{}}/config/app_profile'.format(abs_dir_path)
51+
app.proc_file = '{{}}/config/{app_name}.lst'.format(abs_dir_path)
52+
53+
# Parse command line args
54+
app.parse_args()
6155
6256
if __name__ == '__main__':
63-
main()
57+
# Initiate job and exit driver with return code
58+
sys.exit(app.execute())
6459
"""

pyrunner/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.1.1'
1+
__version__ = '4.1.2'

0 commit comments

Comments
 (0)