프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / DTI_PID / AppDocData.py @ dc620556

이력 | 보기 | 이력해설 | 다운로드 (2.04 KB)

1
# coding: utf-8
2

    
3
import sys
4
import os
5
import sqlite3
6
from SingletonInstance import SingletonInstane
7

    
8
DB_NAME = os.path.dirname(os.path.realpath(__file__)) + "\\db\\DTI_PID.db"
9

    
10
class AppDocData(SingletonInstane):
11
    '''
12
        @brief  return project database path
13
    '''
14
    def getPrjDatabasePath(self):
15
        return (os.path.dirname(os.path.realpath(__file__)) + "\\Project_db.db")
16

    
17
    '''
18
        @brief  get project list from database
19
    '''
20
    def getProjectList(self):
21
        from Project import Project
22

    
23
        projectList = []
24

    
25
        try:
26
            conn = sqlite3.connect(self.getPrjDatabasePath())
27
            cursor = conn.cursor()
28
            sql = 'SELECT * FROM Projects'
29
            try:
30
                cursor.execute(sql)
31
                rows = cursor.fetchall()
32
                for row in rows:
33
                    projectList.append(Project(row[0], row[1], row[2], row[3], row[4]))
34
            except Exception as ex:
35
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
36
        finally:
37
            conn.close()
38

    
39
        return projectList
40

    
41
    '''
42
        @brief  get sliding window size
43
    '''
44
    def getSlidingWindowSize(self):
45
        res = [10,10]
46
        try:
47
            # Creates or opens a file called mydb with a SQLite3 DB
48
            conn = sqlite3.connect(DB_NAME)
49
            # Get a cursor object
50
            cursor = conn.cursor()
51

    
52
            sql = "select * from configuration where section='Sliding Window'"
53
            cursor.execute(sql)
54
            rows = cursor.fetchall()
55
            for row in rows:
56
                if row[1] == 'Width':
57
                    res[0] = int(row[2])
58
                elif row[1] == 'Height':
59
                    res[1] = int(row[2])
60
        # Catch the exception
61
        except Exception as e:
62
            # Roll back any change if something goes wrong
63
            conn.rollback()
64
            raise e
65
        finally:
66
            # Close the db connection
67
            conn.close()
68
        
69
        return res
70

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