3
MAP Client, a program to generate detailed musculoskeletal models for OpenSim.
4
Copyright (C) 2012 University of Auckland
6
This file is part of MAP Client. (http://launchpad.net/mapclient)
8
MAP Client is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
13
MAP Client is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with MAP Client. If not, see <http://www.gnu.org/licenses/>..
21
import os, sys, locale
23
# With PEP366 we need to conditionally import the settings module based on
24
# whether we are executing the file directly of indirectly. This is my
27
from .settings import info
29
from settings import info
31
# Ensure the MAP Client module directory is in the system path so relative 'import' statements work
32
base_path = os.path.dirname(os.path.abspath(__file__))
33
if sys.path.count(base_path) == 0:
34
sys.path.insert(0, base_path)
39
Display program header
41
programHeader = ' MAP Client (version %s) ' % info.ABOUT['version']
42
print('-' * len(programHeader))
44
print('-' * len(programHeader))
46
# This method starts MAP Client
49
Initialise common settings and check the operating environment before starting the application.
53
# import the locale, and set the locale. This is used for
54
# locale-aware number to string formatting
55
locale.setlocale(locale.LC_ALL, '')
57
from PySide import QtGui
58
app = QtGui.QApplication(sys.argv)
60
# Set the default organisation name and application name used to store application settings
61
app.setOrganizationDomain(info.ORGANISATION_DOMAIN)
62
app.setOrganizationName(info.ORGANISATION_NAME)
63
app.setApplicationName(info.APPLICATION_NAME)
64
app.setApplicationVersion(info.ABOUT['version'])
66
from core.mainapplication import MainApplication
67
model = MainApplication()
69
from widgets.mainwindow import MainWindow
70
window = MainWindow(model)
75
class ConsumeOutput(object):
77
self.messages = list()
79
def write(self, message):
80
self.messages.append(message)
83
locale.setlocale(locale.LC_ALL, '')
85
from optparse import OptionParser
86
from PySide import QtCore
87
app = QtCore.QCoreApplication(sys.argv)
89
# Set the default organisation name and application name used to store application settings
90
QtCore.QCoreApplication.setOrganizationName(info.ORGANISATION_NAME)
91
QtCore.QCoreApplication.setOrganizationDomain(info.ORGANISATION_DOMAIN)
92
QtCore.QCoreApplication.setApplicationName(info.APPLICATION_NAME)
94
old_stdout = sys.stdout
95
sys.stdout = redirectstdout = ConsumeOutput()
97
sys.stdout = old_stdout
98
versionstring = ''.join(redirectstdout.messages)
100
progname = os.path.splitext(__file__)[0]
101
usage = 'usage: {0} [options] workflow\n Execute the given workflow'.format(progname)
102
parser = OptionParser(usage, version=versionstring)
103
options, args = parser.parse_args()
108
# Possibly don't need to run app.exec_()
112
if __name__ == '__main__':
113
if len(sys.argv) == 1: # No command line arguments