개정판 4400f726
Feature: ID2 listening port를 Project마다 설정 가능하도록 수정
Change-Id: I4d32a558f8e098b4e56d8357101df2d4629c2fee
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
333 | 333 |
path = os.path.join(os.getenv('USERPROFILE'), 'Digital PID') |
334 | 334 |
return os.path.join(path, 'SymbolLibrary.syl') |
335 | 335 |
|
336 |
def getAppDbPath(self): |
|
336 |
def getAppDbPath(self) -> str:
|
|
337 | 337 |
""" |
338 | 338 |
@brief Get application DB file path in ProgramData |
339 | 339 |
@author humkyung |
... | ... | |
899 | 899 |
@brief return project database path |
900 | 900 |
@history humkyung 2018.04.19 return Project.db in Program Data folder instead of PROJECT_DB_PATH variable |
901 | 901 |
''' |
902 |
def getPrjDatabasePath(self): |
|
902 |
def getPrjDatabasePath(self) -> str:
|
|
903 | 903 |
path = os.path.join(os.getenv('USERPROFILE'), 'Digital PID') |
904 | 904 |
if not os.path.exists(path): os.makedirs(path) |
905 | 905 |
|
... | ... | |
1239 | 1239 |
nowDate = datetime.now().strftime('%Y.%m.%d %H:%M') |
1240 | 1240 |
sql = ''' |
1241 | 1241 |
UPDATE Projects |
1242 |
SET UpdatedDate = ?,[Desc]=?,[Unit]=? |
|
1242 |
SET UpdatedDate = ?,[Desc]=?,[Unit]=?,Port=?
|
|
1243 | 1243 |
WHERE Id = ? |
1244 | 1244 |
''' |
1245 | 1245 |
cur = conn.cursor() |
1246 |
cur.execute(sql, (nowDate, project.desc, project.prj_unit, project.getId())) |
|
1246 |
cur.execute(sql, (nowDate, project.desc, project.prj_unit, project.listening_port, project.getId()))
|
|
1247 | 1247 |
|
1248 | 1248 |
if project.database.host and project.database.port: |
1249 | 1249 |
_host = project.database.host + ':' + project.database.port |
... | ... | |
1261 | 1261 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1262 | 1262 |
sys.exc_info()[-1].tb_lineno)) |
1263 | 1263 |
|
1264 |
def update_project_listening_port(self, project): |
|
1265 |
""" |
|
1266 |
update project listening port |
|
1267 |
""" |
|
1268 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
|
1269 |
conn = sqlite3.connect(prjDatabaseFilePath) |
|
1270 |
with conn: |
|
1271 |
try: |
|
1272 |
sql = ''' |
|
1273 |
UPDATE Projects |
|
1274 |
SET Port = ? |
|
1275 |
WHERE Id = ? |
|
1276 |
''' |
|
1277 |
cur = conn.cursor() |
|
1278 |
cur.execute(sql, (project.listening_port, project.getId())) |
|
1279 |
except Exception as ex: |
|
1280 |
# Roll back any change if something goes wrong |
|
1281 |
conn.rollback() |
|
1282 |
print(f'error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' |
|
1283 |
f'{sys.exc_info()[-1].tb_lineno}') |
|
1284 |
|
|
1264 | 1285 |
''' |
1265 | 1286 |
@brief get project list from database |
1266 | 1287 |
@history humkyung 2018.04.18 add only project which's project exists |
1267 | 1288 |
''' |
1268 |
def getProjectList(self): |
|
1289 |
def getProjectList(self) -> list:
|
|
1269 | 1290 |
from Project import Project |
1270 | 1291 |
|
1271 | 1292 |
projectList = [] |
... | ... | |
1274 | 1295 |
with conn: |
1275 | 1296 |
conn.row_factory = sqlite3.Row |
1276 | 1297 |
cursor = conn.cursor() |
1277 |
sql = "select a.Id,a.Name,a.[Desc],a.[Unit],a.Path,a.CreatedDate,a.UpdatedDate,\ |
|
1298 |
sql = "select a.Id,a.Name,a.[Desc],a.[Unit],a.Path,a.CreatedDate,a.UpdatedDate,a.Port,\
|
|
1278 | 1299 |
(select \ |
1279 | 1300 |
CASE \ |
1280 | 1301 |
WHEN b.DBTypes_UID is NULL THEN 'SQLite' \ |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
677 | 677 |
self.ui.radioButtonOpModeGeneral.setChecked(True) |
678 | 678 |
|
679 | 679 |
# app config for individual user |
680 |
configs = docData.getAppConfigs('app', 'port') |
|
681 |
self.ui.spinBoxListeningPort.setValue(int(configs[0].value) if configs else 2549) |
|
680 |
self.ui.spinBoxListeningPort.setValue(self.project.listening_port if self.project.listening_port else 2549) |
|
682 | 681 |
configs = docData.getAppConfigs('app', 'conn port') |
683 | 682 |
self.ui.spinBoxConnectionPort.setValue(int(configs[0].value) if configs else 3030) |
684 | 683 |
|
... | ... | |
1475 | 1474 |
|
1476 | 1475 |
# app config |
1477 | 1476 |
app_configs = [] |
1478 |
app_configs.append(Config('app', 'port', self.ui.spinBoxListeningPort.value())) |
|
1479 | 1477 |
app_configs.append(Config('app', 'conn port', self.ui.spinBoxConnectionPort.value())) |
1480 | 1478 |
|
1479 |
self.project.listening_port = self.ui.spinBoxListeningPort.value() |
|
1481 | 1480 |
_desc = self.project.desc.split(self.lineNoDelimiter) |
1482 | 1481 |
if len(_desc) == 2: |
1483 | 1482 |
if self.ui.radioButtonOpModeGeneral.isChecked(): |
DTI_PID/DTI_PID/License.py | ||
---|---|---|
168 | 168 |
if configs and 1 == len(configs) and 3 == len(configs[0].value.split('.')): |
169 | 169 |
key = '795hi#(7qq5&p#f3ysa#n-449h8g_n95olca)b%t23s7!w%v0m' |
170 | 170 |
"""license type 2""" |
171 |
#api, headers = 'http://smartfeedwebapi.azurewebsites.net/api/License/Count', \ |
|
172 | 171 |
api, headers = 'http://devdoftech.co.kr:5200/api/License/Count', \ |
173 | 172 |
{'Content-Type': 'application/json; charset=utf-8', 'x-auth-token': configs[0].value} |
174 | 173 |
response = requests.post(api, headers=headers) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
2216 | 2216 |
tool_pane = self.ribbon.get_pane('Tool') |
2217 | 2217 |
if tool_pane.ui.toolButtonConnection.isChecked(): |
2218 | 2218 |
if not hasattr(self, '_tcpserver'): |
2219 |
configs = app_doc_data.getAppConfigs('app', 'port') |
|
2220 |
port = 2549 |
|
2221 |
if configs and 1 == len(configs): |
|
2222 |
port = int(configs[0].value) |
|
2219 |
port = app_doc_data.project.listening_port |
|
2223 | 2220 |
self._tcpserver = TcpServer(port) |
2224 | 2221 |
self._tcpserver.sessionOpened() |
2225 | 2222 |
else: |
DTI_PID/DTI_PID/Project.py | ||
---|---|---|
17 | 17 |
self.path = project['Path'] |
18 | 18 |
self.createDate = project['CreatedDate'] |
19 | 19 |
self.updateDate = project['UpdatedDate'] |
20 |
self._listening_port = project['Port'] |
|
20 | 21 |
|
21 | 22 |
_host = project['Host'] if not project['Host'] else project['Host'].split(':')[0] |
22 | 23 |
_port = None if not project['Host'] or ':' not in project['Host'] else project['Host'].split(':')[1] |
... | ... | |
26 | 27 |
db_path=os.path.join(self.path, 'db', Project.DATABASE) if |
27 | 28 |
project['DBType'] == 'SQLite' else project['Name'], port=_port) |
28 | 29 |
|
30 |
@property |
|
31 |
def listening_port(self) -> int: |
|
32 |
return self._listening_port |
|
33 |
|
|
34 |
@listening_port.setter |
|
35 |
def listening_port(self, value): |
|
36 |
self._listening_port = value |
|
37 |
|
|
29 | 38 |
def setId(self, id): |
30 | 39 |
self.id = id |
31 | 40 |
|
내보내기 Unified diff