Добавлена совместимость с rsync 3.1.0

develop 3.3.0.3
Mike Khiretskiy 9 years ago
parent ee3cc1cf05
commit d1ad78ea30

@ -70,13 +70,20 @@ class RsyncProgressBar:
maximum = 1
copyStarting = False
def __init__(self, title, secondtitle, rsyncstr, parent,maximum=1):
def __init__(self, title, secondtitle, rsyncstr, parent,maximum=1,
rsyncver="3.0.9"):
self.title = title
self.secondtitle = secondtitle
self.maximum = maximum
self.rsyncstr = rsyncstr
self.parent = parent
self.value = 0
if cmpVersion(rsyncver, "3.1.0") >= 0:
self.extraopts = " --msgs2stderr"
self.use_stderr = True
else:
self.extraopts = ""
self.use_stderr = False
def getFilesNum(self):
"""
@ -105,12 +112,16 @@ class RsyncProgressBar:
"""
Run rsync without progressbar
"""
self.pipe = subprocess.Popen(self.rsyncstr, stdin=subprocess.PIPE,
self.pipe = subprocess.Popen(self.rsyncstr+self.extraopts,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True, shell=True)
while True:
s = self.pipe.stdout.readline()
if self.use_stderr:
s = self.pipe.stderr.readline()
else:
s = self.pipe.stdout.readline()
if len(s) == 0:
break
q = self.receiverre.search(s)
@ -122,13 +133,17 @@ class RsyncProgressBar:
Run rsync with progressbar
"""
self.parent.startTask(self.title,progress=True)
self.pipe = subprocess.Popen(self.rsyncstr, stdin=subprocess.PIPE,
self.pipe = subprocess.Popen(self.rsyncstr+self.extraopts,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True, shell=True)
oldpercent = 0
while True:
s = self.pipe.stdout.readline()
if self.use_stderr:
s = self.pipe.stderr.readline()
else:
s = self.pipe.stdout.readline()
if len(s) == 0:
break
q = self.receiverre.search(s)
@ -338,12 +353,12 @@ class Client(commandServer, encrypt, Desktop):
rsync = RsyncProgressBar(\
_("Fetching the file list from %s") % host,
_("Fetching the user profile from %s") % host,
execStr,self)
execStr,self, rsyncver=self.clVars.Get('cl_rsync_ver'))
else:
rsync = RsyncProgressBar(\
_("Sending the file list to %s") % host,
_("Uploading the user profile to %s") % host,
execStr,self)
execStr,self, rsyncver=self.clVars.Get('cl_rsync_ver'))
pathConfig = os.path.join(remoteProfile,
self.pathConfig)
# remove old ini file

@ -23,6 +23,7 @@ from calculate.lib.datavars import (Variable,VariableError,ReadonlyVariable,
from calculate.lib.cl_template import iniParser
from calculate.lib.utils.files import readLinesFile,isMount,readFile, find
from calculate.lib.utils.common import getValueFromCmdLine,cmpVersion
from calculate.lib.utils.portage import isPkgInstalled
from calculate.lib.variables.user import VariableUrLogin
from calculate.lib.convertenv import convertEnv
from calculate.lib.utils.ip import isOpenPort
@ -666,3 +667,13 @@ class VariableClCifsVer(ReadonlyVariable):
"""
def get(self):
return readFile("/sys/module/cifs/version")
class VariableClRsyncVer(ReadonlyVariable):
"""
Версия rsync
"""
def get(self):
data = isPkgInstalled('net-misc/rsync')
if data:
return data[0]['PVR']
return ""

Loading…
Cancel
Save