diff options
author | xiubuzhe <xiubuzhe@sina.com> | 2023-10-08 20:59:00 +0800 |
---|---|---|
committer | xiubuzhe <xiubuzhe@sina.com> | 2023-10-08 20:59:00 +0800 |
commit | 1dac2263372df2b85db5d029a45721fa158a5c9d (patch) | |
tree | 0365f9c57df04178a726d7584ca6a6b955a7ce6a /sbin/suncli | |
parent | b494be364bb39e1de128ada7dc576a729d99907e (diff) | |
download | sunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.tar.gz sunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.tar.bz2 sunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.zip |
first add files
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 |