diff options
Diffstat (limited to 'sbin/suncli')
-rwxr-xr-x | sbin/suncli | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sbin/suncli b/sbin/suncli new file mode 100755 index 0000000..221932c --- /dev/null +++ b/sbin/suncli @@ -0,0 +1,38 @@ +#!/opt/sunpy3/bin/python3 +import os +import sys +import sunhpc +import sunhpc.invoke +import logging.handlers + +if sys.version_info.major < 3: + print("Sunhpc cluster supports only Python3. Rerun application in Python3 environment.") + exit(0) + +from sunhpc.console import SunhpcConsole + +sunhpc_home = os.environ.get('SUNHPCHOME') +if sunhpc_home: + log_file = os.path.join(sunhpc_home, 'logs', 'runSunhpc.log') +else: + log_file = os.path.join('/opt/sunhpc', 'logs', 'runSunhpc.log') + +log_handler = logging.handlers.RotatingFileHandler(filename=log_file, maxBytes=500000) +log_formatter = logging.Formatter("%(asctime)s %(levelname)s %(name)s %(message)s") +log_handler.setFormatter(log_formatter) +LOGGER = logging.getLogger() +LOGGER.setLevel(logging.DEBUG) +LOGGER.addHandler(log_handler) + +def sunhpcApplication(argv): + hpc = SunhpcConsole() + if len(argv[1:]): + hpc.nonInteractive(argv) + else: + hpc.start() + +if __name__ == "__main__": + try: + sunhpcApplication(sys.argv) + except (KeyboardInterrupt, SystemExit): + pass |