Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250
3
revert_blob_to_text.sh
Executable file
3
revert_blob_to_text.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
python3 pybitmessage/revert_blob_to_text.py "$@"
|
52
src/revert_blob_to_text.py
Normal file
52
src/revert_blob_to_text.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import helper_startup
|
||||||
|
import state
|
||||||
|
import shutil
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
expected_ver = 11
|
||||||
|
|
||||||
|
print("Looking up database file..")
|
||||||
|
helper_startup.loadConfig()
|
||||||
|
db_path = state.appdata + "messages.dat"
|
||||||
|
print("Database path: {}".format(db_path))
|
||||||
|
db_backup_path = db_path + ".blob-keys"
|
||||||
|
print("Backup path: {}".format(db_backup_path))
|
||||||
|
shutil.copyfile(db_path, db_backup_path)
|
||||||
|
print("Copied to backup")
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("Open the database")
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
cur = conn.cursor()
|
||||||
|
|
||||||
|
cur.execute("SELECT value FROM settings WHERE key='version';")
|
||||||
|
ver = int(cur.fetchall()[0][0])
|
||||||
|
print("PyBitmessage database version: {}".format(ver))
|
||||||
|
if ver != expected_ver:
|
||||||
|
print("Error: version must be {}".format(expected_ver))
|
||||||
|
conn.close()
|
||||||
|
print("Quitting..")
|
||||||
|
quit()
|
||||||
|
print("Version OK")
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("Converting..")
|
||||||
|
q = "UPDATE inbox SET msgid=CAST(msgid AS TEXT), sighash=CAST(sighash AS TEXT);"
|
||||||
|
print(q)
|
||||||
|
cur.execute(q)
|
||||||
|
q = "UPDATE pubkeys SET transmitdata=CAST(transmitdata AS TEXT);"
|
||||||
|
print(q)
|
||||||
|
cur.execute(q)
|
||||||
|
q = "UPDATE sent SET msgid=CAST(msgid AS TEXT), toripe=CAST(toripe AS TEXT), ackdata=CAST(ackdata AS TEXT);"
|
||||||
|
print(q)
|
||||||
|
cur.execute(q)
|
||||||
|
|
||||||
|
print("Commiting..")
|
||||||
|
conn.commit()
|
||||||
|
print("Conversion done")
|
||||||
|
|
||||||
|
print("Close the database")
|
||||||
|
conn.close()
|
||||||
|
print("Finished")
|
Reference in New Issue
Block a user