本文整理汇总了Python中util.get_stdout函数的典型用法代码示例。如果您正苦于以下问题:Python get_stdout函数的具体用法?Python get_stdout怎么用?Python get_stdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_stdout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_width_height
def get_width_height( fname, orig_modtime=None ):
"""get (possibly cached) width and height of .svg file with inkscape"""
# compute filename of cached width/height
wh_cache_path, wh_cache_fname = os.path.split(fname)
wh_cache_fname = CACHE_PREFIX+os.path.splitext(wh_cache_fname)[0]+'.txt'
wh_cache_fname = os.path.join( wh_cache_path, wh_cache_fname )
# read cache if it exists
if os.path.exists( wh_cache_fname ):
modtime = os.stat(wh_cache_fname)[stat.ST_MTIME]
if orig_modtime is None:
orig_modtime = os.stat(fname)[stat.ST_MTIME]
if modtime > orig_modtime:
width,height = open( wh_cache_fname ).read().strip().split()
return width,height
# no cache, query inkscape for information
tmpf = tempfile.NamedTemporaryFile(suffix='.png')
tmpf.close()
cmd = [INKSCAPE,'-C',fname,'-e',tmpf.name]
get_stdout(cmd)
import Image
# XXX TODO: convert to reading XML file instead of using PIL
im = Image.open(tmpf.name)
(width, height) = im.size
os.unlink(tmpf.name)
fd = open (wh_cache_fname,mode="w")
fd.write("%s %s\n"%(width,height))
fd.close()
return width, height
示例2: p2p_set_nego
def p2p_set_nego(mac):
print 'p2p_set_nego:'
print 'mac: %s' % mac
get_stdout('iwpriv eth0 p2p_set nego=%s' % mac)
# Enter negotiation loop
while 1:
# Wait for result
time.sleep(0.5)
# Poll status
peer_status = p2p_status_get()
print 'peer_status: %d' % peer_status
# For Windows 8.1 support, we consider 19 as negotiation completed
if peer_status in [10, 19]:
print 'Negotiation suceeded!'
break
# Get role
role = p2p_role_get()
print 'Role: %s' % role
# TODO: doesn't seem to return anything
#p2p_opch_get()
# Get peer interface address
peer_mac_get()
p2p_go_mode_set()
示例3: wfd_connection_wait
def wfd_connection_wait():
get_stdout(cmd_killall_wpa_spplicant)
get_stdout(cmd_killall_hostapd)
# Disable p2p
p2p_disable()
time.sleep(0.5)
# Enable p2p
p2p_enable()
#p2p_peer_scan()
print 'Waiting for incoming connection...'
while 1:
peer_status = p2p_status_get()
print 'peer_status: %d' % peer_status
if peer_status == 0:
print 'p2p disabled! Re-enable p2p...'
p2p_enable()
if peer_status in [8, 19, 22]:
# Discovery request or gonego fail
print 'Discovery request received!'
peer_found = p2p_peer_scan()
if peer_found:
break
p2p_disable()
time.sleep(1)
print 'Getting peer device address...'
# Get peer device address
mac = p2p_peer_devaddr_get()
print 'peer_devaddr: %s' % mac
# Notify received wps info
p2p_wpsinfo()
print 'Getting peer authentication type...'
# Get request configuration
p2p_req_cm_get()
print 'Confirming peer authentication...'
# Set negotiation
p2p_set_nego(mac)
示例4: p2p_go_mode_set
def p2p_go_mode_set():
# Start hostAPd and wait for it to daemonize; ignore stdout
get_stdout(["./hostapd", "-B", "p2p_hostapd.conf"])
# Wait for initialization
time.sleep(1)
do_wps()
# Wait for host apd interval
time.sleep(1)
示例5: p2p_peer_port_get
def p2p_peer_port_get():
print 'p2p_peer_port_get:'
output = get_stdout('iwpriv wlan0 p2p_get peer_port')
print output
match = re.search(r'^Port=(\d+)$', output, re.M)
print match.group(1)
return int(match.group(1))
示例6: p2p_peer_devaddr_get
def p2p_peer_devaddr_get():
print 'p2p_peer_devaddr_get:'
output = get_stdout(["iwpriv", "wlan0", "p2p_get", "peer_deva"])
match = re.search(r'\n(.*)$', output)
mac = ':'.join(re.findall('..', match.group(1)))
return mac
示例7: p2p_enable
def p2p_enable():
# Enable p2p
get_stdout('iwpriv eth0 p2p_set enable=1')
# Set intent
get_stdout('iwpriv eth0 p2p_set intent=15')
# Set operation channel
get_stdout('iwpriv eth0 p2p_set op_ch=%d' % 11)
# Sleep for 50ms
time.sleep(0.05)
# Set ssid
get_stdout('iwpriv eth0 p2p_set ssid=DIRECT-RT')
# Set DN
get_stdout('iwpriv eth0 p2p_set setDN=Piracast')
示例8: p2p_go_mode_set
def p2p_go_mode_set():
# Start hostAPd and wait for it to daemonize; ignore stdout
get_stdout(["./hostapd", "-B", "p2p_hostapd.conf"])
# Wait for initialization
time.sleep(1)
do_wps()
# Wait for host apd interval
time.sleep(1)
while 1:
status = read_all_sta()
if status:
print 'Wireless display negotiation completed!'
break
time.sleep(1)
示例9: p2p_peer_devaddr_get
def p2p_peer_devaddr_get():
print 'p2p_peer_devaddr_get:'
output = get_stdout(["iwpriv", "wlan0", "p2p_get", "peer_deva"])
match = re.search(r'\n(.*)$', output)
mac = '%s%s:%s%s:%s%s:%s%s:%s%s:%s%s' % match.group(1)[0:11]
#mac = match.group(1)[0] + match.group(1)[1] + ':' \
# + match.group(1)[2] + match.group(1)[3] + ':' \
# + match.group(1)[4] + match.group(1)[5] + ':' \
# + match.group(1)[6] + match.group(1)[7] + ':' \
# + match.group(1)[8] + match.group(1)[9] + ':' \
# + match.group(1)[10] + match.group(1)[11]
return mac
示例10: do_wps
def do_wps():
while 1:
print 'do_wps:'
output = get_stdout(["./hostapd_cli", "wps_pbc", "any"])
print output
if 'OK' in output:
print 'wps passed!'
return
time.sleep(1)
示例11: p2p_peer_scan
def p2p_peer_scan():
count = 0
while 1:
output = get_stdout(cmd_iwlist_eth0_scan)
print output
if 'No scan results' not in output:
return True
if count > 3:
return False
count += 1
示例12: p2p_peer_devaddr_get
def p2p_peer_devaddr_get():
print 'p2p_peer_devaddr_get:'
output = get_stdout('iwpriv wlan0 p2p_get peer_deva')
print output
match = re.search(r'^([0-9A-Fa-f]{12})$', output, re.M)
print match.group(1)
mac = '%s:%s:%s:%s:%s:%s' % tuple(re.findall('[0-9A-Fa-f]{2}',match.group(1)))
print mac
#mac = match.group(1)[0] + match.group(1)[1] + ':' \
# + match.group(1)[2] + match.group(1)[3] + ':' \
# + match.group(1)[4] + match.group(1)[5] + ':' \
# + match.group(1)[6] + match.group(1)[7] + ':' \
# + match.group(1)[8] + match.group(1)[9] + ':' \
# + match.group(1)[10] + match.group(1)[11]
return mac
示例13: p2p_status_get
def p2p_status_get():
#print 'p2p_status_get:'
output = get_stdout('iwpriv eth0 p2p_get status')
match = re.search(r'Status=(\d*)', output)
return int(match.group(1))
示例14: p2p_wpsinfo
def p2p_wpsinfo():
print 'p2p_wpsinfo:'
get_stdout('iwpriv eth0 p2p_set got_wpsinfo=3')
示例15: wps_status_get
def wps_status_get():
print 'wps_status_get:'
output = get_stdout(["./wpa_cli", "status"])
print output