예제 #1
0
파일: process.py 프로젝트: pycopia/devtest
    def coprocess(self, directory=None):
        """Start a coprocess server.

        Return a CoProcess object that is the manager for the coprocess.
        Use the `start` method on that to actually run coprocess method.
        """
        pid, conn = _fork_coprocess(directory)
        if pid == 0:  # child
            sys.excepthook = sys.__excepthook__
            proc = None
            signal.signal(signal.SIGCHLD, signal.SIG_DFL)
            self._procs = {}
            self._zombies = {}
            self.splitter = None
            atexit._run_exitfuncs()
            atexit._clear()
            sys.stdout.flush()
            sys.stderr.flush()
            _close_stdin()
            _redirect(1, "/tmp/devtest-coprocess-{}.stdout".format(os.getpid()))
            _redirect(2, "/tmp/devtest-coprocess-{}.stderr".format(os.getpid()))
            try:
                get_kernel().run(_coprocess_server_coro, conn)
            except KeyboardInterrupt:
                pass
            except:  # noqa
                traceback.print_exc(file=sys.stderr)
            os._exit(0)
        else:
            proc = CoProcess(pid, conn)
            proc.progname = "CoProcess"
            self._procs[proc.pid] = proc
        logging.notice("ProcessManager: coprocess server with PID: {}".format(pid))
        return proc
예제 #2
0
    def _find_board_temp_file(self):
        """Find the thermal subystem temperature file to use for the board temperature.

        Use the THROTTLING-NOTIFY2 config.
        """
        config_section = self._config.get("THROTTLING-NOTIFY2")
        if config_section is None:
            raise AndroidControllerError(
                "No THROTTLING-NOTIFY2 section in config")
        # Find the right thermal_zone path for that sensor type.
        sensor_type = config_section["sensor"]
        sensor_path = None
        ac = self._cont.adb.async_client

        async def match_entry(st, name):
            nonlocal sensor_path
            if stat.S_ISDIR(st.st_mode):
                if name.startswith("thermal_zone"):
                    tpath = os.path.join(self.THERMAL_BASE, name, "type")
                    out, err, es = await ac.command(["cat", tpath])
                    if es:
                        if out.strip() == sensor_type:
                            sensor_path = os.path.join(self.THERMAL_BASE, name,
                                                       "temp")

        reactor.get_kernel().run(ac.list(self.THERMAL_BASE, match_entry))
        return sensor_path
예제 #3
0
파일: process.py 프로젝트: pycopia/devtest
def start_process(cmd, delaytime=1.0, **kwargs):
    """Start a process and wait delaytime before returning.

    Gives spawned process a chance to initialize.
    """
    proc = get_kernel().run(start_and_delay(cmd, delaytime, **kwargs))
    get_manager().run_exit_handlers()
    return proc
예제 #4
0
파일: process.py 프로젝트: pycopia/devtest
 def run_process(self, proc, timeout=None, input=None):
     """Take a Process instance and communicate with it.
     """
     coro = _run_proc(proc, input)
     if timeout:
         coro = timeout_after(float(timeout), coro)
     output = get_kernel().run(coro)
     if isinstance(output, Exception):
         raise output
     return output
예제 #5
0
파일: process.py 프로젝트: pycopia/devtest
    def call_command(self, cmd, directory=None):
        """Run command, does not collect output.

        Inherits main thread stdio.

        Returns an ExitStatus instance from command.
        """
        proc = self.start(cmd, stdin=None, stdout=None, stderr=None,
                          directory=directory)
        retcode = get_kernel().run(_call_proc(proc))
        return exitstatus.ExitStatus(0, name=proc.progname, returncode=retcode)
예제 #6
0
파일: process.py 프로젝트: pycopia/devtest
 def ping(self):
     """Verify server is running."""
     return get_kernel().run(self.aping)
예제 #7
0
파일: process.py 프로젝트: pycopia/devtest
 def close(self):
     get_kernel().run(self.aclose)
예제 #8
0
파일: time.py 프로젝트: pycopia/devtest
def delay(secs):
    return get_kernel().run(sleep(secs))
예제 #9
0
def _send_message(tag, data):
    kern = get_kernel()
    return kern.run(_send_message_coro(tag, data))
예제 #10
0
파일: process.py 프로젝트: pycopia/devtest
 def write(self, data):
     kern = get_kernel()
     rv = kern.run(self.stdin.write(data))
     kern.run(self.stdin.flush())
     return rv
예제 #11
0
파일: process.py 프로젝트: pycopia/devtest
 def readlines(self):
     return get_kernel().run(self.stdout.readlines())
예제 #12
0
파일: process.py 프로젝트: pycopia/devtest
 def read(self, amt=-1):
     return get_kernel().run(self.stdout.read(amt))
예제 #13
0
파일: process.py 프로젝트: pycopia/devtest
 def syncwait(self):
     return get_kernel().run(self._popen.wait())
예제 #14
0
 def test_fdsignals(self):
     kern = reactor.get_kernel()
     kern.run(_signals_test_main)
예제 #15
0
 def test_fdtimer(self):
     kern = reactor.get_kernel()
     kern.run(_timer_test_main)
예제 #16
0
파일: process.py 프로젝트: pycopia/devtest
 def start(self, func, *args):
     """Start a method or function in the coprocess.
     """
     return get_kernel().run(self.astart, func, args)
예제 #17
0
파일: process.py 프로젝트: pycopia/devtest
def run_coroutine(coro):
    return get_kernel().run(coro)
예제 #18
0
파일: process.py 프로젝트: pycopia/devtest
 def wait(self):
     logging.debug("CoProcess: waiting on: {}".format(self.pid))
     return get_kernel().run(self.a_wait)
예제 #19
0
def main(argv):
    pathname = argv[1]
    kern = reactor.get_kernel()
    return kern.run(adb_list, os.environ["ANDROID_SERIAL"], pathname)
예제 #20
0
def main(argv):
    kern = reactor.get_kernel()
    kern.run(adb_events, os.environ["ANDROID_SERIAL"])