You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.3 KiB
Python
119 lines
4.3 KiB
Python
11 years ago
|
#This program can be used to print out everything in your Inbox or Sent folders and also take things out of the trash.
|
||
|
#Scroll down to the bottom to see the functions that you can uncomment. Save then run this file.
|
||
11 years ago
|
#The functions which only read the database file seem to function just fine even if you have Bitmessage running but you should definitly close it before running the functions that make changes (like taking items out of the trash).
|
||
11 years ago
|
|
||
|
import sqlite3
|
||
|
from time import strftime, localtime
|
||
|
import sys
|
||
|
|
||
|
APPNAME = "PyBitmessage"
|
||
|
from os import path, environ
|
||
|
if sys.platform == 'darwin':
|
||
|
if "HOME" in environ:
|
||
11 years ago
|
appdata = path.join(environ["HOME"], "Library/Application support/", APPNAME) + '/'
|
||
11 years ago
|
else:
|
||
|
print 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.'
|
||
|
sys.exit()
|
||
|
elif 'win' in sys.platform:
|
||
|
appdata = path.join(environ['APPDATA'], APPNAME) + '\\'
|
||
|
else:
|
||
|
appdata = path.expanduser(path.join("~", "." + APPNAME + "/"))
|
||
|
|
||
|
conn = sqlite3.connect( appdata + 'messages.dat' )
|
||
|
conn.text_factory = str
|
||
|
cur = conn.cursor()
|
||
|
|
||
|
def readInbox():
|
||
|
print 'Printing everything in inbox table:'
|
||
|
item = '''select * from inbox'''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
for row in output:
|
||
|
print row
|
||
|
|
||
|
def readSent():
|
||
|
print 'Printing everything in Sent table:'
|
||
11 years ago
|
item = '''select * from sent where folder !='trash' '''
|
||
11 years ago
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
for row in output:
|
||
11 years ago
|
msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber, folder, encodingtype = row
|
||
|
print msgid.encode('hex'), toaddress, 'toripe:', toripe.encode('hex'), 'fromaddress:', fromaddress, 'ENCODING TYPE:', encodingtype, 'SUBJECT:', repr(subject), 'MESSAGE:', repr(message), 'ACKDATA:', ackdata.encode('hex'), lastactiontime, status, pubkeyretrynumber, msgretrynumber, folder
|
||
11 years ago
|
|
||
11 years ago
|
def readSubscriptions():
|
||
|
print 'Printing everything in subscriptions table:'
|
||
|
item = '''select * from subscriptions'''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
for row in output:
|
||
|
print row
|
||
|
|
||
11 years ago
|
def readPubkeys():
|
||
|
print 'Printing everything in pubkeys table:'
|
||
11 years ago
|
item = '''select hash, transmitdata, time, usedpersonally from pubkeys'''
|
||
11 years ago
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
for row in output:
|
||
11 years ago
|
hash, transmitdata, time, usedpersonally = row
|
||
|
print 'Hash:', hash.encode('hex'), '\tTime first broadcast:', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(time)),'utf-8'), '\tUsed by me personally:', usedpersonally, '\tFull pubkey message:', transmitdata.encode('hex')
|
||
11 years ago
|
|
||
11 years ago
|
def readInventory():
|
||
|
print 'Printing everything in inventory table:'
|
||
|
item = '''select hash, objecttype, streamnumber, payload, receivedtime from inventory'''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
for row in output:
|
||
|
hash, objecttype, streamnumber, payload, receivedtime = row
|
||
11 years ago
|
print 'Hash:', hash.encode('hex'), objecttype, streamnumber, '\t', payload.encode('hex'), '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(receivedtime)),'utf-8')
|
||
11 years ago
|
|
||
|
|
||
11 years ago
|
def takeInboxMessagesOutOfTrash():
|
||
|
item = '''update inbox set folder='inbox' where folder='trash' '''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
conn.commit()
|
||
|
print 'done'
|
||
|
|
||
|
def takeSentMessagesOutOfTrash():
|
||
|
item = '''update sent set folder='sent' where folder='trash' '''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
conn.commit()
|
||
|
print 'done'
|
||
|
|
||
11 years ago
|
def markAllInboxMessagesAsUnread():
|
||
|
item = '''update inbox set read='0' '''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
conn.commit()
|
||
|
print 'done'
|
||
|
|
||
11 years ago
|
def vacuum():
|
||
|
item = '''VACUUM'''
|
||
|
parameters = ''
|
||
|
cur.execute(item, parameters)
|
||
|
output = cur.fetchall()
|
||
|
conn.commit()
|
||
|
print 'done'
|
||
|
|
||
11 years ago
|
#takeInboxMessagesOutOfTrash()
|
||
11 years ago
|
#takeSentMessagesOutOfTrash()
|
||
11 years ago
|
#markAllInboxMessagesAsUnread()
|
||
11 years ago
|
#readInbox()
|
||
|
readSent()
|
||
11 years ago
|
#readPubkeys()
|
||
11 years ago
|
#readSubscriptions()
|
||
11 years ago
|
#readInventory()
|
||
11 years ago
|
#vacuum() #will defragment and clean empty space from the messages.dat file.
|
||
11 years ago
|
|
||
11 years ago
|
|
||
|
|