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


Python WatchmanInstance.getSharedInstance方法代码示例

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


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

示例1: runTest

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:30,代码来源:NodeTests.py

示例2: runTest

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:37,代码来源:test_nodejs.py

示例3: runTest

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:37,代码来源:test_nodejs.py

示例4: getClient

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
 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,代码行数:10,代码来源:WatchmanTestCase.py

示例5: dumpLogs

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:11,代码来源:WatchmanTestCase.py

示例6: getClient

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
 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,代码行数:13,代码来源:WatchmanTestCase.py

示例7: getLogSample

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:16,代码来源:WatchmanTestCase.py

示例8: getClient

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
 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,代码行数:17,代码来源:WatchmanTestCase.py

示例9: getLogSample

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:18,代码来源:WatchmanTestCase.py

示例10: getClient

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
 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,代码行数:18,代码来源:WatchmanTestCase.py

示例11: spawnWatchmanWait

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:20,代码来源:test_wm_wait.py

示例12: test_cppclient

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:24,代码来源:test_cppclient.py

示例13: hg

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:24,代码来源:test_scm.py

示例14: hg

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
    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,代码行数:25,代码来源:test_scm.py

示例15: getServerLogContents

# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import getSharedInstance [as 别名]
 def getServerLogContents(self):
     """
     Returns the contents of the server log file as an array
     that has already been split by line.
     """
     return WatchmanInstance.getSharedInstance().getServerLogContents().split("\n")
开发者ID:Stevenzwzhai,项目名称:watchman,代码行数:8,代码来源:WatchmanTestCase.py


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