From 1dac2263372df2b85db5d029a45721fa158a5c9d Mon Sep 17 00:00:00 2001 From: xiubuzhe Date: Sun, 8 Oct 2023 20:59:00 +0800 Subject: first add files --- sbin/suncli | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 sbin/suncli (limited to 'sbin/suncli') 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 -- cgit v1.2.3