• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.get_stdout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.get_stdout函数的典型用法代码示例。如果您正苦于以下问题:Python get_stdout函数的具体用法?Python get_stdout怎么用?Python get_stdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_stdout函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:astraw,项目名称:burst_s5,代码行数:31,代码来源:inklayers_directive.py


示例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()
开发者ID:chr0nu5,项目名称:piracast,代码行数:31,代码来源:wfd.py


示例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)
开发者ID:Carranza,项目名称:uPi-MS,代码行数:56,代码来源:wfd.py


示例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)
开发者ID:sabzo,项目名称:PiDroid,代码行数:12,代码来源:wfd.py


示例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))
开发者ID:wklaebe,项目名称:piracast,代码行数:7,代码来源:wfd.py


示例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
开发者ID:Carranza,项目名称:uPi-MS,代码行数:7,代码来源:wfd.py


示例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')
开发者ID:chr0nu5,项目名称:piracast,代码行数:19,代码来源:wfd.py


示例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)
开发者ID:chr0nu5,项目名称:piracast,代码行数:21,代码来源:wfd.py


示例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
开发者ID:TanYuDe,项目名称:piracast,代码行数:13,代码来源:wfd.py


示例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)
开发者ID:chr0nu5,项目名称:piracast,代码行数:13,代码来源:wfd.py


示例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
开发者ID:chr0nu5,项目名称:piracast,代码行数:15,代码来源:wfd.py


示例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
开发者ID:wklaebe,项目名称:piracast,代码行数:16,代码来源:wfd.py


示例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))
开发者ID:chr0nu5,项目名称:piracast,代码行数:5,代码来源:wfd.py


示例14: p2p_wpsinfo

def p2p_wpsinfo():
    print 'p2p_wpsinfo:'
    get_stdout('iwpriv eth0 p2p_set got_wpsinfo=3')
开发者ID:chr0nu5,项目名称:piracast,代码行数:3,代码来源:wfd.py


示例15: wps_status_get

def wps_status_get():
    print 'wps_status_get:'
    output = get_stdout(["./wpa_cli", "status"])
    print output
开发者ID:chr0nu5,项目名称:piracast,代码行数:4,代码来源:wfd.py


示例16: wps_auth

def wps_auth():
    print 'wps_auth:'
    output = get_stdout(["./hostapd_cli", "wps_pbc", "any"])
    print output
    time.sleep(1)
开发者ID:chr0nu5,项目名称:piracast,代码行数:5,代码来源:wfd.py


示例17: wpa_supplicant_start

def wpa_supplicant_start():
    print 'wpa_supplicant_start:'
    get_stdout(["./wpa_supplicant", "-i", "eth0", "-c", "./wpa_0_8.conf", "-B"])
    time.sleep(1)
开发者ID:chr0nu5,项目名称:piracast,代码行数:4,代码来源:wfd.py


示例18: p2p_role_get

def p2p_role_get():
    print 'p2p_role_get:'
    output = get_stdout('iwpriv eth0 p2p_get role')
    match = re.search(r'Role=(\d*)', output)
    role = int(match.group(1))
    return role
开发者ID:chr0nu5,项目名称:piracast,代码行数:6,代码来源:wfd.py


示例19: lease_file_timestamp_get

lease_file = '/var/lib/dhcp/dhcpd.leases'

def lease_file_timestamp_get():
    return get_stdout('ls -l "%s"' % lease_file)

# get the leased IP address
def leased_ip_get():
    contents = open(lease_file).read()
    ip_list = re.findall(r'lease (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', contents)

    # return the most recently leased IP address
    return ip_list[-1]

print 'Bring up eth0 just in case...'
get_stdout(cmd_eth0_up)

print 'Increase rmem_default...'
get_stdout(cmd_inc_rmem_default)

# Don't kill running application as
# it is started explicitly
#print 'Kill running application...'
#core_channel.end()
#print get_stdout(cmd_kill_core_app)

while 1:

    # Don't launch application, because it stuck
    # the execution
    # get_stdout(cmd_launch_core_app)
开发者ID:chr0nu5,项目名称:piracast,代码行数:30,代码来源:piracast.py


示例20: p2p_disable

def p2p_disable():
    get_stdout('iwpriv eth0 p2p_set enable=0')
开发者ID:chr0nu5,项目名称:piracast,代码行数:2,代码来源:wfd.py



注:本文中的util.get_stdout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_type_by_name函数代码示例发布时间:2022-05-27
下一篇:
Python util.get_required_param函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap