当前位置: 首页>>代码示例>>Python>>正文


Python easyprocess.EasyProcess类代码示例

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


在下文中一共展示了EasyProcess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getRainTicks

def getRainTicks():
    global ticks
    global temperature
    os.system('rm -Rf '+json_rain_sensor)
    time.sleep(0.5)
    cmd = "rtl_433 -R 37 -E -F json:"+json_rain_sensor
    try:
        stdout=Proc(cmd).call(timeout=120).stdout
        time.sleep(0.5)
        with open(json_rain_sensor) as f:
            data = json.loads(f.readline())
        if "temperature_C" in data:
            temperature = float(data["temperature_C"])
        if "rain" in data:
            ticks = int(data["rain"])
    except:
        print(CRED+'[NOK] rtl_433 timed out'+CEND)
        from easyprocess import EasyProcess
        s=EasyProcess("lsusb").call().stdout
        for line in s.splitlines():
            if line.find('Realtek')!=-1:
                cmd = "sudo usb_reset /dev/bus/usb/"+line[4:7]+"/"+line[15:18]
                stdout=Proc(cmd).call().stdout
                print(cmd + ' ' +stdout)
    return ticks, temperature
开发者ID:mtossain,项目名称:koperwiekweg,代码行数:25,代码来源:rain_daemon.py

示例2: test_slowshot_wrap

 def test_slowshot_wrap(self):
     disp = SmartDisplay(visible=0)
     py = path(__file__).parent / ('slowgui.py')
     proc = EasyProcess('python ' + py)
     f = disp.wrap(proc.wrap(disp.waitgrab))
     img = f()
     eq_(img is not None, True)
开发者ID:AvdN,项目名称:PyVirtualDisplay,代码行数:7,代码来源:test_smart.py

示例3: prog_shot

def prog_shot(cmd, f, wait, timeout, screen_size, visible, bgcolor, cwd=None):
    '''start process in headless X and create screenshot after 'wait' sec.
    Repeats screenshot until it is not empty if 'repeat_if_empty'=True.

    wait: wait at least N seconds after first window is displayed,
    it can be used to skip splash screen

    :param enable_crop: True -> crop screenshot
    :param wait: int
    '''
    disp = SmartDisplay(visible=visible, size=screen_size, bgcolor=bgcolor)
    disp.pyscreenshot_backend = None
    disp.pyscreenshot_childprocess = True
    proc = EasyProcess(cmd, cwd=cwd)

    def func():
        try:
            img = disp.waitgrab(timeout=timeout)
        except DisplayTimeoutError as e:
            raise DisplayTimeoutError(str(e) + ' ' + str(proc))
        if wait:
            proc.sleep(wait)
            img = disp.grab()
        return img

    img = disp.wrap(proc.wrap(func))()
    if img:
        img.save(f)
    return (proc.stdout, proc.stderr)
开发者ID:ponty,项目名称:sphinxcontrib-programscreenshot,代码行数:29,代码来源:programscreenshot.py

示例4: test_timeout_out

 def test_timeout_out(self):
     p = EasyProcess(
         [python, '-c', "import time;print( 'start');time.sleep(5);print( 'end')"]).call(timeout=1)
     eq_(p.is_alive(), False)
     eq_(p.timeout_happened, True)
     ok_(p.return_code < 0)
     eq_(p.stdout, '')
开发者ID:ponty,项目名称:EasyProcess,代码行数:7,代码来源:test_timeout.py

示例5: test_slowshot

 def test_slowshot(self):
     disp = SmartDisplay(visible=0).start()
     py = path(__file__).parent / ('slowgui.py')
     proc = EasyProcess('python ' + py).start()
     img = disp.waitgrab()
     proc.stop()
     disp.stop()
     eq_(img is not None, True)
开发者ID:AvdN,项目名称:PyVirtualDisplay,代码行数:8,代码来源:test_smart.py

示例6: stop

    def stop(self):
        '''
        stop display

        :rtype: self
        '''
        self.redirect_display(False)
        EasyProcess.stop(self)
        return self
开发者ID:AnaPaulaRamos,项目名称:X,代码行数:9,代码来源:abstractdisplay.py

示例7: __init__

 def __init__(self):
     mutex.acquire()
     try:        
         self.display = self.search_for_display()
         while self.display in USED_DISPLAY_NR_LIST:
             self.display+=1            
         USED_DISPLAY_NR_LIST.append(self.display)
     finally:
         mutex.release()
     EasyProcess.__init__(self, self._cmd)
开发者ID:qstin,项目名称:darkmoney,代码行数:10,代码来源:abstractdisplay.py

示例8: stop

    def stop(self):
        '''
        stop display

        :rtype: self
        '''
        self.redirect_display(False)
        EasyProcess.stop(self)
        if self.use_xauth:
            self._clear_xauth()
        return self
开发者ID:ponty,项目名称:PyVirtualDisplay,代码行数:11,代码来源:abstractdisplay.py

示例9: generate

def generate():
	#get the query

	if request.method == 'POST':
		query = request.form['query']
	else:
		query = request.args.get('query')
	query = query.replace("\"","\\\"")
	command = "java -jar g.jar -qs \""+query+"\""
	command_results = EasyProcess(command).call().stdout
	result = command_results.split("RDF Output:")[1]

	return str(result)
开发者ID:noorbakerally,项目名称:sparql-server-wrapper,代码行数:13,代码来源:app.py

示例10: display

 def display(self, zipfilename='', block=True):
     fig = plt.figure()
     self.create(fig, zipfilename)
     if block:
         plt.show()
     else:
         p = EasyProcess([sys.executable,
                          '-m', 'elme.start.plot',
                          self.project.name,
                          '--plot', self.name,
                          '--zipfilename', zipfilename
                          ])
         p.start()
开发者ID:ponty,项目名称:electronic-measurements,代码行数:13,代码来源:project.py

示例11: __init__

 def __init__(self, use_xauth=False):
     mutex.acquire()
     try:
         self.display = self.search_for_display()
         while self.display in USED_DISPLAY_NR_LIST:
             self.display+=1
         USED_DISPLAY_NR_LIST.append(self.display)
     finally:
         mutex.release()
     if use_xauth and not xauth.is_installed():
         raise xauth.NotFoundError()
     self.use_xauth = use_xauth
     self._old_xauth = None
     self._xauth_filename = None
     EasyProcess.__init__(self, self._cmd)
开发者ID:ponty,项目名称:PyVirtualDisplay,代码行数:15,代码来源:abstractdisplay.py

示例12: check_buttons

def check_buttons(cmd, expect):
    with SmartDisplay(visible=VISIBLE) as disp:
        with EasyProcess(cmd):
            disp.waitgrab(timeout=TIMEOUT)
            buttons = discover_buttons()

            eq_(len(buttons), len(expect), 
                msg='dialog does not have expected buttons %s!=%s' % (buttons,expect))
            
            mouse = PyMouse()
            print 'buttons:',buttons
            for v, b in zip(expect, buttons):
                process = EasyProcess(cmd).start().sleep(1)
                mouse.click(*b.center)
                process.wait()
                eq_(process.stdout, str(v)) #dialog does not return expected value
开发者ID:gregwjacobs,项目名称:psidialogs,代码行数:16,代码来源:test_dialogs.py

示例13: test_timeout

    def test_timeout(self):
        p = EasyProcess('sleep 1').start()
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(0.2)
        eq_(p.is_alive(), True)
        p.wait(2)
        eq_(p.is_alive(), False)

        eq_(EasyProcess('sleep 0.3').call().return_code == 0, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).return_code == 0, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).return_code == 0, True)

        eq_(EasyProcess('sleep 0.3').call().timeout_happened, False)
        eq_(EasyProcess('sleep 0.3').call(timeout=0.1).timeout_happened, True)
        eq_(EasyProcess('sleep 0.3').call(timeout=1).timeout_happened, False)
开发者ID:Joshuapy,项目名称:EasyProcess,代码行数:16,代码来源:test_timeout.py

示例14: start

    def start(self):
        '''
        start display

        :rtype: self
        '''
        EasyProcess.start(self)

        # https://github.com/ponty/PyVirtualDisplay/issues/2
        self.old_display_var = os.environ[
            'DISPLAY'] if 'DISPLAY' in os.environ else ':0'

        self.redirect_display(True)
        # wait until X server is active
        # TODO: better method
        time.sleep(0.1)
        return self
开发者ID:Cfwang1337,项目名称:thinkful_mvp,代码行数:17,代码来源:abstractdisplay.py

示例15: service

def service(request, service_mock):
    port = random.randint(30000, 40000)
    p = EasyProcess('python3.4 src/service.py {}'
        'http://localhost:{}/tests/html1'            
        .format(port, service_mock.port))

    def turn_off():
        print("DOWN")
        p.stop()
        print("STDOUT: " + p.stdout)
        print("STDERROR: " + p.stderr)
        print("CODE: " + str(p.return_code))

    request.addfinalizer(turn_off)
    p.start()
    time.sleep(0.5)
    p.port = port
    return p
开发者ID:mariusavram91,项目名称:pyconie15-workshop-async-py,代码行数:18,代码来源:tests.py


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