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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2018 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
#-------------------------------------------------------------------------------
import os
import sys
#-------------------------------------------------------------------------------
class master_script:
def __init__(self, argv = None, package = None):
self.command = argv
self.package = package
self.commands = {'studymanager':self.studymanager,
'smgr':self.studymanager,
'bdiff':self.bdiff,
'bdump':self.bdump,
'compile':self.compile,
'config':self.config,
'create':self.create,
'gui':self.gui,
'studymanagergui':self.studymanager_gui,
'smgrgui':self.studymanager_gui,
'trackcvg':self.trackcvg,
'info':self.info,
'run':self.run,
'salome':self.salome,
'submit':self.submit}
if package != None:
sys.path.insert(1, package.get_dir('pythondir'))
def execute(self):
help_commands = ("help", "--help", "-h")
vers_commands = ("--version", "-v")
if len(self.command) < 1:
# On Windows platform, we have two executables frozen by cx_freeze:
# a .com designed for a console mode (it can also be accessed
# without the extension) and a .exe designed for a GUI mode.
# At the moment, running the main script does not launch the GUI
# mode. Therefore, we force the 'gui' option in this case.
# This can be changed later on.
if sys.platform.startswith('win') and \
os.path.basename(sys.argv[0]).endswith('exe'):
command = 'gui'
else:
self.usage()
sys.exit(0)
else:
command = self.command[0]
if command in help_commands:
subcommand = False
if len(self.command) > 1:
subcommand = True
command = self.command[1]
if self.command[1] in self.commands:
options = self.command[1:] + ['--help']
return self.commands[command](options)
if not subcommand:
self.usage()
sys.exit(0)
if command in self.commands:
options = self.command[1:]
return self.commands[command](options)
else:
self.usage()
sys.exit(1)
def usage(self):
usage = \
"""Usage: %(prog)s <topic>
Topics:
help
studymanager
smgr
bdiff
bdump
compile
config
create
gui
studymanagergui
smgrgui
trackcvg
info
run
salome
submit
Options:
-h, --help show this help message and exit"""
print(usage % {'prog':sys.argv[0]})
def studymanager(self, options = None):
import cs_studymanager
return cs_studymanager.main(options, self.package)
def bdiff(self, options = None):
import cs_bdiff
return cs_bdiff.main(options, self.package)
def bdump(self, options = None):
import cs_bdump
return cs_bdump.main(options, self.package)
def compile(self, options = None):
import cs_compile
return cs_compile.main(options, self.package)
def config(self, options = None):
import cs_config
return cs_config.main(options, self.package)
def create(self, options = None):
import cs_create
return cs_create.main(options, self.package)
def gui(self, options = None):
import cs_gui
return cs_gui.main(options, self.package)
def studymanager_gui(self, options = None):
import cs_studymanager_gui
return cs_studymanager_gui.main(options, self.package)
def trackcvg(self, options = None):
import cs_trackcvg
return cs_trackcvg.main(options, self.package)
def info(self, options = None):
import cs_info
return cs_info.main(options, self.package)
def run(self, options = None):
import cs_run
return cs_run.main(options, self.package)
def salome(self, options = None):
import cs_salome
return cs_salome.main(options, self.package)
def submit(self, options = None):
import cs_submit
return cs_submit.main(options, self.package)
#-------------------------------------------------------------------------------
# End
#-------------------------------------------------------------------------------
|