summaryrefslogtreecommitdiffstats
path: root/sbin/suncli
blob: 221932cac4c6cafdeb2dc481b9728dd51d902df0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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