Exemplo n.º 1
0
    def getValue(self, key, default=None):
        get_query = QSqlQuery(self.db)
        get_query.setForwardOnly(True)
        get_query.prepare("SELECT value FROM settings WHERE name=:key")

        value = default
        get_query.bindValue(":key", key)
        if not get_query.exec():
            if not default:
                logging.fatal(f"Failed to get settings for key='{key}'")
            return value
        if get_query.next():
            value = get_query.value(0)
        return value
Exemplo n.º 2
0
    def ScanDirectory(self, Dir, include=[], Slot=lambda: ''):
        BatchMetadata = []
        FileHashList = []
        file_paths = {}
        for D, SD, F in os.walk(os.path.normpath(Dir)):
            for file in F:
                if os.path.splitext(file)[1] in include:
                    file = os.path.normpath(os.path.join(D, file))
                    file_paths[(hashlib.md5(file.encode())).hexdigest()] = file

        Slot(f"Scanning {Dir}")
        ID = ", ".join([f"'{v}'" for v in set(file_paths.keys())])
        query = QSqlQuery(
            f"SELECT path_id FROM library WHERE path_id IN ({ID})")
        query.exec_()
        while query.next():
            del file_paths[query.value(0)]

        self.FileChecker(file_paths, FileHashList, BatchMetadata)
        self.BatchInsert_Metadata(self.TransposeMeatadata(BatchMetadata))
        Slot(f"Completed Scanning {Dir}")