當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。