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


Python Interrupt.setInterrupted方法代码示例

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


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

示例1: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [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

示例2: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [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

示例3: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [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: test_cppclient

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [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

示例5: interrupt_handler

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [as 别名]
def interrupt_handler(signo, frame):
    Interrupt.setInterrupted()
开发者ID:Adjyoucmp,项目名称:watchman,代码行数:4,代码来源:runtests.py

示例6: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [as 别名]
    def runTest(self):
        env = os.environ.copy()
        env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()

        def clean_file_name(name):
            name = name.replace(os.sep, '')
            name = name.replace('tests.integration', '')
            name = name.replace('.php', '')
            name = name.replace('_php', '')
            name = name.replace('.runTest', '')
            return name

        dotted = clean_file_name(os.path.normpath(self.id()))
        env['TMPDIR'] = os.path.join(TempDir.get_temp_dir().get_dir(), dotted)
        if os.name != 'nt' and len(env['TMPDIR']) > 94:
            self.fail('temp dir name %s is too long for unix domain sockets' %
                env['TMPDIR'])
        os.mkdir(env['TMPDIR'])
        env['TMP'] = env['TMPDIR']
        env['TEMP'] = env['TMPDIR']
        env['IN_PYTHON_HARNESS'] = '1'
        env['WATCHMAN_PYTHON_BINARY'] = sys.executable
        proc = subprocess.Popen(
            self.getCommandArgs(),
            cwd=env.get('WATCHMAN_SRC_DIR', os.getcwd()),
            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, stderr))
            return

        res_pat = re.compile(b'^(not )?ok (\d+) (.*)$')
        diag_pat = re.compile(b'^# (.*)$')
        plan_pat = re.compile(b'^1\.\.(\d+)$')

        # Now parse the TAP output
        lines = stdout.replace(b'\r\n', b'\n').split(b'\n')
        last_test = 0
        diags = None
        plan = None

        for line in lines:
            res = plan_pat.match(line)
            if res:
              plan = int(res.group(1))
              continue

            res = res_pat.match(line)
            if res:
                this_test = int(res.group(2))
                if this_test != last_test + 1:
                    print(stdout, stderr)
                    self.fail('Expected test number %d, got %d' % (
                        last_test + 1,
                        this_test))
                last_test = this_test
                if res.group(1) == b'not ':
                    # Failed
                    msg = line
                    if diags is not None:
                        msg = msg + b'\n' + b'\n'.join(diags)
                    self.fail(msg.decode('utf-8'))
                    failed

                diags = None
                continue

            res = diag_pat.match(line)
            if res:
                if diags is None:
                    diags = []
                diags.append(res.group(1))
                continue

            if line != b'':
                print('Invalid tap output from %s: %s' %
                      (self.id(), line))

        if plan is None:
            self.fail('no plan was observed')
        else:
            self.assertEqual(last_test, plan,
                         '%s planned %d but executed %s tests' % (
                             self.id(),
                             plan,
                             last_test))
开发者ID:danez,项目名称:watchman,代码行数:97,代码来源:test_php.py

示例7: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [as 别名]
    def runTest(self):
        env = os.environ.copy()
        env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()
        proc = subprocess.Popen(
            self.getCommandArgs(),
            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, stderr))
            return

        res_pat = re.compile('^(not )?ok (\d+) (.*)$')
        diag_pat = re.compile('^# (.*)$')

        # Now parse the TAP output
        lines = stdout.split('\n')
        # first line is the plan
        try:
            plan = int(lines.pop(0).split('..')[1])
        except Exception as e:
            self.fail(stdout + '\n' + stderr)
            return
        last_test = 0
        diags = None
        for line in lines:
            res = res_pat.match(line)
            if res:
                this_test = int(res.group(2))
                if this_test != last_test + 1:
                    print(stdout, stderr)
                    self.fail('Expected test number %d, got %d' % (
                        last_test + 1,
                        this_test))
                last_test = this_test
                if res.group(1) == 'not ':
                    # Failed
                    msg = line
                    if diags is not None:
                        msg = msg + '\n'.join(diags)
                    self.fail(msg)
                    failed

                diags = None
                continue

            res = diag_pat.match(line)
            if res:
                if diags is None:
                    diags = []
                diags.append(res.group(1))
                continue

            if line != '':
                print('Invalid tap output from %s: %s' %
                      (self.id(), line))

        self.assertEqual(last_test, plan,
                         '%s planned %d but executed %d tests' % (
                             self.id(),
                             plan,
                             last_test))
开发者ID:exponentjs,项目名称:watchman,代码行数:71,代码来源:WatchmanTapTests.py

示例8: runTest

# 需要导入模块: import Interrupt [as 别名]
# 或者: from Interrupt import setInterrupted [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)
        if os.name != "nt" and len(env["TMPDIR"]) > 94:
            self.fail("temp dir name %s is too long for unix domain sockets" % env["TMPDIR"])
        os.mkdir(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, stderr))
            return

        res_pat = re.compile("^(not )?ok (\d+) (.*)$")
        diag_pat = re.compile("^# (.*)$")
        plan_pat = re.compile("^1\.\.(\d+)$")

        # Now parse the TAP output
        lines = stdout.split("\n")
        last_test = 0
        diags = None
        plan = None

        for line in lines:
            res = plan_pat.match(line)
            if res:
                plan = int(res.group(1))
                continue

            res = res_pat.match(line)
            if res:
                this_test = int(res.group(2))
                if this_test != last_test + 1:
                    print(stdout, stderr)
                    self.fail("Expected test number %d, got %d" % (last_test + 1, this_test))
                last_test = this_test
                if res.group(1) == "not ":
                    # Failed
                    msg = line
                    if diags is not None:
                        msg = msg + "\n".join(diags)
                    self.fail(msg)
                    failed

                diags = None
                continue

            res = diag_pat.match(line)
            if res:
                if diags is None:
                    diags = []
                diags.append(res.group(1))
                continue

            if line != "":
                print("Invalid tap output from %s: %s" % (self.id(), line))

        self.assertEqual(last_test, plan, "%s planned %d but executed %s tests" % (self.id(), plan, last_test))
开发者ID:kwlzn,项目名称:watchman,代码行数:69,代码来源:WatchmanTapTests.py


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