-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlProgram.py
74 lines (60 loc) · 2.4 KB
/
ControlProgram.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
"""ControlProgram.py: File containing script for running the ControlProgram application.
Application takes 3 arguments:
--CSV = Path to CSV file
--GUI = Path to GUI directory
--TITLE = Title of the main window"""
import os
import sys
import MainWindow
import DeviceTreeModel
import DeviceListModel
from PyQt4 import QtGui
from taurus.qt.qtgui.application import TaurusApplication
import taurus
import argparse
from CsvManager import CsvManager
from AggSystemTreeModel import AggSystemTreeModel
__author__ = "Cosylab"
parser = argparse.ArgumentParser()
parser.add_argument('--CSV', help='Path to CSV file', required=True)
parser.add_argument('--GCSV', help='Path to Group CSV file', required=False)
parser.add_argument('--GUI', help='Path to GUI directory', required=True)
parser.add_argument('--TITLE', help='Title of the main window', required=False)
parser.add_argument('-v', dest="LOG", help='Verbose - log files for custom GUIs to user home folder.', action="store_true")
args = parser.parse_args()
#sys.argv = []
# Check if the default directory for logs exists.
try:
if args.LOG:
log_directory = os.path.expanduser("~/.ControlProgram")
if not os.path.exists(log_directory):
os.makedirs(log_directory)
except Exception, e:
args.LOG = False
print "Verbose mode disabled. Error while trying to create log dir:\n%s" % str(e)
app = TaurusApplication([])
app.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
mainWindow = MainWindow.MainWindow()
ui = MainWindow.Ui_MainWindow()
csvManager = CsvManager(args.CSV, args.GCSV, args.GUI, ui, args.LOG)
ui.setupUi(mainWindow,csvManager)
if args.TITLE:
mainWindow.setWindowTitle(args.TITLE)
taurusDb = taurus.Database()
device_model = DeviceTreeModel.DeviceTreeModel(ui)
device_model.setDataSource(csvManager)
ui.taurusTreeWidget.setModel(device_model)
device_list_model = DeviceListModel.DeviceListModel(ui)
device_list_model.setDataSource(csvManager)
ui.taurusTreeWidget2.setModel(device_list_model)
agg_system_model = AggSystemTreeModel()
agg_system_model.setDataSource(csvManager)
ui.taurusTreeWidget3.setModel(agg_system_model)
ui.taurusTreeWidget.resizeColumnToContents(0)
ui.taurusTreeWidget.setColumnWidth(0, ui.taurusTreeWidget.columnWidth(0) + 100)
ui.taurusTreeWidget2.resizeColumnToContents(0)
ui.taurusTreeWidget2.setColumnWidth(0, ui.taurusTreeWidget2.columnWidth(0) + 100)
mainWindow.show()
ret = app.exec_()
csvManager.destroy()
sys.exit(ret)