mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
74 lines
No EOL
1.9 KiB
Python
Executable file
74 lines
No EOL
1.9 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# export suchwow data for the purpose of importing into new model definitions
|
|
|
|
import pickle
|
|
|
|
from suchwow.models import Post, Moderator, Profile, Ban, AuditEvent
|
|
from suchwow import wownero
|
|
|
|
wallet = wownero.Wallet()
|
|
if not wallet.connected:
|
|
print('Wallet not connected')
|
|
exit()
|
|
|
|
all_posts = Post.select().order_by(Post.timestamp.desc())
|
|
all_mods = Moderator.select()
|
|
all_profiles = Profile.select()
|
|
all_bans = Ban.select()
|
|
all_audits = AuditEvent.select()
|
|
all_data = {
|
|
'posts': list(),
|
|
'moderators': list(),
|
|
'profiles': list(),
|
|
'bans': list(),
|
|
'auditevents': list()
|
|
}
|
|
|
|
|
|
for post in all_posts:
|
|
post_data = {
|
|
'id': post.id,
|
|
'title': post.title,
|
|
'text': post.text,
|
|
'submitter': post.submitter,
|
|
'image_name': post.image_name,
|
|
'readonly': post.readonly,
|
|
'hidden': post.hidden,
|
|
'account_index': post.account_index,
|
|
'address_index': post.address_index,
|
|
'timestamp': post.timestamp,
|
|
'reddit_url': post.reddit_url,
|
|
'to_reddit': post.to_reddit,
|
|
'to_discord': post.to_discord,
|
|
'approved': post.approved,
|
|
'txes': wallet.transfers(post.account_index)
|
|
}
|
|
all_data['posts'].append(post_data)
|
|
print(post_data['txes'])
|
|
|
|
for mod in all_mods:
|
|
all_data['moderators'].append(mod.username)
|
|
|
|
for profile in all_profiles:
|
|
all_data['profiles'].append({
|
|
'username': profile.username,
|
|
'address': profile.address
|
|
})
|
|
|
|
for ban in all_bans:
|
|
all_data['bans'].append({
|
|
'username': ban.user.username,
|
|
'reason': ban.reason,
|
|
'timestamp': ban.timestamp
|
|
})
|
|
|
|
for event in all_audits:
|
|
all_data['auditevents'].append({
|
|
'username': event.user.username,
|
|
'timestamp': event.timestamp,
|
|
'action': event.action
|
|
})
|
|
|
|
with open('data/migrate_data.pkl', 'wb') as f:
|
|
f.write(pickle.dumps(all_data)) |