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


Python WatchmanInstance类代码示例

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


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

示例1: runner

def runner():
    global results_queue
    global tests_queue

    try:
        # Start up a shared watchman instance for the tests.
        inst = WatchmanInstance.Instance()
        inst.start()
        # Allow tests to locate this default instance
        WatchmanInstance.setSharedInstance(inst)
    except Exception as e:
        print('This is going to suck:', e)
        return

    while True:
        test = tests_queue.get()
        try:
            if test == 'terminate':
                break

            if Interrupt.wasInterrupted():
                continue

            try:
                result = Result()
                test.run(result)
                results_queue.put(result)
            except Exception as e:
                print(e)

        finally:
            tests_queue.task_done()

    inst.stop()
开发者ID:exponentjs,项目名称:watchman,代码行数:34,代码来源:runtests.py

示例2: runTest

    def runTest(self):
        env = os.environ.copy()
        env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()
        dotted = os.path.normpath(self.id()).replace(os.sep, '.').replace(
            'tests.integration.', '').replace('.php', '')
        env['TMPDIR'] = os.path.join(tempfile.tempdir, dotted)
        os.mkdir(env['TMPDIR'])
        env['TMP'] = env['TMPDIR']
        env['TEMP'] = env['TMPDIR']
        env['IN_PYTHON_HARNESS'] = '1'
        proc = subprocess.Popen(
            self.getCommandArgs(),
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        (stdout, stderr) = proc.communicate()
        status = proc.poll()

        if status == -signal.SIGINT:
            Interrupt.setInterrupted()
            self.fail('Interrupted by SIGINT')
            return

        if status != 0:
            self.fail("Exit status %d\n%s\n%s\n" %
                      (status, stdout.decode('utf-8'), stderr.decode('utf-8')))
            return
        self.assertTrue(True, self.jsfile)
开发者ID:1514louluo,项目名称:watchman,代码行数:28,代码来源:NodeTests.py

示例3: runTest

    def runTest(self):
        env = os.environ.copy()
        env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()
        dotted = os.path.normpath(self.id()).replace(os.sep, '.').replace(
            'tests.integration.', '').replace('.php', '')
        env['TMPDIR'] = os.path.join(TempDir.get_temp_dir().get_dir(), dotted)
        os.mkdir(env['TMPDIR'])

        # build the node module with npm
        node_dir = os.path.join(env['TMPDIR'], 'fb-watchman')
        shutil.copytree(os.path.join(WATCHMAN_SRC_DIR, 'node'), node_dir)
        subprocess.check_call(['npm', 'install'], cwd=node_dir)

        env['TMP'] = env['TMPDIR']
        env['TEMP'] = env['TMPDIR']
        env['IN_PYTHON_HARNESS'] = '1'
        env['NODE_PATH'] = '%s:%s' % (env['TMPDIR'], env.get('NODE_PATH', ''))
        proc = subprocess.Popen(
            self.getCommandArgs(),
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        (stdout, stderr) = proc.communicate()
        status = proc.poll()

        if status == -signal.SIGINT:
            Interrupt.setInterrupted()
            self.fail('Interrupted by SIGINT')
            return

        if status != 0:
            self.fail("Exit status %d\n%s\n%s\n" %
                      (status, stdout.decode('utf-8'), stderr.decode('utf-8')))
            return
        self.assertTrue(True, self.getCommandArgs())
开发者ID:danez,项目名称:watchman,代码行数:35,代码来源:test_nodejs.py

示例4: runTest

    def runTest(self):
        env = os.environ.copy()
        env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
        env["TMPDIR"] = self.tempdir

        # build the node module with npm
        node_dir = os.path.join(env["TMPDIR"], "fb-watchman")
        shutil.copytree(os.path.join(WATCHMAN_SRC_DIR, "node"), node_dir)
        subprocess.check_call(["npm", "install"], cwd=node_dir)

        env["TMP"] = env["TMPDIR"]
        env["TEMP"] = env["TMPDIR"]
        env["IN_PYTHON_HARNESS"] = "1"
        env["NODE_PATH"] = "%s:%s" % (env["TMPDIR"], env.get("NODE_PATH", ""))
        proc = subprocess.Popen(
            self.getCommandArgs(),
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        (stdout, stderr) = proc.communicate()
        status = proc.poll()

        if status == -signal.SIGINT:
            Interrupt.setInterrupted()
            self.fail("Interrupted by SIGINT")
            return

        if status != 0:
            self.fail(
                "Exit status %d\n%s\n%s\n"
                % (status, stdout.decode("utf-8"), stderr.decode("utf-8"))
            )
            return
        self.assertTrue(True, self.getCommandArgs())
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:35,代码来源:test_nodejs.py

示例5: getClient

 def getClient(self):
     if not hasattr(self, 'client'):
         self.client = pywatchman.client(
             transport=self.transport,
             sendEncoding=self.encoding,
             recvEncoding=self.encoding,
             sockpath=WatchmanInstance.getSharedInstance().getSockPath())
     return self.client
开发者ID:ezhangle,项目名称:watchman,代码行数:8,代码来源:WatchmanTestCase.py

示例6: dumpLogs

    def dumpLogs(self):
        ''' used in travis CI to show the hopefully relevant log snippets '''
        inst = WatchmanInstance.getSharedInstance()

        def tail(logstr, n):
            lines = logstr.split('\n')[-n:]
            return '\n'.join(lines)

        print(self.getLogSample())
开发者ID:niclasr,项目名称:watchman,代码行数:9,代码来源:WatchmanTestCase.py

示例7: getClient

 def getClient(self):
     if not hasattr(self, 'client'):
         self.client = pywatchman.client(
             # ASAN-enabled builds can be slower enough that we hit timeouts
             # with the default of 1 second
             timeout=3.0,
             transport=self.transport,
             sendEncoding=self.encoding,
             recvEncoding=self.encoding,
             sockpath=WatchmanInstance.getSharedInstance().getSockPath())
     return self.client
开发者ID:chenzhanyiczy,项目名称:watchman,代码行数:11,代码来源:WatchmanTestCase.py

示例8: getLogSample

    def getLogSample(self):
        ''' used in CI to show the hopefully relevant log snippets '''
        inst = WatchmanInstance.getSharedInstance()

        def tail(logstr, n):
            lines = logstr.split('\n')[-n:]
            return '\n'.join(lines)

        return '\n'.join([
            'CLI logs',
            tail(inst.getCLILogContents(), 500),
            'Server logs',
            tail(inst.getServerLogContents(), 500),
        ])
开发者ID:niclasr,项目名称:watchman,代码行数:14,代码来源:WatchmanTestCase.py

示例9: getClient

 def getClient(self, inst=None, replace_cached=False, no_cache=False):
     if inst or not hasattr(self, "client") or no_cache:
         client = pywatchman.client(
             timeout=self.socketTimeout,
             transport=self.transport,
             sendEncoding=self.encoding,
             recvEncoding=self.encoding,
             sockpath=(inst or WatchmanInstance.getSharedInstance()).getSockPath(),
         )
         if (not inst or replace_cached) and not no_cache:
             # only cache the client if it points to the shared instance
             self.client = client
             self.addCleanup(lambda: self.__clearClient())
         return client
     return self.client
开发者ID:facebook,项目名称:watchman,代码行数:15,代码来源:WatchmanTestCase.py

示例10: getLogSample

    def getLogSample(self):
        """ used in CI to show the hopefully relevant log snippets """
        inst = WatchmanInstance.getSharedInstance()

        def tail(logstr, n):
            lines = logstr.split("\n")[-n:]
            return "\n".join(lines)

        return "\n".join(
            [
                "CLI logs",
                tail(inst.getCLILogContents(), 500),
                "Server logs",
                tail(inst.getServerLogContents(), 500),
            ]
        )
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:16,代码来源:WatchmanTestCase.py

示例11: getClient

 def getClient(self, inst=None):
     if inst or not hasattr(self, 'client'):
         client = pywatchman.client(
             # ASAN-enabled builds can be slower enough that we hit timeouts
             # with the default of 1 second
             timeout=3.0,
             transport=self.transport,
             sendEncoding=self.encoding,
             recvEncoding=self.encoding,
             sockpath=(inst or
                       WatchmanInstance.getSharedInstance()).getSockPath())
         if not inst:
             # only cache the client if it points to the shared instance
             self.client = client
         return client
     return self.client
开发者ID:danez,项目名称:watchman,代码行数:16,代码来源:WatchmanTestCase.py

示例12: spawnWatchmanWait

    def spawnWatchmanWait(self, cmdArgs):
        wait_script = os.environ.get("WATCHMAN_WAIT_PATH")
        if wait_script:
            args = [wait_script]
        else:
            args = [
                sys.executable,
                os.path.join(os.environ["WATCHMAN_PYTHON_BIN"], "watchman-wait"),
            ]
        args.extend(cmdArgs)

        env = os.environ.copy()
        sock_path = WatchmanInstance.getSharedInstance().getSockPath()
        env["WATCHMAN_SOCK"] = sock_path
        env["PYTHONPATH"] = env["PYWATCHMAN_PATH"]
        return subprocess.Popen(
            args, env=env, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:18,代码来源:test_wm_wait.py

示例13: test_cppclient

    def test_cppclient(self):
        env = os.environ.copy()
        env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
        proc = subprocess.Popen(
            TEST_BINARY, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        (stdout, stderr) = proc.communicate()
        status = proc.poll()

        if status == -signal.SIGINT:
            Interrupt.setInterrupted()
            self.fail("Interrupted by SIGINT")
            return

        if status != 0:
            self.fail(
                "Exit status %d\n%s\n%s\n"
                % (status, stdout.decode("utf-8"), stderr.decode("utf-8"))
            )
            return

        self.assertTrue(True, TEST_BINARY)
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:22,代码来源:test_cppclient.py

示例14: hg

    def hg(self, args=None, cwd=None):
        env = dict(os.environ)
        env['HGPLAIN'] = '1'
        env['HGUSER'] = 'John Smith <[email protected]>'
        env['NOSCMLOG'] = '1'  # disable some instrumentation at FB
        env['WATCHMAN_SOCK'] = \
                WatchmanInstance.getSharedInstance().getSockPath()
        p = subprocess.Popen(
            # we force the extension on.  This is a soft error for
            # mercurial if it is not available, so we also employ
            # the skipIfNoFSMonitor() test above to make sure the
            # environment is sane.
            ['hg', '--config', 'extensions.fsmonitor='] + args,
            env=env,
            cwd=cwd,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception("hg %r failed: %s, %s" % (args, out, err))

        return out, err
开发者ID:niclasr,项目名称:watchman,代码行数:22,代码来源:test_scm.py

示例15: hg

    def hg(self, args=None, cwd=None):
        env = dict(os.environ)
        env["HGPLAIN"] = "1"
        env["HGUSER"] = "John Smith <[email protected]>"
        env["NOSCMLOG"] = "1"  # disable some instrumentation at FB
        env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
        p = subprocess.Popen(
            # we force the extension on.  This is a soft error for
            # mercurial if it is not available, so we also employ
            # the skipIfNoFSMonitor() test above to make sure the
            # environment is sane.
            [env.get("EDEN_HG_BINARY", "hg"), "--config", "extensions.fsmonitor="]
            + args,
            env=env,
            cwd=cwd,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception("hg %r failed: %s, %s" % (args, out, err))

        return out, err
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:23,代码来源:test_scm.py


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