개정판 094bf65c
optimize db connection
Change-Id: I97887b41278bb15fe289ce08ef5aa99da8a65004
DTI_PID/DTI_PID/AppDatabase.py | ||
---|---|---|
81 | 81 |
|
82 | 82 |
def connect(self): |
83 | 83 |
""" return database connection depends on database type """ |
84 |
#import traceback
|
|
84 |
import traceback |
|
85 | 85 |
|
86 | 86 |
conn = None |
87 | 87 |
if self._DBType == 'SQLite': |
... | ... | |
91 | 91 |
conn = pymssql.connect(host=self._host, user=self._user, password=self._password, database=self.db_name, |
92 | 92 |
port=self._port, charset='utf8', autocommit=False, as_dict=True) |
93 | 93 |
|
94 |
#print(traceback.format_stack(None, -14)[-1].split('\n')[-2].strip())
|
|
94 |
print(traceback.format_stack(None, -14)[-1].split('\n')[-2].strip()) |
|
95 | 95 |
|
96 | 96 |
return conn |
97 | 97 |
|
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
104 | 104 |
self.cadGraphics = [] |
105 | 105 |
|
106 | 106 |
# caches |
107 |
self._configs = None |
|
108 |
self._symbolBase = {} |
|
109 | 107 |
self._lineNoPropertiesUID = {} |
110 | 108 |
self._attributeByType = {} |
111 | 109 |
self._connected_items_lists = None |
112 | 110 |
|
113 | 111 |
# caches not need to be clear |
112 |
self._configs = None |
|
114 | 113 |
self._symbolType = {} |
115 | 114 |
self._symbolNametList = {} |
115 |
self._symbolBase = {} |
|
116 | 116 |
|
117 | 117 |
# for load drawing data from database |
118 | 118 |
self._connecterss = {} |
... | ... | |
171 | 171 |
self.cadGraphics.clear() |
172 | 172 |
self.lineIndicators.clear() |
173 | 173 |
self.SpecBreakUpDownIndicator.clear() |
174 |
self._colors = None |
|
175 |
self._lineNoProperties = None |
|
174 |
#self._colors = None
|
|
175 |
#self._lineNoProperties = None
|
|
176 | 176 |
self._lineTypeConfigs = None |
177 | 177 |
self._activeDrawing = None |
178 | 178 |
#self._hmbTable = None |
... | ... | |
182 | 182 |
self._streamLineListModelDatas = [] |
183 | 183 |
self._titleBlockProperties = None |
184 | 184 |
|
185 |
self._configs = None# if not past else self._configs |
|
186 |
self._symbolBase = {}# if not past else self._symbolBase |
|
187 |
self._lineNoPropertiesUID = {} |
|
185 |
#self._configs = None# if not past else self._configs |
|
186 |
#self._symbolBase = {}# if not past else self._symbolBase |
|
187 |
#self._symbolType = {}# if not past else self._symbolType |
|
188 |
#self._lineNoPropertiesUID = {} |
|
188 | 189 |
self._attributeByType = {} |
189 | 190 |
self._connected_items_lists = QEngineeringInstLineNoTextItem() |
190 | 191 |
|
... | ... | |
1057 | 1058 |
self._lineNoProperties.append(attr) |
1058 | 1059 |
|
1059 | 1060 |
res = self._lineNoProperties |
1061 |
|
|
1062 |
# update cache |
|
1063 |
if res: |
|
1064 |
for _prop in res: |
|
1065 |
if str(_prop.UID) not in self._lineNoPropertiesUID: |
|
1066 |
self._lineNoPropertiesUID[str(_prop.UID)] = res |
|
1060 | 1067 |
# Catch the exception |
1061 | 1068 |
except Exception as ex: |
1062 | 1069 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
1834 | 1841 |
iType=symbolTuple['DB_UID'], |
1835 | 1842 |
detectFlip=symbolTuple['flip'], text_area=symbolTuple['TextArea']) |
1836 | 1843 |
ret.append(sym) |
1844 |
|
|
1845 |
# update cache |
|
1846 |
if ret: |
|
1847 |
if 'UID' not in self._symbolBase: |
|
1848 |
self._symbolBase['UID'] = {} |
|
1849 |
if 'name' not in self._symbolBase: |
|
1850 |
self._symbolBase['name'] = {} |
|
1851 |
|
|
1852 |
for _symbol in ret: |
|
1853 |
if _symbol.uid not in self._symbolBase['UID']: |
|
1854 |
self._symbolBase['UID'][_symbol.uid] = _symbol |
|
1855 |
if _symbol.sName not in self._symbolBase['name']: |
|
1856 |
self._symbolBase['name'][_symbol.sName] = _symbol |
|
1837 | 1857 |
except Exception as ex: |
1838 | 1858 |
from App import App |
1839 | 1859 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
257 | 257 |
self.ui.radioButtonAllowLineNoSpaceYes.setChecked(False) |
258 | 258 |
self.ui.radioButtonAllowLineNoSpaceNo.setChecked(True) |
259 | 259 |
|
260 |
properties = docData.getLineProperties() |
|
261 |
if properties: |
|
262 |
for prop in properties: |
|
263 |
self.lineNoAttributeUID.append(prop.UID) |
|
264 |
if prop.AttributeType == "Code Table": |
|
265 |
self.tempLineColorUID.append(prop.Attribute) |
|
266 |
self.ui.comboBoxColorOption.addItem(prop.DisplayAttribute) |
|
267 |
|
|
268 |
properties = docData.getLineProperties() |
|
269 |
if properties: |
|
270 |
for prop in properties: |
|
271 |
self.lineNoAttributeUID.append(prop.UID) |
|
272 |
if prop.AttributeType == "Code Table": |
|
273 |
self.tempLineColorUID.append(prop.Attribute) |
|
274 |
self.ui.comboBoxColorOption.addItem(prop.DisplayAttribute) |
|
275 |
|
|
276 |
self.load_line_properties() |
|
260 |
self.load_line_properties() |
|
277 | 261 |
|
278 | 262 |
# line no setting (line no, size unit, delimiter) |
279 | 263 |
configs = docData.getConfigs('Line No', 'Size Unit') |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
617 | 617 |
|
618 | 618 |
app_doc_data = AppDocData.instance() |
619 | 619 |
|
620 |
symbol = app_doc_data.getSymbolByQuery('Name', name)
|
|
620 |
symbol = app_doc_data.getSymbolByQuery('name', name)
|
|
621 | 621 |
if symbol: |
622 | 622 |
svg_file_name = symbol.sName |
623 | 623 |
svgFilePath = os.path.join(app_doc_data.getCurrentProject().getSvgFilePath(), symbol.getType(), |
내보내기 Unified diff