Commit 8fd9d48c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6d86fb8e
......@@ -23,10 +23,11 @@
XXX doc
"""
import os, sys, hashlib, tempfile, subprocess, errno, time
import os, sys, hashlib, tempfile, subprocess, time
import logging as log
from os.path import dirname
from golang import go, chan, select, default
from errno import ENOENT, EEXIST
from ZODB.FileStorage import FileStorage
......@@ -61,7 +62,7 @@ def serve(zurl, exec_=False):
try:
f = open(mntpt + "/.wcfs")
except IOError as e:
if e.errno != errno.ENOENT:
if e.errno != ENOENT:
raise
else:
f.close()
......@@ -91,7 +92,7 @@ def join(zurl, autostart=None):
try:
f = open(mntpt + "/.wcfs")
except IOError as e:
if e.errno != errno.ENOENT:
if e.errno != ENOENT:
raise
else:
# already have it
......@@ -156,7 +157,7 @@ def _start(zurl):
try:
f = open("%s/.wcfs" % mntpt)
except IOError as e:
if e.errno != errno.ENOENT:
if e.errno != ENOENT:
raise
else:
res = f
......@@ -216,12 +217,24 @@ def _wcfs_exe():
return '%s/wcfs' % dirname(__file__)
# _mntpt_4zurl returns wcfs should-be mountpoint for ZODB @ zurl.
#
# it also makes sure the mountpoint exists.
def _mntpt_4zurl(zurl):
# XXX stub.
# XXX what is zurl is zconfig://... ? -> then we have to look inside?
m = hashlib.sha1()
m.update(zurl)
return "%s/wcfs/%s" % (tempfile.gettempdir(), m.hexdigest())
mntpt = "%s/wcfs/%s" % (tempfile.gettempdir(), m.hexdigest())
_mkdir_p(mntpt)
return mntpt
# mkdir -p
def _mkdir_p(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != EEXIST:
raise
# _zstor_2zurl converts a ZODB storage to URL to access it.
......
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