本文整理汇总了Python中sub_process.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_triggers
def run_triggers(ref, globber):
"""
Runs all the trigger scripts in a given directory.
ref can be a certmaster object, if not None, the name will be passed
to the script. If ref is None, the script will be called with
no argumenets. Globber is a wildcard expression indicating which
triggers to run. Example: "/var/lib/certmaster/triggers/blah/*"
"""
log = logger.Logger().logger
triggers = glob.glob(globber)
triggers.sort()
for file in triggers:
log.debug("Executing trigger: %s" % file)
try:
if file.find(".rpm") != -1:
# skip .rpmnew files that may have been installed
# in the triggers directory
continue
if ref:
rc = sub_process.call([file, ref], shell=False)
else:
rc = sub_process.call([file], shell=False)
except:
log.warning("Warning: failed to execute trigger: %s" % file)
continue
if rc != 0:
raise codes.CMException, "certmaster trigger failed: %(file)s returns %(code)d" % { "file" : file, "code" : rc }
开发者ID:mpdehaan,项目名称:certmaster,代码行数:29,代码来源:utils.py
示例2: autostart
def autostart(self, vm):
self.conn = self.__get_conn()
if self.conn.get_type() == "Xen":
autostart_args = [
"/bin/ln",
"-s",
"/etc/xen/%s" % vm,
"/etc/xen/auto"
]
else:
# When using KVM, we need to make sure the autostart
# directory exists
mkdir_args = [
"/bin/mkdir",
"-p",
"/etc/libvirt/qemu/autostart"
]
sub_process.call(mkdir_args,shell=False,close_fds=True)
# We aren't using virsh autostart because we want
# the command to work even when the VM isn't running
autostart_args = [
"/bin/ln",
"-s",
"/etc/libvirt/qemu/%s.xml" % vm,
"/etc/libvirt/qemu/autostart/%s.xml" % vm
]
return sub_process.call(autostart_args,shell=False,close_fds=True)
开发者ID:caglar10ur,项目名称:func,代码行数:29,代码来源:virt.py
示例3: __init__
def __init__(self, logfile="/var/log/cobbler/cobbler.log"):
# Main logfile is append mode, other logfiles not.
if not os.path.exists(logfile):
self.logfile = open(logfile, "a")
sub_process.call("chown apache %s" % logfile, shell=True)
self.logfile.close()
if logfile.find("tasks") != -1:
self.logfile = open(logfile, "w+")
else:
self.logfile = open(logfile, "a")
开发者ID:GunioRobot,项目名称:cobbler,代码行数:11,代码来源:clogger.py
示例4: createrepo_walker
def createrepo_walker(self, repo, dirname, fnames):
"""
Used to run createrepo on a copied Yum mirror.
"""
if os.path.exists(dirname) or repo['breed'] == 'rsync':
utils.remove_yum_olddata(dirname)
try:
cmd = "createrepo %s %s" % (repo.createrepo_flags, dirname)
print _("- %s") % cmd
sub_process.call(cmd, shell=True, close_fds=True)
except:
print _("- createrepo failed. Is it installed?")
del fnames[:] # we're in the right place
开发者ID:icontender,项目名称:cobbler,代码行数:13,代码来源:action_reposync.py
示例5: scp_it
def scp_it(self,from_path,to_path):
from_path = "%s:%s" % (self.host, from_path)
cmd = "scp %s %s" % (from_path, to_path)
print _("- %s") % cmd
rc = sub_process.call(cmd, shell=True, close_fds=True)
if rc !=0:
raise CX(_("scp failed"))
开发者ID:icontender,项目名称:cobbler,代码行数:7,代码来源:action_replicate.py
示例6: __command
def __command(self, service_name, command):
filename = os.path.join("/etc/rc.d/init.d/",service_name)
if os.path.exists(filename):
return sub_process.call(["/sbin/service", service_name, command])
else:
raise codes.FuncException("Service not installed: %s" % service_name)
开发者ID:lmacken,项目名称:func,代码行数:7,代码来源:service.py
示例7: deploy
def deploy(api, system, virt_host=None, virt_group=None):
"""
Deploy the current system to the virtual host or virtual group
"""
if virt_host is None and virt_group is not None:
virt_host = __find_host(api, virt_group)
if virt_host is None and system.virt_group == "":
virt_host = __find_host(api, system.virt_group)
if system.virt_host != "":
virt_host = system.virt_host
if virt_host is None:
raise CX("No host specified for deployment.")
virt_host = api.find_system(virt_host)
if virt_host is None:
raise CX("Unable to find cobbler system record for virt-host (%s)" % virt_host)
if virt_host.hostname == "":
raise CX("Hostname for cobbler system (%s) not set" % virt_host.name)
me = api.settings().server
cmd = ["/usr/bin/ssh", virt_host.hostname, "koan", "--server", me, "--virt", "--system", system.name]
print "- %s" % " ".join(cmd)
rc = sub_process.call(cmd, shell=False)
if rc != 0:
raise CX("remote deployment failed")
return virt_host.name
开发者ID:javiplx,项目名称:cobbler-debian,代码行数:31,代码来源:deploy_ssh.py
示例8: rsync_sync
def rsync_sync(self, repo):
"""
Handle copying of rsync:// and rsync-over-ssh repos.
"""
repo_mirror = repo.mirror
if not repo.mirror_locally:
raise CX(_("rsync:// urls must be mirrored locally, yum cannot access them directly"))
if repo.rpm_list != "":
print _("- warning: --rpm-list is not supported for rsync'd repositories")
# FIXME: don't hardcode
dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
spacer = ""
if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
spacer = "-e ssh"
if not repo.mirror.endswith("/"):
repo.mirror = "%s/" % repo.mirror
cmd = "rsync -rltDv %s --delete --delete-excluded --exclude-from=/etc/cobbler/rsync.exclude %s %s" % (spacer, repo.mirror, dest_path)
print _("- %s") % cmd
rc = sub_process.call(cmd, shell=True, close_fds=True)
if rc !=0:
raise CX(_("cobbler reposync failed"))
print _("- walking: %s") % dest_path
os.path.walk(dest_path, self.createrepo_walker, repo)
self.create_local_file(dest_path, repo)
开发者ID:icontender,项目名称:cobbler,代码行数:30,代码来源:action_reposync.py
示例9: __init__
def __init__(self, logfile="/var/log/cobbler/cobbler.log"):
self.logfile = None
# Main logfile is append mode, other logfiles not.
if not os.path.exists(logfile):
self.logfile = open(logfile, "a")
sub_process.call("chown apache %s" % logfile, shell=True)
self.logfile.close()
try:
if logfile.find("tasks") != -1:
self.logfile = open(logfile, "w+")
else:
self.logfile = open(logfile, "a")
except IOError:
# You likely don't have write access, this logger will just print
# things to stdout.
pass
开发者ID:ssalevan,项目名称:cobbler,代码行数:18,代码来源:clogger.py
示例10: subprocess_call
def subprocess_call(cmd, ignore_rc=False):
"""
Wrapper around subprocess.call(...)
"""
print "- %s" % cmd
rc = sub_process.call(cmd)
if rc != 0 and not ignore_rc:
raise InfoException, "command failed (%s)" % rc
return rc
开发者ID:remotesyssupport,项目名称:koan,代码行数:9,代码来源:utils.py
示例11: is_selinux_enabled
def is_selinux_enabled():
if not os.path.exists("/usr/sbin/selinuxenabled"):
return False
args = "/usr/sbin/selinuxenabled"
selinuxenabled = sub_process.call(args,close_fds=True)
if selinuxenabled == 0:
return True
else:
return False
开发者ID:javiplx,项目名称:cobbler-debian,代码行数:9,代码来源:utils.py
示例12: __command
def __command(self, service_name, command):
service_name = service_name.strip() # remove useless spaces
filename = os.path.join("/etc/rc.d/init.d/",service_name)
if os.path.exists(filename):
return sub_process.call(["/sbin/service", service_name, command], close_fds=True)
else:
raise codes.FuncException("Service not installed: %s" % service_name)
开发者ID:ralphbean,项目名称:func-ralphbean-devel,代码行数:9,代码来源:service.py
示例13: modacl
def modacl(self,isadd,isuser,who):
webdir = self.settings.webdir
snipdir = self.settings.snippetsdir
tftpboot = utils.tftpboot_location()
PROCESS_DIRS = {
webdir : "rwx",
"/var/log/cobbler" : "rwx",
"/var/lib/cobbler" : "rwx",
"/etc/cobbler" : "rwx",
tftpboot : "rwx",
"/var/lib/cobbler/triggers" : "rwx"
}
if not snipdir.startswith("/var/lib/cobbler/"):
PROCESS_DIRS[snipdir] = "r"
cmd = "-R"
if isadd:
cmd = "%s -m" % cmd
else:
cmd = "%s -x" % cmd
if isuser:
cmd = "%s u:%s" % (cmd,who)
else:
cmd = "%s g:%s" % (cmd,who)
for d in PROCESS_DIRS:
how = PROCESS_DIRS[d]
if isadd:
cmd2 = "%s:%s" % (cmd,how)
else:
cmd2 = cmd
cmd2 = "%s %s" % (cmd2,d)
print "- setfacl -d %s" % cmd2
rc = sub_process.call("setfacl -d %s" % cmd2,shell=True,close_fds=True)
if not rc == 0:
raise CX(_("command failed"))
print "- setfacl %s" % cmd2
rc = sub_process.call("setfacl %s" % cmd2,shell=True,close_fds=True)
if not rc == 0:
raise CX(_("command failed"))
开发者ID:icontender,项目名称:cobbler,代码行数:44,代码来源:action_acl.py
示例14: check_service
def check_service(self, status, which, notes=""):
if notes != "":
notes = " (NOTE: %s)" % notes
rc = 0
if self.checked_dist == "redhat" or self.checked_dist == "suse":
if os.path.exists("/etc/rc.d/init.d/%s" % which):
rc = sub_process.call("/sbin/service %s status > /dev/null 2>/dev/null" % which, shell=True, close_fds=True)
if rc != 0:
status.append(_("service %s is not running%s") % (which,notes))
return False
elif self.checked_dist == "debian":
if os.path.exists("/etc/init.d/%s" % which):
rc = sub_process.call("/etc/init.d/%s status /dev/null 2>/dev/null" % which, shell=True, close_fds=True)
if rc != 0:
status.append(_("service %s is not running%s") % which,notes)
return False
else:
status.append(_("Unknown distribution type, cannot check for running service %s" % which))
return False
return True
开发者ID:icontender,项目名称:cobbler,代码行数:20,代码来源:action_check.py
示例15: run_this
def run_this(self, cmd, args):
"""
A simple wrapper around subprocess calls.
"""
my_cmd = cmd % args
print _("- %s") % my_cmd
rc = sub_process.call(my_cmd,shell=True,close_fds=True)
if rc != 0:
raise CX(_("Command failed"))
开发者ID:javiplx,项目名称:cobbler-debian,代码行数:11,代码来源:action_import.py
示例16: kill
def kill(self,pid,signal="TERM"):
if pid == "0":
raise codes.FuncException("Killing pid group 0 not permitted")
if signal == "":
# this is default /bin/kill behaviour,
# it claims, but enfore it anyway
signal = "-TERM"
if signal[0] != "-":
signal = "-%s" % signal
rc = sub_process.call(["/bin/kill",signal, pid],
executable="/bin/kill", shell=False)
print rc
return rc
开发者ID:kadamski,项目名称:func,代码行数:13,代码来源:process.py
示例17: subprocess_call
def subprocess_call(cmd,ignore_rc=0):
"""
Wrapper around subprocess.call(...)
"""
print "- %s" % cmd
if not ANCIENT_PYTHON:
rc = sub_process.call(cmd)
else:
cmd = string.join(cmd, " ")
print "cmdstr=(%s)" % cmd
rc = os.system(cmd)
if rc != 0 and not ignore_rc:
raise InfoException, "command failed (%s)" % rc
return rc
开发者ID:ssalevan,项目名称:cobbler,代码行数:14,代码来源:utils.py
示例18: run_triggers
def run_triggers(api,ref,globber,additional=[]):
"""
Runs all the trigger scripts in a given directory.
ref can be a cobbler object, if not None, the name will be passed
to the script. If ref is None, the script will be called with
no argumenets. Globber is a wildcard expression indicating which
triggers to run. Example: "/var/lib/cobbler/triggers/blah/*"
As of Cobbler 1.5.X, this also runs cobbler modules that match the globbing paths.
"""
# Python triggers first, before shell
modules = api.get_modules_in_category(globber)
for m in modules:
arglist = []
if ref:
arglist.append(ref.name)
for x in additional:
arglist.append(x)
rc = m.run(api, arglist)
if rc != 0:
raise CX("cobbler trigger failed: %s" % m.__name__)
# now do the old shell triggers, which are usually going to be slower, but are easier to write
# and support any language
triggers = glob.glob(globber)
triggers.sort()
for file in triggers:
try:
if file.startswith(".") or file.find(".rpm") != -1:
# skip dotfiles or .rpmnew files that may have been installed
# in the triggers directory
continue
arglist = [ file ]
if ref:
arglist.append(ref.name)
for x in additional:
arglist.append(x)
rc = sub_process.call(arglist, shell=False, close_fds=True)
except:
print _("Warning: failed to execute trigger: %s" % file)
continue
if rc != 0:
raise CX(_("cobbler trigger failed: %(file)s returns %(code)d") % { "file" : file, "code" : rc })
开发者ID:javiplx,项目名称:cobbler-debian,代码行数:47,代码来源:utils.py
示例19: cabextract
def cabextract(src,dst,api=None):
"""
Extract a cab file, used for importing off of Windows based cds
"""
try:
if not os.path.isdir(dst):
raise CX(_("Error in cabextract: the destination (%s) must be a directory") % dst)
cmd = [ "/usr/bin/cabextract", "-d", dst, src ]
rc = sub_process.call(cmd, shell=False, close_fds=True)
return rc
except:
if not os.access(src,os.R_OK):
raise CX(_("Cannot read: %s") % src)
if not os.path.samefile(src,dst):
# accomodate for the possibility that we already copied
# the file as a symlink/hardlink
raise
开发者ID:javiplx,项目名称:cobbler-debian,代码行数:17,代码来源:utils.py
示例20: install
def install(self, server_name, target_name, system=False, virt_name=None, virt_path=None, graphics=False):
"""
Install a new virt system by way of a named cobbler profile.
"""
# Example:
# install("bootserver.example.org", "fc7webserver", True)
# install("bootserver.example.org", "client.example.org", True, "client-disk0", "HostVolGroup00")
conn = self.__get_conn()
if conn is None:
raise codes.FuncException("no connection")
if not os.path.exists("/usr/bin/koan"):
raise codes.FuncException("no /usr/bin/koan")
target = "profile"
if system:
target = "system"
koan_args = [
"/usr/bin/koan",
"--virt",
"--%s=%s" % (target, target_name),
"--server=%s" % server_name
]
if virt_name:
koan_args.append("--virt-name=%s" % virt_name)
if virt_path:
koan_args.append("--virt-path=%s" % virt_path)
if not graphics:
koan_args.append("--nogfx")
rc = sub_process.call(koan_args,shell=False,close_fds=True)
if rc == 0:
return 0
else:
raise codes.FuncException("koan returned %d" % rc)
开发者ID:caglar10ur,项目名称:func,代码行数:42,代码来源:virt.py
注:本文中的sub_process.call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论