Beispiel #1
0
 def __init__(self):
     if self.__m_instance is not None:
         raise Exception("Error - Trying to init second instance")
     else:
         self.m_data_persistence = DataPersistence.DataPersistence(self)
         self.__m_emails_lock = RLock()
         self.__m_log_lock = RLock()
         self.__m_log_fr_lock = RLock()
         self.__m_database_lock = RLock()
         self.__m_setting_lock = RLock()
         self.__m_settings = self.m_data_persistence.load_settings()
         self.__m_emails = self.m_data_persistence.load_emails()
         self.__m_log = self.m_data_persistence.load_logs()
         self.__m_log_fr = self.m_data_persistence.load_logs_fr()
         if not self.__m_log_fr:
             self.__m_log_fr = AutoIdDict()
         if not self.__m_log:
             self.__m_log = AutoIdDict()
         if not self.__m_emails:
             self.__m_emails = AutoIdDict()
         if not self.__m_settings:
             self.__m_settings = Settings()
         self.__m_instance = self
         self.__m_image = None
         self.__m_image_fr = None
         self.__m_image_without = None
         self.__m_user = USER
         self.__m_password = PASSWORD
         interfacedb.initialize(DATABASE_PATH, TEMPORARY_PATH)
         self.m_stream_fps = 30
         self.m_data_persistence.save_settings(self.__m_settings)
Beispiel #2
0
    def __getImagesFromDatabase(self):
        """
        Es werden alle Referenzbilder aus der Datenbank geholt und in das Verzeichnis gespeichert, welches in dem
        Config-File angegeben wurde.
        """
        print("Hole Bilder aus Datenbank")

        self.__clearDirectory()
        interfacedb.initialize(self.__path_to_database,
                               self.__path_to_tmpfolder)
        interfacedb.database_connect()
        interfacedb.get_all_pictures()
from scripts import interfacedb

db_directory = '/home/michael/semesterprojekt.db'
tmp_directory = '/home/michael/tmp/'

if __name__ == "__main__":
    try:
        interfacedb.initialize(db_directory, tmp_directory)
        x = interfacedb.delete_action_by_name('test')
        #print(len(x))
    except Exception as e:
        print(e)
        ablob = input_file.read()
        base = os.path.basename(current_file)
        afile, ext = os.path.splitext(base)
        cur.execute(insert_query, [sqlite3.Binary(ablob), ext, afile])
        return cur.lastrowid


if __name__ == "__main__":
    try:
        import sys
        from scripts import interfacedb

        print(sys.argv)
        #Get database connection
        con, cur = new_database(db_directory)
        interfacedb.initialize(db_directory, '/home/michael/tmp/')
        dir_counter = 0
        sub_dir_counter = 0
        directories = os.listdir(sys.argv[1])
        for directory in directories:
            dir_counter += 1
            subdirectories = os.listdir(sys.argv[1] + '/' + directory)
            for subdirectory in subdirectories:
                sub_dir_counter += 1
                # Predefine person insert query
                insert_person_query = "INSERT INTO Person(name) VALUES(?)"
                parent_dir = sys.argv[1] + '/' + directory + '/' + subdirectory
                files = os.listdir(parent_dir)
                file_ids = []

                #Execute insert_person_query and get the last id of the table, which should be the inserted one
 def setUp(self):
     interface.initialize(db_location, tmp_location)
 def test_ExceptionInitialization(self):
     self.assertTrue(interface.initialize("", ""))
     with self.assertRaises(Exception):
         interface.check_for_initialization()
 def test_Initialization(self):
     self.assertTrue(interface.initialize(db_location, tmp_location))
     self.assertTrue(interface.check_for_initialization())