本文整理汇总了Python中util.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_dev
def get_dev(user_mod=''):
'''
use v4l-info to determine device for a given driver module
'''
if user_mod == 'bttv0':
user_mod = 'bttv'
with run_command('ls /dev/video*', do_popen=True) as pop_:
for line in pop_:
devname = line.strip()
if hasattr(devname, 'decode'):
devname = devname.decode()
if not os.path.exists('/usr/bin/v4l-info'):
print('YOU NEED TO INSTALL v4l-conf')
exit(0)
driver = ''
with run_command('v4l-info %s 2> /dev/null | grep driver'
% devname, do_popen=True) as v4linfo:
for line in v4linfo:
if hasattr(line, 'decode'):
line = line.decode()
if line != '':
driver = line.split()[2].strip('"')
if user_mod in driver or (not user_mod and driver == 'em28xx'):
return devname
开发者ID:ddboline,项目名称:roku_app,代码行数:26,代码来源:get_dev.py
示例2: build_ns3
def build_ns3(config, build_examples, build_tests, args, build_options):
cmd = [sys.executable, "waf", "configure"] + args
if build_examples:
cmd.append("--enable-examples")
if build_tests:
cmd.append("--enable-tests")
try:
ns3_traces, = config.getElementsByTagName("ns-3-traces")
except ValueError:
# Don't print a warning message here since regression traces
# are no longer used.
pass
else:
cmd.extend([
"--with-regression-traces", os.path.join("..", ns3_traces.getAttribute("dir")),
])
try:
pybindgen, = config.getElementsByTagName("pybindgen")
except ValueError:
print "Note: configuring ns-3 without pybindgen"
else:
cmd.extend([
"--with-pybindgen", os.path.join("..", pybindgen.getAttribute("dir")),
])
run_command(cmd) # waf configure ...
run_command([sys.executable, "waf", "build"] + build_options)
开发者ID:binhqnguyen,项目名称:lena-simple,代码行数:31,代码来源:build.py
示例3: install_pkgs
def install_pkgs(self, pkg_lst, mnt_pt):
for pkg in pkg_lst:
self.install_package(mnt_pt, pkg)
#clean apt package cache
util.run_command("chroot %s /usr/bin/apt-get clean" % mnt_pt)
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:7,代码来源:Debian.py
示例4: run
def run(self,input):
filename = tempfile.mktemp()
f = open(filename,'wb')
cmd = self.command
if input: cmd += '< %s' % input.pathname
util.run_command(cmd, f.write, self.callback.log)
f.close()
return {'output': File(filename)}
开发者ID:WayWingsDev,项目名称:SIMUL_DSA,代码行数:8,代码来源:piper_plugin.py
示例5: _disable_ttys
def _disable_ttys(self, mnt_pt):
#disable gettys
util.run_command("sed -i -e 's/^\([1-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' %s/etc/inittab" % mnt_pt)
text = "S0:12345:respawn:/sbin/getty -L console 9600 vt100\n"
util.write_to_file("%s/etc/inittab" % mnt_pt, "a", text)
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:7,代码来源:Debian.py
示例6: copy_kernel_modules
def copy_kernel_modules(self, mnt_pt):
#disable hw clock
#os.chmod("%s/etc/init.d/hwclock.sh" % mnt_pt, 0644)
#copy kernek modules
kernel_version = os.path.basename(self._kernel)[8:]
util.run_command("cp -r /lib/modules/%s \
%s/lib/modules/%s" % (kernel_version, mnt_pt, kernel_version))
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:8,代码来源:Guest.py
示例7: netanim_download
def netanim_download():
local_file = required_netanim_version + ".tar.bz2"
remote_file = constants.NETANIM_RELEASE_URL + "/" + local_file
print "Retrieving NetAnim from " + remote_file
urllib.urlretrieve(remote_file, local_file)
print "Uncompressing " + local_file
run_command(["tar", "-xjf", local_file])
print "Rename %s as %s" % (required_netanim_version, constants.LOCAL_NETANIM_PATH)
os.rename(required_netanim_version, constants.LOCAL_NETANIM_PATH)
开发者ID:GritBear,项目名称:ELEC537-wifi-protocal-simulator,代码行数:9,代码来源:download.py
示例8: run
def run(self, **k):
input = k["test data"]
model = k["model"]
filename = tempfile.mktemp()
cmd = "%s %s %s %s" % (svm_predict_pathname, input.pathname, model.pathname, filename)
log = self.callback.log
log("# Running %s\n" % cmd)
util.run_command(cmd, log, log)
return {"output": TextFile(filename, autodel=True)}
开发者ID:WayWingsDev,项目名称:SIMUL_DSA,代码行数:9,代码来源:predictor_plugin.py
示例9: pipeline_monogenic_validation
def pipeline_monogenic_validation(work_dir=os.environ['OBER_OUT'] + '/requests/monogenic/work',
index_segments_dir=os.environ['OBER_OUT'] + '/requests/monogenic/work/index_segments',
region_size=100,
theta_affinity=0.95,
theta_weight=0.5,
regenerate_segments=True,
snps=None, # np.array([6, 8]),
debug=1,
debug_sample=512):
# Load SNPs
problem = im.io.read_plink(prefix=work_dir + '/monogenic.12', pedigree=im.itu.HUTT_PED, haplotype=None, frames=None)
# Testing: simulate aligned samples output (hap types should be 2 in the imputed genotype output line)
problem.haplotype.poo_phase = np.zeros((problem.num_samples,), dtype=np.byte)
problem.haplotype.poo_phase[np.array([0, 1])] = 1
problem.haplotype.poo_phase[np.array([2, 3])] = -1
# Create segments only for the regions around each snp
if regenerate_segments:
for row in (problem.info.snp[snps] if snps is not None else problem.info.snp):
# Find SNP's region (the one containing its base-pair position)
chrom, bp = row['chrom'], row['base_pair']
phasing_dir = '%s/phasing/chr%d' % (os.environ['OBER_OUT'], chrom)
index_segments_chrom_dir = '%s/chr%d' % (index_segments_dir, chrom)
info_file = '%s/hutt.phased.info.npz' % (phasing_dir,)
info = im.io.read_info_npz(info_file)
snp_bp = info.snp['base_pair']
snp_index = util.nearest_neighbor_in_list_tree(bp, snp_bp, util.list_index_tree(snp_bp))
snp_index = snp_index if snp_bp[snp_index] <= bp else snp_index - 1
start = region_size * (snp_index / region_size)
stop = start + region_size
segment_file = '%s/segments-%d-%d.out' % (index_segments_chrom_dir, start, stop)
if not os.path.exists(segment_file):
util.mkdir_if_not_exists(index_segments_chrom_dir)
util.run_command('find-segments-of-snp-range %d %d < %s/segments.out > %s' % (start, stop, phasing_dir, segment_file))
# Index segments
if regenerate_segments or \
not os.path.exists('%s/metadata.npz' % (index_segments_chrom_dir,)) or \
not os.path.exists('%s/region-%d.npz' % (index_segments_chrom_dir, start)):
index_segments_beagle.main(segment_file, info_file, segment_file, index_segments_chrom_dir,
snp_index=snp_index, debug=2,
theta_affinity=theta_affinity, theta_weight=theta_weight)
# Impute using the newly generated segment index
_, t = im.v.iv.impute_problem(problem, debug=debug, remove_partial_calls=True,
segment_location=index_segments_dir, # if regenerate_segments else None,
snps=snps, debug_sample=debug_sample)
im.io.write_plink(im.Problem(genotype=t.imputed, pedigree=im.examples.hutt_pedigree(), haplotype=None, frames=None),
work_dir + '/imputed.12', save_frames=False, save_haplotype=False)
im.cgi.io_cgi.write_imputed(t, sys.stdout, poo_phase=problem.haplotype.poo_phase)
with open(work_dir + '/imputed.12.lgen', 'wb') as f:
im.cgi.io_cgi.write_imputed_lgen(t, f)
return t
开发者ID:orenlivne,项目名称:ober,代码行数:54,代码来源:monogenic_validation.py
示例10: install
def install(self):
"""mount disk image and download base system"""
#mount disk image
mnt_pt = "/mnt/%s" % self._name
os.mkdir(mnt_pt)
util.run_command("mount -o loop %s %s" % (self._path, mnt_pt))
#download base system
print "Downloading %s base system\n" % self._release
return util.run_command("debootstrap --arch %s %s %s %s" %
(self._arch, self._release, mnt_pt, self._location))
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:12,代码来源:Debian.py
示例11: post_install
def post_install(self):
# create /etc/fstab, /etc/hostname, /etc/network/interfaces, /etc/hosts
# create xen config file, unmount disk image
mnt_pt = "/mnt/%s" % self._name
print "Setting up guest OS %s\n" % self._name
print "Copying kernel modules\n"
self.copy_kernel_modules(mnt_pt)
print "Disabling extra ttys\n"
self._disable_ttys(mnt_pt)
print "Setting up apt\n"
text = """# %s/stable
deb http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu %s-security main restricted universe multiverse
""" % (
self._release,
self._release,
self._release,
)
self._apt_setup(text, mnt_pt)
print "installing libc6-xen, udev, ssh\n"
self.install_pkgs(["libc6-xen", "openssh-server", "udev"], mnt_pt)
# create /etc/fstab
print "Setting up filesystem table\n"
self.create_fstab(mnt_pt)
print "Setting up networking\n"
self.network_setup(mnt_pt)
# hack to prevent nash-hotplug from hogging cpu
self.kill_nash_hotplug(mnt_pt)
print "Creating initrd for %s\n" % self._name
self.create_initrd()
print "Generating xen configuration file /etc/xen/%s\n" % self._name
self.create_xen_config()
# unmount filesystem
util.run_command("umount %s" % mnt_pt)
os.rmdir(mnt_pt)
print "Installation of guest domain %s complete!!!" % self._name
return 0
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:52,代码来源:Ubuntu.py
示例12: list_auto_snapshot_sets
def list_auto_snapshot_sets(self, tag = None):
"""
Returns a list of zfs filesystems and volumes tagged with
the "com.sun:auto-snapshot" property set to "true", either
set locally or inherited. Snapshots are excluded from the
returned result.
Keyword Arguments:
tag:
A string indicating one of the standard auto-snapshot schedules
tags to check (eg. "frequent" will map to the tag:
com.sun:auto-snapshot:frequent). If specified as a zfs property
on a zfs dataset, the property corresponding to the tag will
override the wildcard property: "com.sun:auto-snapshot"
Default value = None
"""
#Get auto-snap property in two passes. First with the global
#value, then overriding with the label/schedule specific value
included = []
excluded = []
cmd = [ZFSCMD, "list", "-H", "-t", "filesystem,volume",
"-o", "name,com.sun:auto-snapshot", "-s", "name"]
if tag:
overrideprop = "com.sun:auto-snapshot:" + tag
scmd = [ZFSCMD, "list", "-H", "-t", "filesystem,volume",
"-o", "name," + overrideprop, "-s", "name"]
outdata,errdata = util.run_command(scmd)
for line in outdata.rstrip().split('\n'):
line = line.split()
if line[1] == "true":
included.append(line[0])
elif line[1] == "false":
excluded.append(line[0])
outdata,errdata = util.run_command(cmd)
for line in outdata.rstrip().split('\n'):
line = line.split()
# Only set values that aren't already set. Don't override
try:
included.index(line[0])
continue
except ValueError:
try:
excluded.index(line[0])
continue
except ValueError:
# Dataset is not listed in either list.
if line[1] == "true":
included.append(line[0])
return included
开发者ID:aszeszo,项目名称:time-slider,代码行数:51,代码来源:zfs.py
示例13: get_regression_traces
def get_regression_traces(ns3_dir, regression_branch):
print """
#
# Get the regression traces
#
"""
# ns3_dir is the directory into which we cloned the repo
# regression_branch is the repo in which we will find the traces. Variations like this should work:
# ns-3-dev-ref-traces
# craigdo/ns-3-dev-ref-traces
# craigdo/ns-3-tap-ref-traces
regression_traces_dir = os.path.split(regression_branch)[-1]
regression_branch_url = constants.REGRESSION_TRACES_REPO + regression_branch
print "Synchronizing reference traces using Mercurial."
try:
if not os.path.exists(regression_traces_dir):
run_command(["hg", "clone", regression_branch_url, regression_traces_dir])
else:
run_command(["hg", "-q", "pull", "--cwd", regression_traces_dir, regression_branch_url])
run_command(["hg", "-q", "update", "--cwd", regression_traces_dir])
except OSError: # this exception normally means mercurial is not found
if not os.path.exists(regression_traces_dir_name):
traceball = regression_tbranch + constants.TRACEBALL_SUFFIX
print "Retrieving " + traceball + " from web."
urllib.urlretrieve(constants.REGRESSION_TRACES_URL + traceball, traceball)
run_command(["tar", "-xjf", traceball])
print "Done."
return regression_traces_dir
开发者ID:joelagnel,项目名称:ns-3,代码行数:30,代码来源:download-pybindgen.py
示例14: _disable_ttys
def _disable_ttys(self, mnt_pt):
util.run_command("rm -f %s/etc/event.d/tty[2-6]" % mnt_pt)
lines = util.pipe_command("cat %s/etc/event.d/tty1" % mnt_pt)
if self._release == "feisty":
lines[-1] = "exec /sbin/getty -L 9600 console vt100\n"
else:
lines[-1] = "respawn /sbin/getty -L 9600 console vt100\n"
fd = None
try:
fd = open("%s/etc/event.d/tty1" % mnt_pt, "w")
fd.writelines(lines)
finally:
if fd is not None:
fd.close()
开发者ID:MartinOmatsola,项目名称:xensor,代码行数:15,代码来源:Ubuntu.py
示例15: build_ns3
def build_ns3(config, build_examples, build_tests):
cmd = [
"python", "waf", "configure",
]
if build_examples:
cmd.append("--enable-examples")
if build_tests:
cmd.append("--enable-tests")
try:
ns3_traces, = config.getElementsByTagName("ns-3-traces")
except ValueError:
# Don't print a warning message here since regression traces
# are no longer used.
pass
else:
cmd.extend([
"--with-regression-traces", os.path.join("..", ns3_traces.getAttribute("dir")),
])
try:
pybindgen, = config.getElementsByTagName("pybindgen")
except ValueError:
print "Note: configuring ns-3 without pybindgen"
else:
cmd.extend([
"--with-pybindgen", os.path.join("..", pybindgen.getAttribute("dir")),
])
try:
nsc, = config.getElementsByTagName("nsc")
except ValueError:
print "Note: configuring ns-3 without NSC"
else:
# Build NSC if the architecture supports it
if sys.platform not in ['linux2']:
arch = None
else:
arch = os.uname()[4]
if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
cmd.extend(["--with-nsc", os.path.join("..", nsc.getAttribute("dir"))])
else:
print "Note: configuring ns-3 without NSC (architecture not supported)"
run_command(cmd)
run_command(["python", "waf"])
开发者ID:achanda,项目名称:MobilityFirst,代码行数:48,代码来源:build.py
示例16: get_user_property
def get_user_property(self, prop, local=False):
if local == True:
cmd = [ZFSCMD, "get", "-s", "local", "-H", "-o", "value", prop, self.name]
else:
cmd = [ZFSCMD, "get", "-H", "-o", "value", prop, self.name]
outdata,errdata = util.run_command(cmd)
return outdata.rstrip()
开发者ID:aszeszo,项目名称:time-slider,代码行数:7,代码来源:zfs.py
示例17: get_default_schedules
def get_default_schedules():
"""
Finds the default schedules that are enabled (online, offline or degraded)
"""
#This is not the fastest method but it is the safest, we need
#to ensure that default schedules are processed in the pre-defined
#order to ensure that the overlap between them is adhered to
#correctly. monthly->weekly->daily->hourly->frequent. They have
#to be processed first and they HAVE to be in the correct order.
_defaultSchedules = []
for s in factoryDefaultSchedules:
instanceName = "%s:%s" % (BASESVC,s)
cmd = [smf.SVCSCMD, "-H", "-o", "state", instanceName]
_scheddetaillock.acquire()
try:
outdata,errdata = util.run_command(cmd)
finally:
_scheddetaillock.release()
result = outdata.rstrip()
# Note that the schedules, being dependent on the time-slider service
# itself will typically be in an offline state when enabled. They will
# transition to an "online" state once time-slider itself comes
# "online" to satisfy it's dependency
if result == "online" or result == "offline" or result == "degraded":
instance = AutoSnap(s)
try:
_defaultSchedules.append(instance.get_schedule_details())
except RuntimeError, message:
raise RuntimeError, "Error getting schedule details for " + \
"default auto-snapshot SMF instance:" + \
"\n\t" + instanceName + "\nDetails:\n" + \
str(message)
开发者ID:Lalufu,项目名称:time-slider,代码行数:32,代码来源:autosnapsmf.py
示例18: get_creation_time
def get_creation_time(self):
if self.__creationTime == None:
cmd = [ZFSCMD, "get", "-H", "-p", "-o", "value", "creation",
self.name]
outdata,errdata = util.run_command(cmd)
self.__creationTime = long(outdata.rstrip())
return self.__creationTime
开发者ID:aszeszo,项目名称:time-slider,代码行数:7,代码来源:zfs.py
示例19: get_custom_schedules
def get_custom_schedules():
"""
Finds custom schedules ie. not the factory default
'monthly', 'weekly', 'hourly', 'daily' and 'frequent' schedules
"""
_customSchedules = []
cmd = [smf.SVCSCMD, "-H", "-o", "state,FMRI", BASESVC]
_scheddetaillock.acquire()
try:
outdata,errdata = util.run_command(cmd)
finally:
_scheddetaillock.release()
for line in outdata.rstrip().split('\n'):
line = line.rstrip().split()
state = line[0]
fmri = line[1]
fmri = fmri.rsplit(":", 1)
label = fmri[1]
if label not in factoryDefaultSchedules:
# Note that the schedules, being dependent on the time-slider service
# itself will typically be in an offline state when enabled. They will
# transition to an "online" state once time-slider itself comes
# "online" to satisfy it's dependency
if state == "online" or state == "offline" or state == "degraded":
instance = AutoSnap(label)
try:
_customSchedules.append(instance.get_schedule_details())
except RuntimeError, message:
raise RuntimeError, "Error getting schedule details " + \
"for custom auto-snapshot SMF " + \
"instance:\n\t" + label + "\n" + \
"Details:\n" + str(message)
开发者ID:Lalufu,项目名称:time-slider,代码行数:33,代码来源:autosnapsmf.py
示例20: make_temp_copy
def make_temp_copy(temp_dir_with_slash, filename, head=False):
"""
Create a temporary copy of a file, either from the index or from HEAD.
"""
# TODO: Once all the hooks can take straight text rather than files, use git show instead:
# git_cat_command = "git show :%(f)s" % dict(f=filename)
# git_out, git_err, git_rc = run_command(git_cat_command)
# if git_err or git_rc:
# return None
# return git_out # contents of <filename> in the index
temp_filename = os.path.join(temp_dir_with_slash, filename)
if os.path.isfile(temp_filename):
os.remove(temp_filename)
if head:
git_archive_command = "git archive HEAD -- %s" % (filename, )
untar_command = "tar -x -C %s" % (temp_dir_with_slash, )
git_out, git_err, git_rc = run_piped_commands([git_archive_command, untar_command])
else:
git_checkout_command = "git checkout-index --prefix=%s -- %s" % (temp_dir_with_slash, filename)
git_out, git_err, git_rc = run_command(git_checkout_command)
if git_out or git_err or git_rc:
print("# Internal hook error:\n%(out)s\n%(err)s\n" % dict(out=git_out, err=git_err))
sys.exit(1)
return temp_filename
开发者ID:nouiz,项目名称:pygithooks,代码行数:28,代码来源:precommit.py
注:本文中的util.run_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论