All Samples(3393) | Call(3248) | Derive(0) | Import(145)
popen(command [, mode='r' [, bufsize]]) -> pipe Open a pipe to/from a command returning a file object.
src/t/o/Toolserver-0.4.1/samples/ServerManager.py Toolserver(Download)
services = os.listdir('/usr/share/servermanager/service.d')
if service in services:
if service not in self.config.disabledServices:
cmd = os.popen('/usr/share/servermanager/service.d/%s %s' % (service, action), 'r')
rc = 800
msg = 'no response from control script'
for line in cmd.readlines():
this process group (grouped by user+command)
"""
what = (onlyrunning and 'axr') or 'ax'
pipe = os.popen('ps -o pid,stat,user,pcpu,pmem,comm --no-headers %s' % what)
lines = pipe.readlines()
pipe.close()
proc = {}
def getdevstats(self, token):
"""
This call returns a l ist of all mounted filesystems with
usage stats for each
"""
pipe = os.popen('df -T -m -P')
lines = pipe.readlines()
counters = os.listdir('/usr/share/servermanager/counter.d')
if counter in counters:
parmstr = ' '.join(map(lambda k: '%s=%s' % (k[0], k[1]), parms))
cmd = os.popen('/usr/share/servermanager/counter.d/%s values %s' % (counter, parmstr), 'r')
output = cmd.read()
(head, body) = output.split('\n\n')
headerlist = head.split('\n')
def getcountervariables(self, token, counter):
"""
Get variables for a given counter script.
"""
counters = os.listdir('/usr/share/servermanager/counter.d')
if counter in counters:
cmd = os.popen('/usr/share/servermanager/counter.d/%s variables' % counter, 'r')
src/c/e/cerebrum-HEAD/trunk/cerebrum/clients/examples/bofh.py cerebrum(Download)
from M2Crypto import SSL
if not os.path.exists('/dev/random') and rand_cmd is not None:
from M2Crypto.Rand import rand_add
rand_file = os.popen(rand_cmd, 'r')
rand_string = rand_file.read()
rand_file.close()
rand_add(rand_string, len(rand_string))
src/c/e/cerebrum-HEAD/cerebrum/clients/examples/bofh.py cerebrum(Download)
from M2Crypto import SSL
if not os.path.exists('/dev/random') and rand_cmd is not None:
from M2Crypto.Rand import rand_add
rand_file = os.popen(rand_cmd, 'r')
rand_string = rand_file.read()
rand_file.close()
rand_add(rand_string, len(rand_string))
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_9_11_sol_1.py python-cookbook(Download)
import os
f = os.popen('gnuplot', 'w')
print >>f, "set yrange[-300:+300]"
for n in range(300):
print >>f, "plot %i*cos(x)+%i*log(x+10)" % (n, 150-n)
f.flush()
f.close()
src/p/r/practice_python-HEAD/bookexample/src/bvista/b15_1_rewho.py practice_python(Download)
'''
from os import popen
from re import split
f = popen('dir','r')
src/e/x/execnet-1.0.8/doc/example/svn-sync-repo.py execnet(Download)
def svn_load(repo, dumpchannel, maxcount=100):
# every maxcount we will send an ACK to the other
# side in order to synchronise and avoid our side
# growing buffers (execnet does not control
# RAM usage or receive queue sizes)
dumpchannel.send(maxcount)
f = os.popen("svnadmin load -q %s" %(repo, ), "w")
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_9_12_sol_1.py python-cookbook(Download)
def getCommandOutput2(command):
child = os.popen(command)
data = child.read()
err = child.close()
if err:
raise RuntimeError, '%r failed with exit code %d' % (command, err)
src/m/o/modu-HEAD/examples/modusite/modusite/model/release.py modu(Download)
def get_checksum(filepath, md5_path='md5sum'):
handle = os.popen(md5_path + ' "' + filepath.replace(r';', r'\;') + '"')
filehash = handle.read()
handle.close()
if(filehash.find('=') == -1):
filehash = [output.strip() for output in filehash.split(' ')][0]
src/m/o/modu-1.0.2/examples/modusite/modusite/model/release.py modu(Download)
def get_checksum(filepath, md5_path='md5sum'):
handle = os.popen(md5_path + ' "' + filepath.replace(r';', r'\;') + '"')
filehash = handle.read()
handle.close()
if(filehash.find('=') == -1):
filehash = [output.strip() for output in filehash.split(' ')][0]
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_15_8_sol_2.py python-cookbook(Download)
def get_cookie(self):
pipe = os.popen(FORTUNE_PATH)
cookie = pipe.read()
if pipe.close():
# An error occurred with the pipe
cookie = "Oh dear, couldn't get a fortune\n"
return cookie
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next