forked from ostis-dev/pyUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
95 lines (76 loc) · 3.01 KB
/
start.py
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
"""
-----------------------------------------------------------------------------
This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
For the latest info, see http://www.ostis.net
Copyright (c) 2010 OSTIS
OSTIS is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OSTIS 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with OSTIS. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
"""
'''
Created on 29.08.2010
@author: Denis Koronchik
'''
import sys
import os.path
import suit.core.kernel
import traceback
import components
import operations
import codecs
import locale as lc
lc.setlocale(lc.LC_ALL, ('English_United States', '1251'))
encoding = lc.getlocale()[1]
if not encoding:
encoding = "utf-8"
reload(sys)
sys.setdefaultencoding(encoding)
sys.stdout = codecs.getwriter(encoding)(sys.stdout, errors = "replace")
sys.stderr = codecs.getwriter(encoding)(sys.stderr, errors = "replace")
if (__name__ == "__main__"):
from optparse import OptionParser
parser = OptionParser()
parser.add_option("--fsrepo", dest = "fsrepo",
help = "use specified repository for system starting",
metavar = "FSREPO", default = 'repo/fs_repo')
parser.add_option("--rbuild", dest = "rbuild",
help = "rebuild repository on system start (yes/no)",
metavar = "RBUILD", default = 'no')
parser.add_option("--rules", dest = "rules",
help = "rules file name",
metavar = "RULES", default = 'build.rules')
(options, args) = parser.parse_args()
if options.rbuild == "yes":
sys.path.append('repo')
import rule_builder
rule_builder.build(options.rules)
sys.path.remove('repo')
kernel = suit.core.kernel.Kernel()
# make modeules list
modules = []
for _mod in operations.modules:
modules.append('operations.' + _mod)
for _mod in components.modules:
modules.append('components.' + _mod)
try:
print os.path.split(sys.argv[0])[0]
kernel.initialize("srs.log",
repo_path = options.fsrepo,
resource_cfg = 'resources.cfg',
modules = modules,
exec_path = os.path.split(sys.argv[0])[0],
cache_path = "_cache",
segments = ["/seb/test", "/seb/demo"])
except:
print "Error:", sys.exc_info()[0]
traceback.print_exc(file=sys.stdout)
kernel.shutdown()