forked from sci-visus/VisoarAgExplorer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.py
More file actions
116 lines (80 loc) · 2.81 KB
/
Main.py
File metadata and controls
116 lines (80 loc) · 2.81 KB
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
import os,sys,platform,subprocess,glob
from VisoarAgExplorer import *
from OpenVisus import *
from OpenVisus.gui import *
from PyQt5 import QtCore
from PyQt5.QtWidgets import *
# ////////////////////////////////////////////////////////////////////////////////////////////
def GetArg(name,default_value=""):
for I in range(0,len(sys.argv)):
if sys.argv[I]==name:
ret=sys.argv[I+1]
sys.argv=sys.argv[0:I] + sys.argv[I+2:]
return ret
return default_value
# //////////////////////////////////////////////////////////////////////////////
class Logger(QtCore.QObject):
"""Redirects console output to text widget."""
my_signal = QtCore.pyqtSignal(str)
# constructor
def __init__(self, terminal=None, filename="", qt_callback=None):
super().__init__()
self.terminal=terminal
self.log=open(filename,'w')
self.my_signal.connect(qt_callback)
# write
def write(self, message):
message=message.replace("\n", "\n" + str(datetime.datetime.now())[0:-7] + " ")
self.terminal.write(message)
self.log.write(message)
self.my_signal.emit(str(message))
# flush
def flush(self):
self.terminal.flush()
self.log.flush()
# ////////////////////////////////////////////////////////////////////////////////////////////
class ExceptionHandler(QtCore.QObject):
# __init__
def __init__(self):
super(ExceptionHandler, self).__init__()
self.__excepthook__ = sys.excepthook
sys.excepthook = self.handler
# handler
def handler(self, exctype, value, traceback):
sys.excepthook=self.__excepthook__
sys.excepthook(exctype, value, traceback)
# ////////////////////////////////////////////////////////////////////////////////////////////
def Main():
# set PYTHONPATH=D:\projects\OpenVisus\build\RelWithDebInfo
# example: -m OpenVisus slam "D:\GoogleSci\visus_slam\TaylorGrant"
# example: -m OpenVisus slam3d "D:\GoogleSci\visus_dataset\male\RAW\Fullcolor\fullbody"
SetCommandLine("__main__")
app = QApplication(sys.argv)
GuiModule.attach()
# since I'm writing data serially I can disable locks
os.environ["VISUS_DISABLE_WRITE_LOCK"]="1"
ShowSplash()
args=sys.argv
if args[1]=="VisoarAgExplorer":
win=VisoarAgExplorer()
else:
raise Exception("internal error")
#win.resize(1280,1024)
#win.show()
win.showMaximized()
_stdout = sys.stdout
_stderr = sys.stderr
logger=Logger(terminal=sys.stdout, filename="~visusslam.log", qt_callback=win.printLog)
sys.stdout = logger
sys.stderr = logger
if len(args)==3:
win.setCurrentDir(args[2])
else:
win.chooseDirectory()
exception_handler = ExceptionHandler()
HideSplash()
print("!!!HERE")
app.exec()
sys.stdout = _stdout
sys.stderr = _stderr
GuiModule.detach()