本文整理汇总了Python中execcmd.ExecCmd类的典型用法代码示例。如果您正苦于以下问题:Python ExecCmd类的具体用法?Python ExecCmd怎么用?Python ExecCmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExecCmd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getCurrentTheme
def getCurrentTheme():
curTheme = ['']
if getCurrentResolution() != '':
cmd = '/usr/sbin/plymouth-set-default-theme'
ec = ExecCmd(log)
curTheme = ec.run(cmd, False)
return curTheme[0]
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:7,代码来源:functions.py
示例2: getLinuxHeadersAndImage
def getLinuxHeadersAndImage(getLatest=False, includeLatestRegExp='', excludeLatestRegExp=''):
returnList = []
lhList = []
ec = ExecCmd(log)
if getLatest:
lst = ec.run('aptitude search linux-headers', False)
for item in lst:
lhMatch = re.search('linux-headers-\d+\.[a-zA-Z0-9-\.]*', item)
if lhMatch:
lh = lhMatch.group(0)
addLh = True
if includeLatestRegExp != '':
inclMatch = re.search(includeLatestRegExp, lh)
if not inclMatch:
addLh = False
if excludeLatestRegExp != '':
exclMatch = re.search(excludeLatestRegExp, lh)
if exclMatch:
addLh = False
# Append to list
if addLh:
lhList.append(lh)
else:
# Get the current linux header package
linHeader = ec.run("echo linux-headers-$(uname -r)", False)
lhList.append(linHeader[0])
# Sort the list and add the linux-image package name
if lhList:
lhList.sort(reverse=True)
returnList.append(lhList[0])
returnList.append('linux-image-' + lhList[0][14:])
return returnList
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:34,代码来源:functions.py
示例3: getLatestLunuxHeader
def getLatestLunuxHeader(includeString='', excludeString=''):
lhList = []
ec = ExecCmd(log)
list = ec.run('apt search linux-headers', False)
startIndex = 14
for item in list:
lhMatch = re.search('linux-headers-\d[a-zA-Z0-9-\.]*', item)
if lhMatch:
lh = lhMatch.group(0)
addLh = True
if includeString != '':
inclMatch = re.search(includeString, lh)
if inclMatch:
if excludeString != '':
exclMatch = re.search(excludeString, lh)
if exclMatch:
addLh = False
else:
addLh = False
# Append to list
if addLh:
lhList.append(lh)
lhList.sort(reverse=True)
return lhList[0]
开发者ID:AlbertJP,项目名称:device-driver-manager,代码行数:25,代码来源:functions.py
示例4: killProcessByName
def killProcessByName(processName):
killed = False
ec = ExecCmd(log)
lst = ec.run('killall %s' % processName)
if len(lst) == 0:
killed = True
return killed
开发者ID:0rakul,项目名称:updatemanager,代码行数:7,代码来源:functions.py
示例5: isPackageInstalled
def isPackageInstalled(packageName, alsoCheckVersion=True):
isInstalled = False
try:
cmd = 'dpkg-query -l %s | grep ^i' % packageName
if '*' in packageName:
cmd = 'aptitude search %s | grep ^i' % packageName
ec = ExecCmd(log)
pckList = ec.run(cmd, False)
for line in pckList:
matchObj = re.search('([a-z]+)\s+([a-z0-9\-_\.]*)', line)
if matchObj:
if matchObj.group(1)[:1] == 'i':
if alsoCheckVersion:
cache = apt.Cache()
pkg = cache[matchObj.group(2)]
if pkg.installed.version == pkg.candidate.version:
isInstalled = True
break
else:
isInstalled = True
break
if isInstalled:
break
except:
pass
return isInstalled
开发者ID:0rakul,项目名称:updatemanager,代码行数:26,代码来源:functions.py
示例6: getPackageStatus
def getPackageStatus(packageName):
status = ''
try:
cmdChk = 'apt-cache policy ' + str(packageName)
ec = ExecCmd(log)
packageCheck = ec.run(cmdChk, False)
for line in packageCheck:
instChk = re.search('installed:.*\d.*', line.lower())
if not instChk:
instChk = re.search('installed.*', line.lower())
if instChk:
# Package is not installed
log.write('Package not installed: ' + str(packageName), 'drivers.getPackageStatus', 'debug')
status = packageStatus[1]
break
else:
# Package is installed
log.write('Package is installed: ' + str(packageName), 'drivers.getPackageStatus', 'debug')
status = packageStatus[0]
break
# Package is not found: uninstallable
if not status:
log.write('Package not found: ' + str(packageName), 'drivers.getPackageStatus', 'warning')
status = packageStatus[2]
except:
# If something went wrong: assume that package is uninstallable
log.write('Could not get status info for package: ' + str(packageName), 'drivers.getPackageStatus', 'error')
status = packageStatus[2]
return status
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:31,代码来源:functions.py
示例7: DistroGeneral
class DistroGeneral(object):
def __init__(self, distroPath):
self.ec = ExecCmd()
distroPath = distroPath.rstrip('/')
if basename(distroPath) == "root":
distroPath = dirname(distroPath)
self.distroPath = distroPath
self.rootPath = join(distroPath, "root")
self.edition = basename(distroPath)
self.description = "SolydXK"
infoPath = join(self.rootPath, "etc/solydxk/info")
if exists(infoPath):
self.edition = self.ec.run(cmd="grep EDITION= \"{}\" | cut -d'=' -f 2".format(infoPath), returnAsList=False).strip('"')
self.description = self.ec.run(cmd="grep DESCRIPTION= \"{}\" | cut -d'=' -f 2".format(infoPath), returnAsList=False).strip('"')
def getIsoFileName(self):
# Get the date string
d = datetime.now()
serial = d.strftime("%Y%m")
# Check for a localized system
localePath = join(self.rootPath, "etc/default/locale")
if exists(localePath):
locale = self.ec.run(cmd="grep LANG= {}".format(localePath), returnAsList=False).strip('"').replace(" ", "")
matchObj = re.search("\=\s*([a-z]{2})", locale)
if matchObj:
language = matchObj.group(1)
if language != "en":
serial += "_{}".format(language)
isoFileName = "{}_{}.iso".format(self.description.lower().replace(' ', '_').split('-')[0], serial)
return isoFileName
开发者ID:xaosfiftytwo,项目名称:solydxk-constructor,代码行数:31,代码来源:solydxk.py
示例8: getDivertedFiles
def getDivertedFiles(mustContain=None):
divertedFiles = []
cmd = 'dpkg-divert --list'
if mustContain:
cmd = 'dpkg-divert --list | grep %s | cut -d' ' -f3' % mustContain
ec = ExecCmd(log)
divertedFiles = ec.run(cmd, False)
return divertedFiles
开发者ID:0rakul,项目名称:updatemanager,代码行数:8,代码来源:functions.py
示例9: previewPlymouth
def previewPlymouth():
cmd = "su -c 'plymouthd; plymouth --show-splash ; for ((I=0; I<10; I++)); do plymouth --update=test$I ; sleep 1; done; plymouth quit'"
log.write('Preview command: ' + cmd, 'drivers.previewPlymouth', 'debug')
try:
ec = ExecCmd(log)
ec.run(cmd, False)
except Exception, detail:
log.write(detail, 'drivers.previewPlymouth', 'error')
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:8,代码来源:functions.py
示例10: isProcessRunning
def isProcessRunning(processName):
isProc = False
cmd = 'ps -C ' + processName
ec = ExecCmd(log)
procList = ec.run(cmd, False)
if procList:
if len(procList) > 1:
isProc = True
return isProc
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:9,代码来源:functions.py
示例11: getDistribution
def getDistribution():
distribution = ''
try:
cmdDist = 'cat /etc/*-release | grep DISTRIB_CODENAME'
ec = ExecCmd(log)
dist = ec.run(cmdDist, False)[0]
distribution = dist[dist.find('=') + 1:]
except Exception, detail:
log.write(detail, 'functions.getDistribution', 'error')
开发者ID:AlbertJP,项目名称:device-driver-manager,代码行数:9,代码来源:functions.py
示例12: getSystemVersionInfo
def getSystemVersionInfo():
info = ''
try:
ec = ExecCmd(log)
infoList = ec.run('cat /proc/version', False)
if infoList:
info = infoList[0]
except Exception, detail:
log.write(detail, 'functions.getSystemVersionInfo', 'error')
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:9,代码来源:functions.py
示例13: isPackageInstalled
def isPackageInstalled(packageName):
isInstalled = False
cmd = 'aptitude search ' + packageName + ' | grep ^i'
ec = ExecCmd(log)
packageList = ec.run(cmd, False)
if packageList:
if len(packageList) > 0:
isInstalled = True
return isInstalled
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:9,代码来源:functions.py
示例14: getDistributionDescription
def getDistributionDescription():
distribution = ''
try:
cmdDist = 'cat /etc/*-release | grep DISTRIB_DESCRIPTION'
ec = ExecCmd(log)
dist = ec.run(cmdDist, False)[0]
distribution = dist[dist.find('=') + 1:]
distribution = string.replace(distribution, '"', '')
except Exception, detail:
log.write(detail, 'functions.getDistributionDescription', 'error')
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:10,代码来源:functions.py
示例15: getVideoCards
def getVideoCards(pciId=None):
videoCard = []
cmdVideo = 'lspci -nn | grep VGA'
ec = ExecCmd(log)
hwVideo = ec.run(cmdVideo, False)
for line in hwVideo:
videoMatch = re.search(':\s(.*)\[(\w*):(\w*)\]', line)
if videoMatch and (pciId is None or pciId.lower() + ':' in line.lower()):
videoCard.append([videoMatch.group(1), videoMatch.group(2), videoMatch.group(3)])
return videoCard
开发者ID:0rakul,项目名称:updatemanager,代码行数:10,代码来源:functions.py
示例16: getGraphicsCard
def getGraphicsCard():
global graphicsCard
if graphicsCard is None:
cmdGraph = 'lspci | grep VGA'
ec = ExecCmd(log)
hwGraph = ec.run(cmdGraph, False)
for line in hwGraph:
graphicsCard = line[line.find(': ') + 2:]
break
return graphicsCard
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:10,代码来源:functions.py
示例17: getPackagesWithFile
def getPackagesWithFile(fileName):
packages = []
if len(fileName) > 0:
cmd = 'dpkg -S %s' % fileName
ec = ExecCmd(log)
packageList = ec.run(cmd, False)
for package in packageList:
if '*' not in package:
packages.append(package[:package.find(':')])
return packages
开发者ID:0rakul,项目名称:updatemanager,代码行数:10,代码来源:functions.py
示例18: getDefaultTerminal
def getDefaultTerminal():
terminal = None
cmd = "update-alternatives --display x-terminal-emulator"
ec = ExecCmd(log)
terminalList = ec.run(cmd, False)
for line in terminalList:
reObj = re.search("\'(\/.*)\'", line)
if reObj:
terminal = reObj.group(1)
return terminal
开发者ID:0rakul,项目名称:updatemanager,代码行数:10,代码来源:functions.py
示例19: isFileLocked
def isFileLocked(path):
locked = False
cmd = 'lsof %s' % path
ec = ExecCmd(log)
lsofList = ec.run(cmd, False)
for line in lsofList:
if path in line:
locked = True
break
return locked
开发者ID:0rakul,项目名称:updatemanager,代码行数:10,代码来源:functions.py
示例20: getPackageVersion
def getPackageVersion(packageName):
version = ''
cmd = 'apt-cache policy ' + packageName + ' | grep Installed'
ec = ExecCmd(log)
versionList = ec.run(cmd, False)
for line in versionList:
versionObj = re.search(':\s(.*)', line.lower())
if versionObj:
version = versionObj.group(1)
return version
开发者ID:linuxer9,项目名称:device-driver-manager,代码行数:11,代码来源:functions.py
注:本文中的execcmd.ExecCmd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论