프로젝트

일반

사용자정보

개정판 1d6948c4

ID1d6948c41fd03a1cc69ba3bd0005d3408d908677
상위 4ee5c4bf
하위 8ec37eca, 9f428148

백흠경이(가) 5년 이상 전에 추가함

issue #622: 저장 로직 수정

Change-Id: I4e20a521b2f02358d4c9d6dea912522e41a60d80

차이점 보기:

DTI_PID/DTI_PID/AppDatabase.py
72 72
        """ return database connection depends on database type """
73 73
        conn = None
74 74
        if self._DBType == 'SQLite':
75
            conn = sqlite3.connect(self.file_path)
75
            conn = sqlite3.connect(self.file_path, isolation_level=None)
76 76
            conn.row_factory = sqlite3.Row
77 77
            #cursor = conn.cursor()
78 78
        elif self._DBType == 'MSSQL':
DTI_PID/DTI_PID/AppDocData.py
229 229

  
230 230
        if self._colors is None or self._colors == []:
231 231
            self._colors = []
232
            try:
233
                conn = self.project.database.connect()
234
                with conn:
232
            conn = self.project.database.connect()
233
            with conn:
234
                try:
235 235
                    cursor = conn.cursor()
236 236
                    sql = 'SELECT UID,RED,GREEN,BLUE FROM Colors'
237 237
                    cursor.execute(sql)
238 238
                    rows = cursor.fetchall()
239 239
                    for row in rows:
240 240
                        self._colors.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3])))
241
            # Catch the exception
242
            except Exception as ex:
243
                # Roll back any change if something goes wrong
244
                conn.rollback()
245

  
246
                from App import App 
247
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
248
                App.mainWnd().addMessage.emit(MessageType.Error, message)
241
                # Catch the exception
242
                except Exception as ex:
243
                    from App import App 
244
                    message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
245
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
249 246

  
250 247
        return self._colors.pop(random.randrange(0, len(self._colors)))
251 248

  
......
421 418
    '''
422 419
    def isExistFileName(self, name):
423 420
        rows = None
424
        try:
425
            conn = self.project.database.connect()
426
            with conn:
421
        conn = self.project.database.connect()
422
        with conn:
423
            try:
427 424
                cursor = conn.cursor()
428 425
                sql = "SELECT * FROM Symbol WHERE name = '"+ name +"'"
429 426
                cursor.execute(sql)
430 427
                rows = cursor.fetchall()
431
        # Catch the exception
432
        except Exception as ex:
433
            # Roll back any change if something goes wrong
434
            conn.rollback()
435
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
436
        finally:
437
            if rows is not None and len(rows) > 0:
438
                return True
439
            else:
440
                return False
428
            # Catch the exception
429
            except Exception as ex:
430
                # Roll back any change if something goes wrong
431
                conn.rollback()
432
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
433
            finally:
434
                if rows is not None and len(rows) > 0:
435
                    return True
436
                else:
437
                    return False
441 438

  
442 439
    '''
443 440
        @brief      Insert new symbol into Symbol Table, Moved from SG_DbHelper
......
802 799
            # Creates or opens a file called mydb with a SQLite3 DB
803 800
            conn = self.project.database.connect()
804 801
            with conn:
805
                # Get a cursor object
806
                cursor = conn.cursor()
802
                try:
803
                    # Get a cursor object
804
                    cursor = conn.cursor()
807 805

  
808
                for deletedTitleBlockProp in deletedTitleBlockProps:
809
                    sql = "delete from TitleBlockProperties where UID='{}'".format(deletedTitleBlockProp)
810
                    cursor.execute(sql)
806
                    for deletedTitleBlockProp in deletedTitleBlockProps:
807
                        sql = "delete from TitleBlockProperties where UID='{}'".format(deletedTitleBlockProp)
808
                        cursor.execute(sql)
811 809

  
812
                for titleBlockProp in titleBlockProps:
813
                    sql = "insert or replace into TitleBlockProperties values(?,?,?)"
814
                    param = (titleBlockProp[0], titleBlockProp[1], titleBlockProp[2]) # uid, name, area
815
                    cursor.execute(sql, param)
816
                conn.commit()
810
                    for titleBlockProp in titleBlockProps:
811
                        sql = "insert or replace into TitleBlockProperties values(?,?,?)"
812
                        param = (titleBlockProp[0], titleBlockProp[1], titleBlockProp[2]) # uid, name, area
813
                        cursor.execute(sql, param)
814
                    conn.commit()
815
                    # Catch the exception
816
                except Exception as ex:
817
                    # Roll back any change if something goes wrong
818
                    conn.rollback()
819
                    print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
817 820
        # Catch the exception
818 821
        except Exception as ex:
819
            # Roll back any change if something goes wrong
820
            conn.rollback()
821 822
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
822 823

  
823 824
        self._titleBlockProperties = None
......
960 961
                    res.append(line_type)
961 962
            # Catch the exception
962 963
            except Exception as ex:
963
                # Roll back any change if something goes wrong
964 964
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
965 965

  
966 966
        return res
......
972 972
        @history    humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable
973 973
    '''
974 974
    def insertProjectInfo(self, desc, prj_unit, dir):
975
        try:
976
            prjDatabaseFilePath = self.getPrjDatabasePath()
977
            conn = sqlite3.connect(prjDatabaseFilePath)
978
            with conn:
975
        prjDatabaseFilePath = self.getPrjDatabasePath()
976
        conn = sqlite3.connect(prjDatabaseFilePath)
977
        with conn:
978
            try:
979 979
                folderName = dir.split('/')[-1]
980 980
                if folderName:
981 981
                    nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M')
......
987 987
                    conn.commit()
988 988
                else:
989 989
                    print("Empty folder name")
990
        except Exception as ex:
991
            # Roll back any change if something goes wrong
992
            conn.rollback()
993
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
990
            except Exception as ex:
991
                # Roll back any change if something goes wrong
992
                conn.rollback()
993
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
994 994

  
995 995
    def removeProjectInfo(self, targetProject):
996 996
        '''
......
998 998
        @author     Euisung
999 999
        @date       2019.01.28
1000 1000
        '''
1001
        try:
1002
            prjDatabaseFilePath = self.getPrjDatabasePath()
1003
            conn = sqlite3.connect(prjDatabaseFilePath)
1004
            sql = "delete from Projects where Id = '{}'".format(targetProject.id)
1005
            cur = conn.cursor()
1006
            cur.execute(sql)
1007
            conn.commit()
1008
        except Exception as ex:
1009
            # Roll back any change if something goes wrong
1010
            conn.rollback()
1011
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1012
        finally:
1013
            conn.close()
1001
        prjDatabaseFilePath = self.getPrjDatabasePath()
1002
        conn = sqlite3.connect(prjDatabaseFilePath)
1003
        with conn:
1004
            try:
1005
                sql = "delete from Projects where Id = '{}'".format(targetProject.id)
1006
                cur = conn.cursor()
1007
                cur.execute(sql)
1008
                conn.commit()
1009
            except Exception as ex:
1010
                # Roll back any change if something goes wrong
1011
                conn.rollback()
1012
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1014 1013

  
1015 1014
    '''
1016 1015
        @brief      update project
......
1099 1098
    '''
1100 1099
    def getLineNoConfiguration(self):
1101 1100
        res = None
1102
        try:
1103
            # Creates or opens a file called mydb with a SQLite3 DB
1104
            conn = self.project.database.connect()
1105
            with conn:
1101

  
1102
        conn = self.project.database.connect()
1103
        with conn:
1104
            try:
1106 1105
                # Get a cursor object
1107 1106
                cursor = conn.cursor()
1108 1107

  
......
1119 1118
                    rows = cursor.fetchall()
1120 1119
                    if len(rows) == 1:
1121 1120
                        res = rows[0][2].split(delimiter)
1122
        # Catch the exception
1123
        except Exception as ex:
1124
            # Roll back any change if something goes wrong
1125
            conn.rollback()
1126
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1121
            # Catch the exception
1122
            except Exception as ex:
1123
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1127 1124
        
1128 1125
        return res
1129 1126

  
......
1136 1133
        from Area import Area
1137 1134

  
1138 1135
        if len(self._areas) == 0:
1139
            try:
1140
                # Creates or opens a file called mydb with a SQLite3 DB
1141
                conn = self.project.database.connect()
1142
                with conn:
1136
            conn = self.project.database.connect()
1137
            with conn:
1138
                try:
1143 1139
                    # Get a cursor object
1144 1140
                    cursor = conn.cursor()
1145 1141

  
......
1151 1147
                        area = Area(name)
1152 1148
                        area.parse(row[2])
1153 1149
                        self._areas.append(area)
1154
            # Catch the exception
1155
            except Exception as ex:
1156
                # Roll back any change if something goes wrong
1157
                conn.rollback()
1158
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1150
                # Catch the exception
1151
                except Exception as ex:
1152
                    print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1159 1153
        
1160 1154
        return self._areas 
1161 1155

  
......
1178 1172

  
1179 1173
        if self.configTable is None:
1180 1174
            self.configTable = []
1181
            try:
1182
                # Creates or opens a file called mydb with a SQLite3 DB
1183
                dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
1184
                conn = self.project.database.connect()
1185
                with conn:
1175
            conn = self.project.database.connect()
1176
            with conn:
1177
                try:
1186 1178
                    # Get a cursor object
1187 1179
                    cursor = conn.cursor()
1188 1180

  
......
1193 1185
                    for row in rows:
1194 1186
                        self.configTable.append(Config(row[0], row[1], row[2]))
1195 1187
                # Catch the exception
1196
            except Exception as ex:
1197
                # Roll back any change if something goes wrong
1198
                conn.rollback()
1199
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1188
                except Exception as ex:
1189
                    print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1200 1190

  
1201 1191
        if key is not None:
1202 1192
            for con in self.configTable:
......
1218 1208

  
1219 1209
        res = []
1220 1210

  
1221
        try:
1222
            # Creates or opens a file called mydb with a SQLite3 DB
1223
            dbPath = self.getAppDbPath()
1224
            conn = sqlite3.connect(dbPath)
1225
            # Get a cursor object
1226
            cursor = conn.cursor()
1211
        # Creates or opens a file called mydb with a SQLite3 DB
1212
        dbPath = self.getAppDbPath()
1213
        conn = sqlite3.connect(dbPath)
1214
        with conn:
1215
            try:
1216
                # Get a cursor object
1217
                cursor = conn.cursor()
1227 1218

  
1228
            if key is not None:
1229
                sql = "select * from configuration where section=? and key=?"
1230
                param = (section, key)
1231
            else:
1232
                sql = "select * from configuration where section=?"
1233
                param = (section,)
1219
                if key is not None:
1220
                    sql = "select * from configuration where section=? and key=?"
1221
                    param = (section, key)
1222
                else:
1223
                    sql = "select * from configuration where section=?"
1224
                    param = (section,)
1234 1225

  
1235
            cursor.execute(sql, param)
1236
            rows = cursor.fetchall()
1237
            for row in rows:
1238
                res.append(Config(row[0], row[1], row[2]))
1239
        # Catch the exception
1240
        except Exception as ex:
1241
            # Roll back any change if something goes wrong
1242
            conn.rollback()
1243
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1244
        finally:
1245
            # Close the db connection
1246
            conn.close()
1226
                cursor.execute(sql, param)
1227
                rows = cursor.fetchall()
1228
                for row in rows:
1229
                    res.append(Config(row[0], row[1], row[2]))
1230
            # Catch the exception
1231
            except Exception as ex:
1232
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1247 1233

  
1248 1234
        return res
1249 1235

  
......
1329 1315
        @date   2018.06.29
1330 1316
    '''
1331 1317
    def deleteConfigs(self, section, key=None):
1332
        try:
1333
            conn = self.project.database.connect()
1334
            with conn:
1318
        conn = self.project.database.connect()
1319
        with conn:
1320
            try:
1335 1321
                # Get a cursor object
1336 1322
                cursor = conn.cursor()
1337 1323

  
......
1342 1328
                cursor.execute(sql)
1343 1329

  
1344 1330
                conn.commit()
1345
        # Catch the exception
1346
        except Exception as ex:
1347
            # Roll back any change if something goes wrong
1348
            conn.rollback()
1349
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1331
            # Catch the exception
1332
            except Exception as ex:
1333
                # Roll back any change if something goes wrong
1334
                conn.rollback()
1335
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1350 1336

  
1351 1337
    def deleteAppConfigs(self, section, key=None):
1352 1338
        """
......
1355 1341
        @date   2018.11.01
1356 1342
        """
1357 1343

  
1358
        try:
1359
            # Creates or opens a file called mydb with a SQLite3 DB
1360
            dbPath = self.getAppDbPath()
1361
            conn = sqlite3.connect(dbPath)
1362
            # Get a cursor object
1363
            cursor = conn.cursor()
1344
        # Creates or opens a file called mydb with a SQLite3 DB
1345
        dbPath = self.getAppDbPath()
1346
        conn = sqlite3.connect(dbPath)
1347
        with conn:
1348
            try:
1349
                # Get a cursor object
1350
                cursor = conn.cursor()
1364 1351

  
1365
            if key is not None:
1366
                sql = "delete from configuration where section='{}' and key='{}'".format(section, key)
1367
            else:
1368
                sql = "delete from configuration where section='{}'".format(section)
1369
            cursor.execute(sql)
1352
                if key is not None:
1353
                    sql = "delete from configuration where section='{}' and key='{}'".format(section, key)
1354
                else:
1355
                    sql = "delete from configuration where section='{}'".format(section)
1356
                cursor.execute(sql)
1370 1357

  
1371
            conn.commit()
1372
        # Catch the exception
1373
        except Exception as ex:
1374
            # Roll back any change if something goes wrong
1375
            conn.rollback()
1376
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1377
        finally:
1378
            # Close the db connection
1379
            conn.close()
1358
                conn.commit()
1359
            # Catch the exception
1360
            except Exception as ex:
1361
                # Roll back any change if something goes wrong
1362
                conn.rollback()
1363
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1380 1364

  
1381 1365
    '''
1382 1366
        @brief      set area list
......
1479 1463
                    conn.commit()
1480 1464
                    ret = True
1481 1465
                except Exception as ex:
1466
                    conn.rollback()
1482 1467
                    print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1483 1468
                    ret = False
1484 1469
            finally:
......
1574 1559
                        res.append(pipeSize)
1575 1560
            # Catch the exception
1576 1561
            except Exception as ex:
1577
                # Roll back any change if something goes wrong
1578
                conn.rollback()
1579
                
1580 1562
                from App import App 
1581 1563
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1582 1564
                App.mainWnd().addMessage.emit(MessageType.Error, message)
......
1623 1605
                cursor.execute(sql)
1624 1606
                conn.commit()
1625 1607
            except Exception as ex:
1608
                conn.rollback()
1626 1609
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1627 1610

  
1628 1611
    '''
......
1632 1615
    '''
1633 1616
    def convertInchToMetric(self, inch):
1634 1617
        result = ''
1635
        try:
1636
            conn = self.project.database.connect()
1637
            with conn:
1618
        conn = self.project.database.connect()
1619
        with conn:
1620
            try:
1638 1621
                # Get a cursor object
1639 1622
                cursor = conn.cursor()
1640 1623
                
......
1646 1629
                if rows:
1647 1630
                    result = rows[0][0]
1648 1631
                # Catch the exception
1649
        except Exception as ex:
1650
            # Roll back any change if something goes wrong
1651
            conn.rollback()
1652
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1632
            except Exception as ex:
1633
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1653 1634

  
1654 1635
        return result
1655 1636

  
......
1661 1642
    def getMaxColorUID(self):
1662 1643
        result = 0
1663 1644

  
1664
        try:
1665
            conn = self.project.database.connect()
1666
            with conn:
1645
        conn = self.project.database.connect()
1646
        with conn:
1647
            try:
1667 1648
                # Get a cursor object
1668 1649
                cursor = conn.cursor()
1669 1650

  
......
1673 1654

  
1674 1655
                result = rows[0][0]
1675 1656
                # Catch the exception
1676
        except Exception as ex:
1677
            # Roll back any change if something goes wrong
1678
            conn.rollback()
1679
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1657
            except Exception as ex:
1658
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1680 1659

  
1681 1660
        return result
1682 1661

  
......
1686 1665
        @date       2018.07.09
1687 1666
    '''
1688 1667
    def setPropertyColor(self, _color):
1689
        try:
1690
            conn = self.project.database.connect()
1691
            with conn:
1668
        conn = self.project.database.connect()
1669
        with conn:
1670
            try:
1692 1671
                # Get a cursor object
1693 1672
                cursor = conn.cursor()
1694 1673
                sql = "INSERT INTO Colors(UID, RED, GREEN, BLUE, PROPERTY, VALUE) VALUES(?,?,?,?,?,?)"
......
1696 1675
                cursor.execute(sql, param)
1697 1676
                conn.commit()
1698 1677
            # Catch the exception
1699
        except Exception as ex:
1700
            # Roll back any change if something goes wrong
1701
            conn.rollback()
1702
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1678
            except Exception as ex:
1679
                # Roll back any change if something goes wrong
1680
                conn.rollback()
1681
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1703 1682

  
1704 1683
    '''
1705 1684
        @brief      delete Color property
......
1707 1686
        @date       2018.07.09
1708 1687
    '''
1709 1688
    def deletePropertyColor(self, property):
1710
        try:
1711
            conn = self.project.database.connect()
1712
            with conn:
1689
        conn = self.project.database.connect()
1690
        with conn:
1691
            try:
1713 1692
                # Get a cursor object
1714 1693
                cursor = conn.cursor()
1715 1694

  
1716 1695
                sql = "DELETE FROM Colors WHERE PROPERTY = '{}'".format(property)
1717 1696
                cursor.execute(sql)
1718 1697
                conn.commit()
1719
            # Catch the exception
1720
        except Exception as ex:
1721
            # Roll back any change if something goes wrong
1722
            conn.rollback()
1723
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1698
                # Catch the exception
1699
            except Exception as ex:
1700
                # Roll back any change if something goes wrong
1701
                conn.rollback()
1702
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1724 1703

  
1725 1704
    '''
1726 1705
        @brief      get Fluid Code
......
1732 1711
        from FluidCodeData import FluidCodeData
1733 1712
        result = []
1734 1713

  
1735
        try:
1736
            conn = self.project.database.connect()
1737
            with conn:
1714
        conn = self.project.database.connect()
1715
        with conn:
1716
            try:
1738 1717
                # Get a cursor object
1739 1718
                cursor = conn.cursor()
1740 1719

  
......
1747 1726
                        result.append(data.code)
1748 1727
                    else:
1749 1728
                        result.append(data)
1750
            # Catch the exception
1751
        except Exception as ex:
1752
            # Roll back any change if something goes wrong
1753
            conn.rollback()
1754
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1729
                # Catch the exception
1730
            except Exception as ex:
1731
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1755 1732

  
1756 1733
        return result
1757 1734

  
......
1761 1738
        @date       2018.07.18
1762 1739
    '''
1763 1740
    def checkAttribute(self, attr):
1764
        try:
1765
            conn = self.project.database.connect()
1766
            with conn:
1741
        conn = self.project.database.connect()
1742
        with conn:
1743
            try:
1767 1744
                # Get a cursor object
1768 1745
                cursor = conn.cursor()
1769 1746

  
......
1775 1752
                    return True
1776 1753
                else:
1777 1754
                    return False
1778
            # Catch the exception
1779
        except Exception as ex:
1780
            # Roll back any change if something goes wrong
1781
            conn.rollback()
1782
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1755
                # Catch the exception
1756
            except Exception as ex:
1757
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1783 1758

  
1784 1759
        return False
1785 1760

  
......
1835 1810

  
1836 1811
        res = None
1837 1812

  
1838
        try:
1839
            conn = self.project.database.connect()
1840
            with conn:
1813
        conn = self.project.database.connect()
1814
        with conn:
1815
            try:
1841 1816
                # Get a cursor object
1842 1817
                cursor = conn.cursor()
1843 1818

  
......
1854 1829
                    res.Expression = rows[0][4]
1855 1830
                    res.Target = rows[0][5]
1856 1831
                    res.IsProp = row[0][6]
1857
            # Catch the exception
1858
        except Exception as ex:
1859
            from App import App
1860

  
1861
            # Roll back any change if something goes wrong
1862
            conn.rollback()
1863

  
1864
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1865
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1832
                # Catch the exception
1833
            except Exception as ex:
1834
                from App import App
1835
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1836
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1866 1837

  
1867 1838
        return res
1868 1839

  
......
1954 1925
                    result = -1
1955 1926
                # Catch the exception
1956 1927
            except Exception as ex:
1957
                # Roll back any change if something goes wrong
1958
                conn.rollback()
1959 1928
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1960 1929

  
1961 1930
        return result
......
2002 1971
            # Catch the exception
2003 1972
            except Exception as ex:
2004 1973
                from App import App 
2005

  
2006
                # Roll back any change if something goes wrong
2007
                conn.rollback()
2008
                
2009 1974
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2010 1975
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2011 1976

  
......
2013 1978

  
2014 1979
    def get_components(self, drawing):
2015 1980
        """ get components in given drawing """
2016
        try:
2017
            conn = self.project.database.connect()
2018
            conn.row_factory = sqlite3.Row
2019
            with conn:
1981
        conn = self.project.database.connect()
1982
        conn.row_factory = sqlite3.Row
1983
        with conn:
1984
            try:
2020 1985
                # Get a cursor object
2021 1986
                cursor = conn.cursor()
2022 1987

  
......
2025 1990
                where a.Drawings_UID='{}'".format(drawing)
2026 1991
                cursor.execute(sql)
2027 1992
                return cursor.fetchall()
2028
            # Catch the exception
2029
        except Exception as ex:
2030
            from App import App 
2031

  
2032
            # Roll back any change if something goes wrong
2033
            conn.rollback()
2034
            
2035
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2036
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1993
                # Catch the exception
1994
            except Exception as ex:
1995
                from App import App 
1996
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1997
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2037 1998

  
2038 1999
    def get_component_connectors(self, component):
2039 2000
        """ get connectors of given component """
2040
        try:
2041
            conn = self.project.database.connect()
2042
            conn.row_factory = sqlite3.Row
2043
            with conn:
2001
        conn = self.project.database.connect()
2002
        conn.row_factory = sqlite3.Row
2003
        with conn:
2004
            try:
2044 2005
                # Get a cursor object
2045 2006
                cursor = conn.cursor()
2046 2007

  
2047 2008
                sql = "select * from Points where Components_UID='{}' order by [Index]".format(component)
2048 2009
                cursor.execute(sql)
2049 2010
                return cursor.fetchall()
2050
            # Catch the exception
2051
        except Exception as ex:
2052
            from App import App 
2053

  
2054
            # Roll back any change if something goes wrong
2055
            conn.rollback()
2056
            
2057
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2058
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2011
                # Catch the exception
2012
            except Exception as ex:
2013
                from App import App 
2014
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2015
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2059 2016

  
2060 2017
    def get_component_associations(self, component):
2061 2018
        """ get associations of given component """
2062
        try:
2063
            conn = self.project.database.connect()
2064
            conn.row_factory = sqlite3.Row
2065
            with conn:
2019
        conn = self.project.database.connect()
2020
        conn.row_factory = sqlite3.Row
2021
        with conn:
2022
            try:
2066 2023
                # Get a cursor object
2067 2024
                cursor = conn.cursor()
2068 2025

  
2069 2026
                sql = "select * from Associations where Components_UID='{}'".format(component)
2070 2027
                cursor.execute(sql)
2071 2028
                return cursor.fetchall()
2072
            # Catch the exception
2073
        except Exception as ex:
2074
            from App import App 
2075

  
2076
            # Roll back any change if something goes wrong
2077
            conn.rollback()
2078
            
2079
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2080
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2029
                # Catch the exception
2030
            except Exception as ex:
2031
                from App import App 
2032
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2033
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2081 2034

  
2082 2035
    def get_component_attributes(self, component):
2083 2036
        """ get attributes of given component """
2084
        try:
2085
            conn = self.project.database.connect()
2086
            conn.row_factory = sqlite3.Row
2087
            with conn:
2037
        conn = self.project.database.connect()
2038
        conn.row_factory = sqlite3.Row
2039
        with conn:
2040
            try:
2088 2041
                # Get a cursor object
2089 2042
                cursor = conn.cursor()
2090 2043

  
2091 2044
                sql = "select * from [Attributes] a \
2092
	                   join SymbolAttribute b on a.SymbolAttribute_UID=b.UID where a.Components_UID='{}' order by a.Components_UID,b.Property".format(component)
2045
                        join SymbolAttribute b on a.SymbolAttribute_UID=b.UID where a.Components_UID='{}' order by a.Components_UID,b.Property".format(component)
2093 2046
                cursor.execute(sql)
2094 2047
                return cursor.fetchall()
2095
            # Catch the exception
2096
        except Exception as ex:
2097
            from App import App 
2098

  
2099
            # Roll back any change if something goes wrong
2100
            conn.rollback()
2101
            
2102
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2103
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2048
                # Catch the exception
2049
            except Exception as ex:
2050
                from App import App 
2051
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2052
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2104 2053

  
2105 2054
    def get_pipe_runs(self, component):
2106 2055
        """ get line runs of given component """
2107
        try:
2108
            conn = self.project.database.connect()
2109
            conn.row_factory = sqlite3.Row
2110
            with conn:
2056
        conn = self.project.database.connect()
2057
        conn.row_factory = sqlite3.Row
2058
        with conn:
2059
            try:
2111 2060
                # Get a cursor object
2112 2061
                cursor = conn.cursor()
2113 2062

  
2114 2063
                sql = "select * from PipeRuns where Owner='{}' order by [Index]".format(component)
2115 2064
                cursor.execute(sql)
2116 2065
                return cursor.fetchall()
2117
            # Catch the exception
2118
        except Exception as ex:
2119
            from App import App 
2120

  
2121
            # Roll back any change if something goes wrong
2122
            conn.rollback()
2123
            
2124
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2125
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2066
                # Catch the exception
2067
            except Exception as ex:
2068
                from App import App 
2069
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2070
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2126 2071

  
2127 2072
    def get_pipe_run_items(self, component):
2128 2073
        """ get line run items of given pipe run """
2129
        try:
2130
            conn = self.project.database.connect()
2131
            conn.row_factory = sqlite3.Row
2132
            with conn:
2074
        conn = self.project.database.connect()
2075
        conn.row_factory = sqlite3.Row
2076
        with conn:
2077
            try:
2133 2078
                # Get a cursor object
2134 2079
                cursor = conn.cursor()
2135 2080

  
2136 2081
                sql = "select * from PipeRunItems where PipeRuns_UID='{}' order by [Index]".format(component)
2137 2082
                cursor.execute(sql)
2138 2083
                return cursor.fetchall()
2139
            # Catch the exception
2140
        except Exception as ex:
2141
            from App import App 
2142

  
2143
            # Roll back any change if something goes wrong
2144
            conn.rollback()
2145
            
2146
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2147
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2084
                # Catch the exception
2085
            except Exception as ex:
2086
                from App import App 
2087
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2088
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2148 2089

  
2149 2090
    '''
2150 2091
        @brief      get special item types from database
......
2152 2093
        @date       2019.08.10
2153 2094
    '''
2154 2095
    def get_special_item_types(self):
2155
        try:
2156
            conn = self.project.database.connect()
2157
            with conn:
2096
        conn = self.project.database.connect()
2097
        with conn:
2098
            try:
2158 2099
                # Get a cursor object
2159 2100
                cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True)
2160 2101

  
2161 2102
                sql = 'select UID, Code, Type, Allowables from SpecialItemTypes order by Code DESC'
2162 2103
                cursor.execute(sql)
2163 2104
                return cursor.fetchall()
2164
            # Catch the exception
2165
        except Exception as ex:
2166
            from App import App 
2167

  
2168
            # Roll back any change if something goes wrong
2169
            conn.rollback()
2170
            
2171
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2172
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2105
                # Catch the exception
2106
            except Exception as ex:
2107
                from App import App 
2108
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2109
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2173 2110
    
2174 2111
    '''
2175 2112
        @brief      save special item types
......
2230 2167
                return cursor.fetchall()
2231 2168
            # catch the exception
2232 2169
            except Exception as ex:
2233
                # Roll back any change if something goes wrong
2234
                conn.rollback()
2235

  
2236 2170
                from App import App 
2237 2171
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2238 2172
                App.mainWnd().addMessage.emit(MessageType.Error, message)
......
2313 2247
        @date       2018.08.16
2314 2248
    '''
2315 2249
    def deleteDataList(self, tableName, UID):
2316
        try:
2317
            conn = self.project.database.connect()
2318
            with conn:
2250
        conn = self.project.database.connect()
2251
        with conn:
2252
            try:
2319 2253
                # Get a cursor object
2320 2254
                cursor = conn.cursor()
2321

  
2322 2255
                sql = 'delete from {} where UID = {}'.format(tableName, UID)
2323
                
2324 2256
                cursor.execute(sql)
2325

  
2326 2257
                conn.commit()
2327 2258

  
2328
        # Catch the exception
2329
        except Exception as ex:
2330
            # Roll back any change if something goes wrong
2331
            conn.rollback()
2332
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2259
            # Catch the exception
2260
            except Exception as ex:
2261
                # Roll back any change if something goes wrong
2262
                conn.rollback()
2263
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2333 2264

  
2334 2265
    def getDocumentNameList(self):
2335 2266
        '''
......
2339 2270
        '''
2340 2271
        result = []
2341 2272

  
2342
        try:
2343
            conn = self.project.database.connect()
2344
            with conn:
2273
        conn = self.project.database.connect()
2274
        with conn:
2275
            try:
2345 2276
                # Get a cursor object
2346 2277
                cursor = conn.cursor()
2347 2278

  
......
2362 2293

  
2363 2294
                result = list(set(result))
2364 2295
                result.sort()
2365
        # Catch the exception
2366
        except Exception as ex:
2367
            # Roll back any change if something goes wrong
2368
            conn.rollback()
2369
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2296
            # Catch the exception
2297
            except Exception as ex:
2298
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2370 2299

  
2371 2300
        return result
2372 2301

  
......
2379 2308
    def getLineDocumentNameList(self):
2380 2309
        result = []
2381 2310

  
2382
        try:
2383
            conn = self.project.database.connect()
2384
            with conn:
2311
        conn = self.project.database.connect()
2312
        with conn:
2313
            try:
2385 2314
                # Get a cursor object
2386 2315
                cursor = conn.cursor()
2387 2316

  
......
2391 2320
                rows = cursor.fetchall()
2392 2321
                for row in rows:
2393 2322
                    result.append(row[0])
2394
        # Catch the exception
2395
        except Exception as ex:
2396
            # Roll back any change if something goes wrong
2397
            conn.rollback()
2398
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2323
            # Catch the exception
2324
            except Exception as ex:
2325
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2399 2326

  
2400 2327
        return result
2401 2328

  
......
2407 2334
    def getEquipDocumentNameList(self):
2408 2335
        result = []
2409 2336

  
2410
        try:
2411
            conn = self.project.database.connect()
2412
            with conn:
2337
        conn = self.project.database.connect()
2338
        with conn:
2339
            try:
2413 2340
                # Get a cursor object
2414 2341
                cursor = conn.cursor()
2415 2342

  
......
2419 2346
                rows = cursor.fetchall()
2420 2347
                for row in rows:
2421 2348
                    result.append(row[0])
2422
        # Catch the exception
2423
        except Exception as ex:
2424
            # Roll back any change if something goes wrong
2425
            conn.rollback()
2426
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2349
            # Catch the exception
2350
            except Exception as ex:
2351
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2427 2352

  
2428 2353
        return result
2429 2354

  
......
2436 2361
    def getLineDataList(self, docName = None):
2437 2362
        result = []
2438 2363

  
2439
        try:
2440
            conn = self.project.database.connect()
2441
            with conn:
2364
        conn = self.project.database.connect()
2365
        with conn:
2366
            try:
2442 2367
                # Get a cursor object
2443 2368
                cursor = conn.cursor()
2444 2369

  
......
2456 2381
                        data.append([attr[0], attr[1]])
2457 2382
                    if data:
2458 2383
                        data.insert(0, ['Drawing Name', comp[1]])
2459
                        data.insert(0, ['UID', comp[0]])
2460
                        result.append(data)
2461

  
2462
        # catch the exception
2463
        except Exception as ex:
2464
            # Roll back any change if something goes wrong
2465
            conn.rollback()
2466
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2384
                        data.insert(0, ['UID', comp[0]])
2385
                        result.append(data)
2386

  
2387
            # catch the exception
2388
            except Exception as ex:
2389
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2467 2390

  
2468 2391
        return result
2469 2392

  
......
2473 2396
        @date       2018.08.13
2474 2397
    '''
2475 2398
    def setLineDataList(self, dataLists):
2476
        try:
2477
            conn = self.project.database.connect()
2478
            # Get a cursor object
2479
            cursor = conn.cursor()
2480
            
2481
            for data in dataLists:
2482
                sql = "insert or replace into LINE_DATA_LIST(UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
2483
                param = tuple(data)
2484
                cursor.execute(sql, param)
2399
        conn = self.project.database.connect()
2400
        with conn:
2401
            try:
2402
                # Get a cursor object
2403
                cursor = conn.cursor()
2404
                
2405
                for data in dataLists:
2406
                    sql = "insert or replace into LINE_DATA_LIST(UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
2407
                    param = tuple(data)
2408
                    cursor.execute(sql, param)
2485 2409

  
2486
            conn.commit()
2410
                conn.commit()
2487 2411

  
2488
        # Catch the exception
2489
        except Exception as ex:
2490
            # Roll back any change if something goes wrong
2491
            conn.rollback()
2492
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2493
        finally:
2494
            # Close the db connection
2495
            conn.close()
2412
            # Catch the exception
2413
            except Exception as ex:
2414
                # Roll back any change if something goes wrong
2415
                conn.rollback()
2416
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2496 2417

  
2497 2418
    '''
2498 2419
        @brief      delete line data list
......
2500 2421
        @date       2018.08.13
2501 2422
    '''
2502 2423
    def deleteLineDataList(self, removeUID):
2503
        try:
2504
            conn = self.project.database.connect()
2505
            with conn:
2424
        conn = self.project.database.connect()
2425
        with conn:
2426
            try:
2506 2427
                # Get a cursor object
2507 2428
                cursor = conn.cursor()
2508 2429
                
......
2512 2433

  
2513 2434
                conn.commit()
2514 2435

  
2515
        # Catch the exception
2516
        except Exception as ex:
2517
            # Roll back any change if something goes wrong
2518
            conn.rollback()
2519
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2436
            # Catch the exception
2437
            except Exception as ex:
2438
                # Roll back any change if something goes wrong
2439
                conn.rollback()
2440
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2520 2441

  
2521 2442
    '''
2522 2443
        @brief      delete line data list
......
2524 2445
        @date       2018.08.13
2525 2446
    '''
2526 2447
    def deleteLineDataList_LineNo(self, removeUID):
2527
        try:
2528
            conn = self.project.database.connect()
2529
            with conn:
2448
        conn = self.project.database.connect()
2449
        with conn:
2450
            try:
2530 2451
                # Get a cursor object
2531 2452
                cursor = conn.cursor()
2532 2453
                
......
2537 2458

  
2538 2459
                conn.commit()
2539 2460

  
2540
        # Catch the exception
2541
        except Exception as ex:
2542
            # Roll back any change if something goes wrong
2543
            conn.rollback()
2544
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2461
            # Catch the exception
2462
            except Exception as ex:
2463
                # Roll back any change if something goes wrong
2464
                conn.rollback()
2465
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2545 2466

  
2546 2467
    '''
2547 2468
        @brief      delete equip data list
......
2549 2470
        @date       2018.08.14
2550 2471
    '''
2551 2472
    def deleteEquipDataList(self, removeUID):
2552
        try:
2553
            conn = self.project.database.connect()
2554
            with conn:
2473
        conn = self.project.database.connect()
2474
        with conn:
2475
            try:
2555 2476
                # Get a cursor object
2556 2477
                cursor = conn.cursor()
2557 2478
                
......
2561 2482

  
2562 2483
                conn.commit()
2563 2484

  
2564
        # Catch the exception
2565
        except Exception as ex:
2566
            # Roll back any change if something goes wrong
2567
            conn.rollback()
2568
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2485
            # Catch the exception
2486
            except Exception as ex:
2487
                # Roll back any change if something goes wrong
2488
                conn.rollback()
2489
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2569 2490

  
2570 2491
    '''
2571 2492
        @brief      delete inst data list
......
2573 2494
        @date       2018.08.14
2574 2495
    '''
2575 2496
    def deleteInstDataList(self, removeUID):
2576
        try:
2577
            conn = self.project.database.connect()
2578
            with conn:
2497
        conn = self.project.database.connect()
2498
        with conn:
2499
            try:
2579 2500
                # Get a cursor object
2580 2501
                cursor = conn.cursor()
2581 2502
                
......
2585 2506

  
2586 2507
                conn.commit()
2587 2508

  
2588
        # Catch the exception
2589
        except Exception as ex:
2590
            # Roll back any change if something goes wrong
2591
            conn.rollback()
2592
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2509
            # Catch the exception
2510
            except Exception as ex:
2511
                # Roll back any change if something goes wrong
2512
                conn.rollback()
2513
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2593 2514

  
2594 2515
    '''
2595 2516
        @brief      delete note data list
......
2622 2543
    '''
2623 2544
    def getEquipmentDataList(self, docName = None):
2624 2545
        result = []
2625
        try:
2626
            conn = self.project.database.connect()
2627
            with conn:
2546
        conn = self.project.database.connect()
2547
        with conn:
2548
            try:
2628 2549
                # Get a cursor object
2629 2550
                cursor = conn.cursor()
2630 2551

  
......
2645 2566
                        if row[len(row)-2] is not None:
2646 2567
                            data[row[len(row)-2]] = row[len(row)-1]
2647 2568
                        result.append(data)
2648
        # Catch the exception
2649
        except Exception as ex:
2650
            from App import App 
2651

  
2652
            # Roll back any change if something goes wrong
2653
            conn.rollback()
2654
            
2655
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2656
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2569
            # Catch the exception
2570
            except Exception as ex:
2571
                from App import App 
2572
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2573
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2657 2574

  
2658 2575
        return result
2659 2576

  
......
2665 2582
        """
2666 2583

  
2667 2584
        result = []
2668
        try:
2669
            conn = self.project.database.connect()
2670
            with conn:
2585
        conn = self.project.database.connect()
2586
        with conn:
2587
            try:
2671 2588
                # Get a cursor object
2672 2589
                cursor = conn.cursor()
2673 2590

  
......
2687 2604
                        data[row[5]] = row[6]
2688 2605
                        result.append(data)
2689 2606

  
2690
        # Catch the exception
2691
        except Exception as ex:
2692
            from App import App 
2693

  
2694
            # Roll back any change if something goes wrong
2695
            conn.rollback()
2696
            
2697
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2698
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2607
            # Catch the exception
2608
            except Exception as ex:
2609
                from App import App 
2610
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2611
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2699 2612

  
2700 2613
        return result
2701 2614

  
......
2706 2619
    '''
2707 2620
    def getInstrumentDataList(self, docName = None):
2708 2621
        result = []
2709
        try:
2710
            conn = self.project.database.connect()
2711
            with conn:
2622
        conn = self.project.database.connect()
2623
        with conn:
2624
            try:
2712 2625
                # Get a cursor object
2713 2626
                cursor = conn.cursor()
2714 2627

  
......
2724 2637
                    for index in range(len(cursor.description)): 
2725 2638
                        data.append(row[index])
2726 2639
                    result.append(data)
2727
        # Catch the exception
2728
        except Exception as ex:
2729
            # Roll back any change if something goes wrong
2730
            conn.rollback()
2731
            from App import App
2732

  
2733
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2734
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2640
            # Catch the exception
2641
            except Exception as ex:
2642
                from App import App
2643
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2644
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2735 2645

  
2736 2646
        return result
2737 2647

  
......
2763 2673
                    result.append(data)
2764 2674
            # Catch the exception
2765 2675
            except Exception as ex:
2766
                # Roll back any change if something goes wrong
2767
                conn.rollback()
2768

  
2769 2676
                from App import App
2770 2677
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2771 2678
                App.mainWnd().addMessage.emit(MessageType.Error, message)
......
2837 2744
                conn.commit()
2838 2745
            # Catch the exception
2839 2746
            except Exception as ex:
2840
                from App import App
2841 2747
                # Roll back any change if something goes wrong
2842 2748
                conn.rollback()
2843 2749

  
2750
                from App import App
2844 2751
                print(sql)
2845 2752
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2846 2753
                App.mainWnd().addMessage.emit(MessageType.Error, message)
......
2851 2758
        @date       2018.05.03
2852 2759
    '''
2853 2760
    def setEquipmentDataList(self, dataList):
2854
        try:
2855
            conn = self.project.database.connect()
2856
            with conn:
2761
        conn = self.project.database.connect()
2762
        with conn:
2763
            try:
2857 2764
                # Get a cursor object
2858 2765
                cursor = conn.cursor()
2859 2766

  
......
2862 2769
                    param = tuple(data)
2863 2770
                    cursor.execute(self.project.database.to_sql(sql), param)
2864 2771
                conn.commit()
2865
        # Catch the exception
2866
        except Exception as ex:
2867
            # Roll back any change if something goes wrong
2868
            conn.rollback()
2869
            from App import App
2772
            # Catch the exception
2773
            except Exception as ex:
2774
                # Roll back any change if something goes wrong
2775
                conn.rollback()
2870 2776

  
2871
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2872
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2777
                from App import App
2778
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2779
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2873 2780

  
2874 2781
    '''
2875 2782
        @brief      set instrumnet data list
......
2877 2784
        @date       2018.08.14
2878 2785
    '''
2879 2786
    def setInstrumentDataList(self, dataList):
2880
        try:
2881
            conn = self.project.database.connect()
2882
            with conn:
2787
        conn = self.project.database.connect()
2788
        with conn:
2789
            try:
2883 2790
                # Get a cursor object
2884 2791
                cursor = conn.cursor()
2885 2792

  
......
2889 2796
                    cursor.execute(sql, param)
2890 2797
                conn.commit()
2891 2798

  
2892
        # Catch the exception
2893
        except Exception as ex:
2894
            # Roll back any change if something goes wrong
2895
            conn.rollback()
2896
            from App import App
2799
            # Catch the exception
2800
            except Exception as ex:
2801
                # Roll back any change if something goes wrong
2802
                conn.rollback()
2897 2803

  
2898
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2899
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2804
                from App import App
2805
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2806
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2900 2807

  
2901 2808
    '''
2902 2809
        @brief      set Note data list
......
2919 2826
            except Exception as ex:
2920 2827
                # Roll back any change if something goes wrong
2921 2828
                conn.rollback()
2922
                from App import App
2923 2829

  
2830
                from App import App
2924 2831
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2925 2832
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2926 2833

  
......
2942 2849
                    res.append([row['UID'], row['NAME'], row['DATETIME']])
2943 2850
            # Catch the exception
2944 2851
            except Exception as ex:
2945
                # Roll back any change if something goes wrong
2946
                conn.rollback()
2947 2852
                from App import App
2948

  
2949 2853
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2950 2854
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2951 2855

  
......
2980 2884
            except Exception as ex:
2981 2885
                # Roll back any change if something goes wrong
2982 2886
                conn.rollback()
2983
                from App import App
2984 2887

  
2888
                from App import App
2985 2889
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2986 2890
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2987 2891

  
......
3017 2921
                    symbolTypeList.append((row[0], row[1], row[2])) # UID, category, type
3018 2922
            except Exception as ex:
3019 2923
                from App import App
3020

  
3021 2924
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
3022 2925
                App.mainWnd().addMessage.emit(MessageType.Error, message)
3023 2926

  
......
3030 2933
    '''
3031 2934
    def getSymbolCategoryByType(self, type):
3032 2935
        category = None
3033
        try:
3034
            conn = self.project.database.connect()
3035
            with conn:
2936
        conn = self.project.database.connect()
2937
        with conn:
2938
            try:
3036 2939
                cursor = conn.cursor()
3037 2940
                sql = self.project.database.to_sql('SELECT Category FROM SymbolType WHERE [Type] = ?')
3038 2941
                cursor.execute(sql,(type,))
3039 2942
                rows = cursor.fetchall()
3040 2943
                if rows is not None and len(rows) > 0:
3041 2944
                    category = rows[0][0]
3042
        except Exception as ex:
3043
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2945
            except Exception as ex:
2946
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
3044 2947

  
3045 2948
        return category
3046 2949

  
......
3127 3030
                        res.append(row[0])
3128 3031
            # Catch the exception
3129 3032
            except Exception as ex:
3130
                # Roll back any change if something goes wrong
3131
                conn.rollback()
3132 3033
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
3133 3034

  
3134 3035
        return res
......
3140 3041
            @date   2019.03.13
3141 3042
        '''
3142 3043
        err = False
3143
        try:
3144
            conn = self.project.database.connect()
3145
            with conn:
3044
        conn = self.project.database.connect()
3045
        with conn:
3046
            try:
3146 3047
                # Get a cursor object
3147 3048
                cursor = conn.cursor()
3148 3049
                sql = "alter table {} add {}".format(table, columnName)
......
3150 3051

  
3151 3052
                conn.commit()
3152 3053

  
3153
        # Catch the exception
3154
        except Exception as ex:
3155
            # Roll back any change if something goes wrong
3156
            conn.rollback()
3157
            err = True
3158
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)