gsyncd: python3 compat fixes
Also add __codecheck script which can verify if source is OK at the syntactical level with a given Python interpreter. Change-Id: Ieff34bcd3efd1cdc0e8f9a510c05488f35897bbe BUG: 1570 Reviewed-on: http://review.gluster.com/320 Reviewed-by: Kaushik BV <kaushikbv@gluster.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
f3081a2274
commit
e139eeeb62
27
xlators/features/marker/utils/syncdaemon/__codecheck.py
Normal file
27
xlators/features/marker/utils/syncdaemon/__codecheck.py
Normal file
@ -0,0 +1,27 @@
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
fl = os.listdir(os.path.dirname(sys.argv[0]) or '.')
|
||||
fl.sort()
|
||||
for f in fl:
|
||||
if f[-3:] != '.py' or f[0] == '_':
|
||||
continue
|
||||
m = f[:-3]
|
||||
sys.stdout.write('importing %s ...' % m)
|
||||
__import__(m)
|
||||
print(' OK.')
|
||||
|
||||
def sys_argv_set(a):
|
||||
sys.argv = sys.argv[:1] + a
|
||||
|
||||
gsyncd = sys.modules['gsyncd']
|
||||
for a in [['--help'], ['--version'], ['--canonicalize-escape-url', '/foo']]:
|
||||
print('>>> invoking program with args: %s' % ' '.join(a))
|
||||
pid = os.fork()
|
||||
if not pid:
|
||||
sys_argv_set(a)
|
||||
gsyncd.main()
|
||||
_, r = os.waitpid(pid, 0)
|
||||
if r:
|
||||
raise RuntimeError('invocation failed')
|
@ -173,7 +173,7 @@ class GConffile(object):
|
||||
opt = norm(opt)
|
||||
v = d.get(opt)
|
||||
if v:
|
||||
print v
|
||||
print(v)
|
||||
else:
|
||||
for k, v in d.iteritems():
|
||||
if k == '__name__':
|
||||
|
@ -110,7 +110,7 @@ class GMaster(object):
|
||||
self.volinfo_state = (uuid_preset and {'uuid': uuid_preset}, None)
|
||||
# the actual volinfo we make use of
|
||||
self.volinfo = None
|
||||
self.terminate = False
|
||||
self.terminate = False
|
||||
|
||||
def crawl_loop(self):
|
||||
"""start the keep-alive thread and iterate .crawl"""
|
||||
|
@ -8,7 +8,11 @@ from threading import Lock, Thread as baseThread
|
||||
from errno import EACCES, EAGAIN, EPIPE, ENOTCONN
|
||||
from signal import SIGTERM, SIGKILL
|
||||
from time import sleep
|
||||
from cPickle import PickleError
|
||||
try:
|
||||
from cPickle import PickleError
|
||||
except ImportError:
|
||||
# py 3
|
||||
from pickle import PickleError
|
||||
|
||||
from gconf import gconf
|
||||
|
||||
@ -184,7 +188,7 @@ class FreeObject(object):
|
||||
"""wildcard class for which any attribute can be set"""
|
||||
|
||||
def __init__(self, **kw):
|
||||
for k,v in kw.iteritems():
|
||||
for k,v in kw.items():
|
||||
setattr(self, k, v)
|
||||
|
||||
class Thread(baseThread):
|
||||
@ -210,5 +214,5 @@ class Thread(baseThread):
|
||||
baseThread.__init__(self, *a, **kw)
|
||||
self.setDaemon(True)
|
||||
|
||||
class GsyncdError(StandardError):
|
||||
class GsyncdError(Exception):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user