Commit 92c3bbfa authored by Kirill Smelkov's avatar Kirill Smelkov

demo_zbigarray: Switch to dbopen() for opening database

And this way, because dbopen() supports opening various kind of
databases (see previous commit) we can now specify type of database on
command line, e.g.

    /path/to/db
    neo://db@master
    zeo://host:port

/cc @jm
parent 0e8dd91b
...@@ -11,8 +11,7 @@ TODO text ...@@ -11,8 +11,7 @@ TODO text
from __future__ import print_function from __future__ import print_function
from wendelin.bigarray.array_zodb import ZBigArray from wendelin.bigarray.array_zodb import ZBigArray
from ZODB.FileStorage import FileStorage from wendelin.lib.zodb import dbopen, dbclose
from ZODB import DB
import transaction import transaction
from numpy import float64, dtype, cumsum, sin from numpy import float64, dtype, cumsum, sin
...@@ -63,14 +62,14 @@ def gen(signalv): ...@@ -63,14 +62,14 @@ def gen(signalv):
def usage(): def usage():
print("Usage: %s (gen|read) <db>" % sys.argv[0], file=sys.stderr) print("Usage: %s (gen|read) <dburi>" % sys.argv[0], file=sys.stderr)
sys.exit(1) sys.exit(1)
def main(): def main():
try: try:
act = sys.argv[1] act = sys.argv[1]
dbpath = sys.argv[2] dburi = sys.argv[2]
except IndexError: except IndexError:
usage() usage()
...@@ -80,10 +79,7 @@ def main(): ...@@ -80,10 +79,7 @@ def main():
ram_nbytes = psutil.virtual_memory().total ram_nbytes = psutil.virtual_memory().total
print('I: RAM: %.2fGB' % (float(ram_nbytes) / GB)) print('I: RAM: %.2fGB' % (float(ram_nbytes) / GB))
stor = FileStorage(dbpath) root = dbopen(dburi)
db = DB(stor)
conn = db.open()
root = conn.root()
if act == 'gen': if act == 'gen':
sig_dtype = dtype(float64) sig_dtype = dtype(float64)
...@@ -106,9 +102,7 @@ def main(): ...@@ -106,9 +102,7 @@ def main():
m = p.memory_info() m = p.memory_info()
print('VIRT: %i MB\tRSS: %iMB' % (m.vms//MB, m.rss//MB)) print('VIRT: %i MB\tRSS: %iMB' % (m.vms//MB, m.rss//MB))
conn.close() dbclose(root)
db.close()
stor.close()
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment