forked from cory/tildefriends
Adding a completely dangerous tool to dump and load all lmdb databases.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3217 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
45f0136ceb
commit
a3524b761b
30
tools/data
Executable file
30
tools/data
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
if sys.argv[1] == 'dump':
|
||||||
|
with zipfile.ZipFile('data.zip', 'w') as z:
|
||||||
|
for root, dirs, files in os.walk('data'):
|
||||||
|
for f in files:
|
||||||
|
if f == 'data.mdb':
|
||||||
|
database = subprocess.check_output(['mdb_dump', root])
|
||||||
|
z.writestr(root, database)
|
||||||
|
elif sys.argv[1] == 'load':
|
||||||
|
with zipfile.ZipFile('data.zip', 'r') as z:
|
||||||
|
for name in z.namelist():
|
||||||
|
database = z.read(name)
|
||||||
|
if os.path.exists(name):
|
||||||
|
shutil.rmtree(name)
|
||||||
|
os.makedirs(name)
|
||||||
|
p = subprocess.Popen(['mdb_load', name], stdin=subprocess.PIPE)
|
||||||
|
p.communicate(database)
|
||||||
|
assert p.wait() == 0
|
||||||
|
#for root, dirs, files in os.walk('data'):
|
||||||
|
#for f in files:
|
||||||
|
#if f == 'data.mdb':
|
||||||
|
#database = subprocess.check_output(['mdb_dump', root])
|
||||||
|
#z.writestr(root, database)
|
Loading…
Reference in New Issue
Block a user