Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250

Open
kashikoibumi wants to merge 125 commits from kashikoibumi/py3qt into v0.6
Showing only changes of commit a1d633dc5f - Show all commits

View File

@ -1,6 +1,7 @@
""" """
Sqlite Inventory Sqlite Inventory
""" """
import six
import sqlite3 import sqlite3
import time import time
from threading import RLock from threading import RLock
@ -110,7 +111,10 @@ class SqliteInventory(InventoryStorage):
# always use the inventoryLock OUTSIDE of the sqlLock. # always use the inventoryLock OUTSIDE of the sqlLock.
with SqlBulkExecute() as sql: with SqlBulkExecute() as sql:
for objectHash, value in self._inventory.items(): for objectHash, value in self._inventory.items():
value = [value[0], value[1], sqlite3.Binary(value[2]), value[3], sqlite3.Binary(value[4])] tag = value[4]
if six.PY3 and isinstance(tag, str):
tag = tag.encode("utf-8", "replace")
value = [value[0], value[1], sqlite3.Binary(value[2]), value[3], sqlite3.Binary(tag)]
sql.execute( sql.execute(
'INSERT INTO inventory VALUES (?, ?, ?, ?, ?, ?)', 'INSERT INTO inventory VALUES (?, ?, ?, ?, ?, ?)',
sqlite3.Binary(objectHash), *value) sqlite3.Binary(objectHash), *value)