Merge branch 'master' of git.calculate.ru:/calculate-lib

develop
Самоукин Алексей 14 years ago
commit 2cc5ecd294

@ -900,3 +900,18 @@ class fillVars(glob_attr):
return "vmware"
else:
return "vesa"
def get_cl_kernel_uid(self):
uuidpath = '/dev/disk/by-uuid'
if not os.access(uuidpath,os.R_OK):
return ""
uuidDevs = filter(os.path.islink,map(lambda x: os.path.join(uuidpath,x),
os.listdir(uuidpath)))
mapDevUuid = dict(map(lambda x:(os.path.normpath(os.path.join(uuidpath,
os.readlink(x))),
os.path.basename(x)),
uuidDevs))
if self.Get('os_root_dev') in mapDevUuid:
return mapDevUuid[self.Get('os_root_dev')][:8]
else:
return ""

@ -151,31 +151,44 @@ class scanDirectory:
class process:
"""Execute system command by Popen
Example:
#execute program and get result
Examples:
execute program and get result:
if process("/bin/gzip","/boot/somefile").success():
print "Gzip success"
#unzip and process unzip data by cpio (list files)
unzip and process unzip data by cpio (list files):
processGzip = process("/bin/gzip","-dc","/boot/initrd")
processCpio = process("/bin/cpio","-tf",stdin=processGzip)
filelist = processCpio.readlines()
#execute command and send data
execute command and send data:
processGrub = process("/sbin/grub")
processGrub.write("root (hd0,0)\n")
processGrub.write("setup (hd0)\n")
processGrub.write("quit\n")
isok = processGrub.success()
#union stdout and stderr
union stdout and stderr:
process("/bin/ls","/",stderr=STDOUT)
result to stdout:
process("/bin/ls",stdout=None)
get data from keyboard:
process("/bin/cat",stdin=None)
"""
def __init__(self,command,*params,**kwarg):
if not "stdin" in kwarg:
stdin=self._defaultStdin
else:
stdin=kwarg["stdin"].getStdout
if kwarg["stdin"] == None:
stdin = self._keyboardStdin
else:
stdin=kwarg["stdin"].getStdout
self.stdout = kwarg.get("stdout",PIPE)
self.envdict = kwarg.get("envdict",None)
self.stderr = kwarg.get("stderr",PIPE)
self.command = [command] + list(params)
self.stdin = stdin
@ -188,14 +201,19 @@ class process:
"""Open pipe if it not open"""
if not self.pipe:
self.pipe = Popen(self.command,
stdout=PIPE,
stdout=self.stdout,
stdin=self.stdin(),
stderr=self.stderr)
stderr=self.stderr,
env=self.envdict)
def _defaultStdin(self):
"""Return default stdin"""
return PIPE
def _keyboardStdin(self):
"""Return keyboard stdin"""
return None
def getStdout(self):
"""Get current stdout"""
self.close()

@ -147,6 +147,8 @@ class Data:
# user email
ur_mail = {'official':True}
# kernel uid get by uuid root device
cl_kernel_uid = {}
# variable for calculate-client and calculate-desktop packages
# ip or domain name of CDS
cl_remote_host = {'mode':'r', 'official':True}

Loading…
Cancel
Save