本文整理汇总了Python中comoonics.ComSystem.execLocalGetResult方法的典型用法代码示例。如果您正苦于以下问题:Python ComSystem.execLocalGetResult方法的具体用法?Python ComSystem.execLocalGetResult怎么用?Python ComSystem.execLocalGetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comoonics.ComSystem
的用法示例。
在下文中一共展示了ComSystem.execLocalGetResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doPre
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def doPre(self):
"""
Unpacks the given file to dest
"""
srcfile=self.getAttribute("name")
destfile=self.getAttribute("dest")
__mkdir=self.getAttributeBoolean("mkdir", default=True)
if not ComSystem.execMethod(os.path.exists, destfile) and __mkdir:
ComLog.getLogger(ArchiveRequirement.__logStrLevel__).debug("Path %s does not exists. I'll create it." % destfile)
os.makedirs(destfile)
if self.check() and not ComSystem.isSimulate():
if not os.access(srcfile, os.R_OK) or not os.access(destfile, os.F_OK) or not os.access(destfile, os.W_OK):
raise ArchiveRequirementException("Either srcfile %s is not readable or dest %s is not writeable" % (srcfile, destfile))
__cmd="rm -rf %s/*" % destfile
(rc, rv) = ComSystem.execLocalGetResult(__cmd)
if rc >> 8 != 0:
raise RuntimeError("running \"%s\" failed: %u, %s" % (__cmd, rc,rv))
self.olddir=os.curdir
ComSystem.execMethod(os.chdir, destfile)
__cmd="gzip -cd %s | cpio -i" % srcfile
(rc, rv, stderr) = ComSystem.execLocalGetResult(__cmd, True)
if rc >> 8 != 0:
raise RuntimeError("running \"%s\" failed: %u, %s, %s" % (__cmd, rc,rv, stderr))
示例2: scanOptions
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def scanOptions(self, device, mountpoint=None):
""" Scans a mountded gfs2 and puts the meta information into the DOM
raises ComException
"""
if mountpoint:
mountpoint=mountpoint.getAttribute("name")
else:
mountpoint = device.scanMountPoint()[0]
if not mountpoint:
raise ComException("device " + device.getDevicePath() + " is not mounted.")
cmd = CMD_GFS2_TOOL + " sb " + device.getDevicePath() + " all"
rc, ret = ComSystem.execLocalGetResult(cmd)
if rc != 0:
raise ComException(cmd + ret)
if ret[0] == ComSystem.SKIPPED:
# Just to keep up working when SIMULATING
self.setAttribute("bsize", "4096")
self.setAttribute("lockproto", "lock_dlm")
self.setAttribute("clustername", "testcluster")
self.setAttribute("journals", "4")
else:
bsize=ComUtils.grepInLines(ret, " sb_bsize = ([0-9]*)")[0]
log.debug("scan Options bsize: " + bsize)
self.setAttribute("bsize", bsize)
lockproto=ComUtils.grepInLines(ret, " sb_lockproto = (.*)")[0]
log.debug("scan Options lockproto: " + lockproto)
self.setAttribute("lockproto", lockproto)
locktable=ComUtils.grepInLines(ret, " sb_locktable = .*?:(.*)")
if len(locktable) == 1:
log.debug("scan Options locktable: " + locktable[0])
self.setAttribute("locktable", locktable[0])
clustername=ComUtils.grepInLines(ret, " sb_locktable = (.*?):.*")
if len(clustername) == 1:
log.debug("scan Options clustername: " +clustername[0])
self.setAttribute("clustername", clustername[0])
# FIXME: Bug in gfs2_tool journals / does not work. Only for bindmounts on /
if mountpoint == "/":
mountpoint = device.scanMountPoint(mountpoint)[0]
cmd = CMD_GFS2_TOOL + " journals " + mountpoint
rc, ret = ComSystem.execLocalGetResult(cmd)
if rc != 0:
raise ComException(cmd + ret)
journals=ComUtils.grepInLines(ret, "^([0-9])+ journal\(s\) found.")[0]
log.debug("scan Options Journals: " +journals)
self.setAttribute("journals", journals)
示例3: scanOptions
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def scanOptions(self, device, mountpoint=None):
""" Scans a mountded gfs and puts the meta information into the DOM
raises ComException
"""
if mountpoint:
__mountpoint=mountpoint.getAttribute("name")
else:
__mountpoint, fstype = device.scanMountPoint()
if not __mountpoint:
raise ComException("device " + device.getDevicePath() + " is not mounted.")
__cmd = CMD_GFS_TOOL + " getsb " + __mountpoint
__rc, __ret = ComSystem.execLocalGetResult(__cmd)
if __rc != 0:
raise ComException(__cmd + __ret)
if __ret[0] == ComSystem.SKIPPED:
# Just to keep up working when SIMULATING
self.setAttribute("bsize", "4096")
self.setAttribute("lockproto", "lock_dlm")
self.setAttribute("clustername", "testcluster")
self.setAttribute("journals", "4")
else:
__bsize=ComUtils.grepInLines(__ret, " sb_bsize = ([0-9]*)")[0]
log.debug("scan Options bsize: " + __bsize)
self.setAttribute("bsize", __bsize)
__lockproto=ComUtils.grepInLines(__ret, " sb_lockproto = (.*)")[0]
log.debug("scan Options lockproto: " + __lockproto)
self.setAttribute("lockproto",__lockproto)
__locktable=ComUtils.grepInLines(__ret, " sb_locktable = .*?:(.*)")
if len(__locktable) == 1:
log.debug("scan Options locktable: " + __locktable[0])
self.setAttribute("locktable", __locktable[0])
__clustername=ComUtils.grepInLines(__ret, " sb_locktable = (.*?):.*")
if len(__clustername) == 1:
log.debug("scan Options clustername: " +__clustername[0])
self.setAttribute("clustername", __clustername[0])
__cmd = CMD_GFS_TOOL + " df " + __mountpoint
__rc, __ret = ComSystem.execLocalGetResult(__cmd)
if __rc != 0:
raise ComException(__cmd + __ret)
__journals=ComUtils.grepInLines(__ret, " Journals = ([0-9]+)")[0]
log.debug("scan Options Journals: " +__journals)
self.setAttribute("journals", __journals)
示例4: extractFile
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def extractFile(self, name, dest):
''' extracts a file or directory from archiv' to destination dest '''
__cmd = TarArchiveHandler.TAR +" "+" ".join(self.getCommandOptions())+" -x " + self.compression + " -f " \
+ self.tarfile + " -C " + dest + " " + name
__rc, __rv = ComSystem.execLocalGetResult(__cmd)
if __rc >> 8 != 0:
raise RuntimeError("running %s failed" %__cmd)
示例5: getLiveCDDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def getLiveCDDevice(self):
_devs=["/dev/cdrom"]
for _dev in _devs:
_cmd="isoinfo -d -i %s | grep COMOONICS" %_dev
_rc, _rv, _err = ComSystem.execLocalGetResult(_cmd, err=True)
if _rc == 0: return [_dev]
return []
示例6: counters
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def counters(self):
#buf=array.array("c")
#buf.fromstring(struct.pack("I", 1))
#buf.fromstring("get_counter")
#buf.fromstring(4096*" ")
#buf.fromstring(struct.pack("I", 4096))
# FIXME: As ioctls don't work jet we'll do it with gfs_tool directly should be ported back sometime
# But Mr. Hl. said pragamtic!!
#buf=struct.pack("I12s513sI", 1, "get_counters", 512*" ", 512)
#self.logger.debug("size of buf: %u" %len(buf))
#fd=os.open(self.mountpoint, os.O_RDONLY)
#if fcntl.ioctl(fd, GFS.GFS_SUPER_IOCTL, buf) != 0:
# self.logger.error("Could not get counters on filesystem %s" %self.mountpoint)
# return -1
#os.close(fd)
#return buf
(_rc,_output)=ComSystem.execLocalGetResult("%s %s %s" %(GFS.GFS_TOOL, GFS.COUNTERS_CMD, self.mountpoint))
_counters=dict()
if _rc != 0:
return _counters
for _line in _output:
_line=_line.strip()
if not _line or _line=="":
continue
_re=GFS.COUNTERS_MATCH_NUMBER.match(_line)
if _re:
_counters[_re.group("key")]=int(_re.group("value"))
else:
_re=GFS.COUNTERS_MATCH_PERCENTAGE.match(_line)
if _re:
_counters[_re.group("key")]=float(_re.group("value"))
else:
self.logger.debug("Could not match line \"%s\"" %_line)
return _counters
示例7: exec_cmd
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def exec_cmd(cmd, key=None):
import sys
if not key:
key=cmd
try:
from comoonics import ComSystem
(rc, out, err)=ComSystem.execLocalGetResult(cmd, True, cmds.get("key", dict()).get("simoutput", None), cmds.get("key", dict()).get("simerror", None))
except ImportError:
if sys.version[:3] < "2.4":
import popen2
child=popen2.Popen3(cmd, err)
rc=child.wait()
out=child.fromchild.readlines()
err=child.childerr.readlines()
else:
import subprocess
p = subprocess.Popen([cmd], shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=True)
p.wait()
rc=p.returncode
out=p.stdout.readlines()
err=p.stderr.readlines()
if cmds.has_key(key):
cmds[key]["executed"]=True
cmds[key]["rc"]=rc
cmds[key]["output"]=out
cmds[key]["error"]=err
if rc==0:
return out
else:
raise IOError("Could not execute cmd %s. Errorcode: %u, Output: %s, Error: %s" %(cmd, rc, out, err))
示例8: findLabel
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def findLabel(self, label):
""" try to find Device with label
returns Device
"""
import ComDevice
__cmd="/sbin/findfs LABEL=" + label
__rc, __path = ComSystem.execLocalGetResult(__cmd)
if not __rc:
raise ComException("device with label " + label + "not found")
return ComDevice.Device(__path[0])
示例9: countersValues
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def countersValues(self):
_counters=self.counters()
(_rc,_output)=ComSystem.execLocalGetResult("date +\"%F-%H-%M-%S\"")
_time=_output
_output=_output[0].splitlines()[0]
buf=_output+","
for _value in _counters.values():
buf+=str(_value)+","
return buf[:-1]
示例10: createArchive
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def createArchive(self, source, cdir=None):
''' creates an archive from the whole source tree
stays in the same filesystem
'''
if not cdir:
cdir=os.getcwd()
__cmd = TarArchiveHandler.TAR +" "+" ".join(self.getCommandOptions())+" -c --one-file-system " + self.compression + " -f " \
+ self.tarfile + " -C " + cdir + " " + source
__rc, __rv = ComSystem.execLocalGetResult(__cmd)
if __rc >> 8 != 0:
raise RuntimeError("running %s failed" %__cmd)
示例11: hasPartitionTable
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def hasPartitionTable(self):
""" checks wether the disk has a partition table or not """
#__cmd = CMD_SFDISK + " -Vq " + self.getDeviceName() + " >/dev/null 2>&1"
#if ComSystem.execLocal(__cmd):
# return False
#return True
__cmd = CMD_SFDISK + " -l " + self.getDeviceName()
rc, std, err = ComSystem.execLocalGetResult(__cmd, True)
if rc!=0:
return False
if (" ".join(err).upper().find("ERROR")) > 0:
return False
return True
示例12: doPost
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def doPost(self):
"""
Does something afterwards
"""
srcfile=self.getAttribute("name")
destfile=self.getAttribute("dest")
if self.check() and not ComSystem.isSimulate():
if not os.access(srcfile, os.R_OK) or not os.access(destfile, os.F_OK) or not os.access(destfile, os.W_OK):
raise ArchiveRequirementException("Either srcfile %s is not readable or dest %s is not writeable" % (srcfile, destfile))
ComSystem.execMethod(os.chdir, destfile)
__cmd="cp %s %s" %(srcfile, srcfile+self.getAttribute("bak_suffix", ".bak"))
try:
(rc, rv, stderr) = ComSystem.execLocalGetResult(__cmd, True)
if rc >> 8 != 0:
raise RuntimeError("running \"%s\" failed: %u, %s, errors: %s" % (__cmd, rc,rv, stderr))
except RuntimeError, re:
ComLog.getLogger(ArchiveRequirement.__logStrLevel__).warn("Cannot backup sourcefile %s=%s, %s." %(srcfile, srcfile+".bak", re))
示例13: doRealModifications
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def doRealModifications(self):
import xml.dom
import StringIO
if self.hasAttribute("command"):
__cmd=self.getAttribute("command")
else:
buf=StringIO.StringIO()
element=self.getElement()
child=element.firstChild
while child != None:
if child.nodeType==xml.dom.Node.TEXT_NODE:
buf.write(child.data)
child=child.nextSibling
__cmd=buf.getvalue()
__rc, __ret, __err = ComSystem.execLocalGetResult(__cmd, True)
if __rc:
raise ComException(__cmd + ": out:" + " ".join(__ret) + \
" err: " + " ".join(__err))
else:
ComLog.getLogger("ExecutionModification").debug(__cmd + ": return:" + " ".join(__ret) + \
" err: " + " ".join(__err))
示例14: testExecLocalGetResultErrSim
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def testExecLocalGetResultErrSim(self):
ComSystem.setExecMode(ComSystem.SIMULATE)
result = ComSystem.execLocalGetResult(self.cmd1, True, self.cmd1_simout, self.cmd1_simerr)
self.assertEquals(result, self.cmd1_sim_result[3])
示例15: testExecLocalGetResultSim
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalGetResult [as 别名]
def testExecLocalGetResultSim(self):
ComSystem.setExecMode(ComSystem.SIMULATE)
result = ComSystem.execLocalGetResult(self.cmd1, False, self.cmd1_simout)
self.assertEquals(result, self.cmd1_sim_result[2])