本文整理汇总了Python中repce.RepceClient.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python RepceClient.__version__方法的具体用法?Python RepceClient.__version__怎么用?Python RepceClient.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repce.RepceClient
的用法示例。
在下文中一共展示了RepceClient.__version__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SlaveRemote
# 需要导入模块: from repce import RepceClient [as 别名]
# 或者: from repce.RepceClient import __version__ [as 别名]
class SlaveRemote(object):
"""mix-in class to implement an interface to a remote slave"""
def connect_remote(self, rargs=[], **opts):
"""connects to a remote slave
Invoke an auxiliary utility (slave gsyncd, possibly wrapped)
which sets up the connection and set up a RePCe client to
communicate throuh its stdio.
"""
slave = opts.get('slave', self.url)
extra_opts = []
so = getattr(gconf, 'session_owner', None)
if so:
extra_opts += ['--session-owner', so]
if boolify(gconf.use_rsync_xattrs):
extra_opts.append('--use-rsync-xattrs')
po = Popen(rargs + gconf.remote_gsyncd.split() + extra_opts + \
['-N', '--listen', '--timeout', str(gconf.timeout), slave],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
gconf.transport = po
return self.start_fd_client(po.stdout, po.stdin, **opts)
def start_fd_client(self, i, o, **opts):
"""set up RePCe client, handshake with server
It's cut out as a separate method to let
subclasses hook into client startup
"""
self.server = RepceClient(i, o)
rv = self.server.__version__()
exrv = {'proto': repce.repce_version, 'object': Server.version()}
da0 = (rv, exrv)
da1 = ({}, {})
for i in range(2):
for k, v in da0[i].iteritems():
da1[i][k] = int(v)
if da1[0] != da1[1]:
raise GsyncdError("RePCe major version mismatch: local %s, remote %s" % (exrv, rv))
def rsync(self, files, *args):
"""invoke rsync"""
if not files:
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
argv = gconf.rsync_command.split() + \
['-aR0', '--files-from=-', '--super','--stats', '--numeric-ids', '--no-implied-dirs'] + \
gconf.rsync_options.split() + (boolify(gconf.use_rsync_xattrs) and ['--xattrs'] or []) + \
['.'] + list(args)
po = Popen(argv, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
for f in files:
po.stdin.write(f)
po.stdin.write('\0')
po.stdin.close()
po.wait()
po.terminate_geterr(fail_on_err = False)
return po
示例2: SlaveRemote
# 需要导入模块: from repce import RepceClient [as 别名]
# 或者: from repce.RepceClient import __version__ [as 别名]
class SlaveRemote(object):
"""mix-in class to implement an interface to a remote slave"""
def connect_remote(self, rargs=[], **opts):
"""connects to a remote slave
Invoke an auxiliary utility (slave gsyncd, possibly wrapped)
which sets up the connection and set up a RePCe client to
communicate throuh its stdio.
"""
slave = opts.get("slave", self.url)
so = getattr(gconf, "session_owner", None)
if so:
so_args = ["--session-owner", so]
else:
so_args = []
po = Popen(
rargs + gconf.remote_gsyncd.split() + so_args + ["-N", "--listen", "--timeout", str(gconf.timeout), slave],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
gconf.transport = po
return self.start_fd_client(po.stdout, po.stdin, **opts)
def start_fd_client(self, i, o, **opts):
"""set up RePCe client, handshake with server
It's cut out as a separate method to let
subclasses hook into client startup
"""
self.server = RepceClient(i, o)
rv = self.server.__version__()
exrv = {"proto": repce.repce_version, "object": Server.version()}
da0 = (rv, exrv)
da1 = ({}, {})
for i in range(2):
for k, v in da0[i].iteritems():
da1[i][k] = int(v)
if da1[0] != da1[1]:
raise GsyncdError("RePCe major version mismatch: local %s, remote %s" % (exrv, rv))
def rsync(self, files, *args):
"""invoke rsync"""
if not files:
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
argv = (
gconf.rsync_command.split()
+ ["-aR", "--super", "--numeric-ids", "--no-implied-dirs"]
+ gconf.rsync_options.split()
+ files
+ list(args)
)
po = Popen(argv, stderr=subprocess.PIPE)
po.wait()
po.terminate_geterr(fail_on_err=False)
return po
示例3: SlaveRemote
# 需要导入模块: from repce import RepceClient [as 别名]
# 或者: from repce.RepceClient import __version__ [as 别名]
class SlaveRemote(object):
def connect_remote(self, rargs=[], **opts):
slave = opts.get('slave', self.url)
ix, ox = os.pipe()
iy, oy = os.pipe()
pid = os.fork()
if not pid:
os.close(ox)
os.dup2(ix, sys.stdin.fileno())
os.close(iy)
os.dup2(oy, sys.stdout.fileno())
so = getattr(gconf, 'session_owner', None)
if so:
so_args = ['--session-owner', so]
else:
so_args = []
argv = rargs + gconf.remote_gsyncd.split() + so_args + \
['-N', '--listen', '--timeout', str(gconf.timeout), slave]
os.execvp(argv[0], argv)
os.close(ix)
os.close(oy)
return self.start_fd_client(iy, ox, **opts)
def start_fd_client(self, i, o, **opts):
self.server = RepceClient(i, o)
rv = self.server.__version__()
exrv = {'proto': repce.repce_version, 'object': Server.version()}
da0 = (rv, exrv)
da1 = ({}, {})
for i in range(2):
for k, v in da0[i].iteritems():
da1[i][k] = int(v)
if da1[0] != da1[1]:
raise GsyncdError("RePCe major version mismatch: local %s, remote %s" % (exrv, rv))
def rsync(self, files, *args):
if not files:
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
argv = gconf.rsync_command.split() + gconf.rsync_extra.split() + ['-aR'] + files + list(args)
return os.spawnvp(os.P_WAIT, argv[0], argv) == 0
示例4: SlaveRemote
# 需要导入模块: from repce import RepceClient [as 别名]
# 或者: from repce.RepceClient import __version__ [as 别名]
class SlaveRemote(object):
"""mix-in class to implement an interface to a remote slave"""
def connect_remote(self, rargs=[], **opts):
"""connects to a remote slave
Invoke an auxiliary utility (slave gsyncd, possibly wrapped)
which sets up the connection and set up a RePCe client to
communicate throuh its stdio.
"""
slave = opts.get('slave', self.url)
extra_opts = []
so = getattr(gconf, 'session_owner', None)
if so:
extra_opts += ['--session-owner', so]
if boolify(gconf.use_rsync_xattrs):
extra_opts.append('--use-rsync-xattrs')
po = Popen(rargs + gconf.remote_gsyncd.split() + extra_opts +
['-N', '--listen', '--timeout', str(gconf.timeout),
slave],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
gconf.transport = po
return self.start_fd_client(po.stdout, po.stdin, **opts)
def start_fd_client(self, i, o, **opts):
"""set up RePCe client, handshake with server
It's cut out as a separate method to let
subclasses hook into client startup
"""
self.server = RepceClient(i, o)
rv = self.server.__version__()
exrv = {'proto': repce.repce_version, 'object': Server.version()}
da0 = (rv, exrv)
da1 = ({}, {})
for i in range(2):
for k, v in da0[i].iteritems():
da1[i][k] = int(v)
if da1[0] != da1[1]:
raise GsyncdError(
"RePCe major version mismatch: local %s, remote %s" %
(exrv, rv))
def rsync(self, files, *args):
"""invoke rsync"""
if not files:
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
argv = gconf.rsync_command.split() + \
['-avR0', '--inplace', '--files-from=-', '--super',
'--stats', '--numeric-ids', '--no-implied-dirs'] + \
gconf.rsync_options.split() + \
(boolify(gconf.use_rsync_xattrs) and ['--xattrs'] or []) + \
['.'] + list(args)
po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
for f in files:
po.stdin.write(f)
po.stdin.write('\0')
po.stdin.close()
po.wait()
po.terminate_geterr(fail_on_err=False)
return po
def tarssh(self, files, slaveurl):
"""invoke tar+ssh
-z (compress) can be use if needed, but ommitting it now
as it results in wierd error (tar+ssh errors out (errcode: 2)
"""
if not files:
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
(host, rdir) = slaveurl.split(':')
tar_cmd = ["tar", "-cf", "-", "--files-from", "-"]
ssh_cmd = gconf.ssh_command_tar.split() + \
[host, "tar", "--overwrite", "-xf", "-", "-C", rdir]
p0 = Popen(tar_cmd, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = Popen(ssh_cmd, stdin=p0.stdout, stderr=subprocess.PIPE)
for f in files:
p0.stdin.write(f)
p0.stdin.write('\n')
p0.stdin.close()
# wait() for tar to terminate, collecting any errors, further
# waiting for transfer to complete
p0.wait()
p0.terminate_geterr(fail_on_err=False)
p1.wait()
p1.terminate_geterr(fail_on_err=False)
return p1