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


Python util.sibpath方法代码示例

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


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

示例1: testFullAppend

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testFullAppend(self):
        infile = util.sibpath(__file__, 'rfc822.message')
        message = open(infile)
        SimpleServer.theAccount.addMailbox('root/subthing')
        def login():
            return self.client.login(b'testuser', b'password-test')
        def append():
            return self.client.append(
                'root/subthing',
                message,
                ('\\SEEN', '\\DELETED'),
                'Tue, 17 Jun 2003 11:22:16 -0600 (MDT)',
            )

        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(append), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        return d.addCallback(self._cbTestFullAppend, infile) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_imap.py

示例2: testPartialAppend

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testPartialAppend(self):
        infile = util.sibpath(__file__, 'rfc822.message')
        SimpleServer.theAccount.addMailbox('PARTIAL/SUBTHING')
        def login():
            return self.client.login(b'testuser', b'password-test')
        def append():
            message = open(infile)
            return self.client.sendCommand(
                imap4.Command(
                    'APPEND',
                    'PARTIAL/SUBTHING (\\SEEN) "Right now" {%d}' % os.path.getsize(infile),
                    (), self.client._IMAP4Client__cbContinueAppend, message
                )
            )
        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(append), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        return d.addCallback(self._cbTestPartialAppend, infile) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_imap.py

示例3: test_FileRebuild

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_FileRebuild(self):
        from twisted.python.util import sibpath
        import shutil, time
        shutil.copyfile(sibpath(__file__, "myrebuilder1.py"),
                        os.path.join(self.fakelibPath, "myrebuilder.py"))
        from twisted_rebuild_fakelib import myrebuilder
        a = myrebuilder.A()
        b = myrebuilder.B()
        i = myrebuilder.Inherit()
        self.assertEqual(a.a(), 'a')
        # Necessary because the file has not "changed" if a second has not gone
        # by in unix.  This sucks, but it's not often that you'll be doing more
        # than one reload per second.
        time.sleep(1.1)
        shutil.copyfile(sibpath(__file__, "myrebuilder2.py"),
                        os.path.join(self.fakelibPath, "myrebuilder.py"))
        rebuild.rebuild(myrebuilder)
        b2 = myrebuilder.B()
        self.assertEqual(b2.b(), 'c')
        self.assertEqual(b.b(), 'c')
        self.assertEqual(i.a(), 'd')
        self.assertEqual(a.a(), 'b') 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:test_rebuild.py

示例4: test_directory

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_directory(self):
        """
        Test loader against a filesystem directory. It should handle
        'path' and 'path/' the same way.
        """
        path  = util.sibpath(__file__, 'goodDirectory')
        os.mkdir(path)
        f = file(os.path.join(path, '__init__.py'), "w")
        f.close()
        try:
            module = runner.filenameToModule(path)
            self.assert_(module.__name__.endswith('goodDirectory'))
            module = runner.filenameToModule(path + os.path.sep)
            self.assert_(module.__name__.endswith('goodDirectory'))
        finally:
            shutil.rmtree(path) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:test_loader.py

示例5: testFullAppend

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testFullAppend(self):
        infile = util.sibpath(__file__, 'rfc822.message')
        message = open(infile)
        SimpleServer.theAccount.addMailbox('root/subthing')
        def login():
            return self.client.login('testuser', 'password-test')
        def append():
            return self.client.append(
                'root/subthing',
                message,
                ('\\SEEN', '\\DELETED'),
                'Tue, 17 Jun 2003 11:22:16 -0600 (MDT)',
            )

        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(append), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        return d.addCallback(self._cbTestFullAppend, infile) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:test_imap.py

示例6: testPartialAppend

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testPartialAppend(self):
        infile = util.sibpath(__file__, 'rfc822.message')
        message = open(infile)
        SimpleServer.theAccount.addMailbox('PARTIAL/SUBTHING')
        def login():
            return self.client.login('testuser', 'password-test')
        def append():
            message = file(infile)
            return self.client.sendCommand(
                imap4.Command(
                    'APPEND',
                    'PARTIAL/SUBTHING (\\SEEN) "Right now" {%d}' % os.path.getsize(infile),
                    (), self.client._IMAP4Client__cbContinueAppend, message
                )
            )
        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(append), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        return d.addCallback(self._cbTestPartialAppend, infile) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:test_imap.py

示例7: testStdio

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testStdio(self):
        """twisted.internet.stdio test."""
        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_twisted.py")
        p = Accumulator()
        d = p.endedDeferred = defer.Deferred()
        env = {"PYTHONPATH": os.pathsep.join(sys.path)}
        reactor.spawnProcess(p, exe, [exe, "-u", scriptPath], env=env,
                             path=None, usePTY=self.usePTY)
        p.transport.write("hello, world")
        p.transport.write("abc")
        p.transport.write("123")
        p.transport.closeStdin()

        def processEnded(ign):
            self.assertEquals(p.outF.getvalue(), "hello, worldabc123",
                              "Output follows:\n"
                              "%s\n"
                              "Error message from process_twisted follows:\n"
                              "%s\n" % (p.outF.getvalue(), p.errF.getvalue()))
        return d.addCallback(processEnded) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:test_process.py

示例8: test_unsetPid

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_unsetPid(self):
        """
        Test if pid is None/non-None before/after process termination.  This
        reuses process_echoer.py to get a process that blocks on stdin.
        """
        finished = defer.Deferred()
        p = TrivialProcessProtocol(finished)
        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_echoer.py")
        procTrans = reactor.spawnProcess(p, exe,
                                    [exe, scriptPath], env=None)
        self.failUnless(procTrans.pid)

        def afterProcessEnd(ignored):
            self.assertEqual(procTrans.pid, None)

        p.transport.closeStdin()
        return finished.addCallback(afterProcessEnd) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:test_process.py

示例9: testManyProcesses

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testManyProcesses(self):

        def _check(results, protocols):
            for p in protocols:
                self.assertEquals(p.stages, [1, 2, 3, 4, 5], "[%d] stages = %s" % (id(p.transport), str(p.stages)))
                # test status code
                f = p.reason
                f.trap(error.ProcessTerminated)
                self.assertEquals(f.value.exitCode, 23)

        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_tester.py")
        args = [exe, "-u", scriptPath]
        protocols = []
        deferreds = []

        for i in xrange(50):
            p = TestManyProcessProtocol()
            protocols.append(p)
            reactor.spawnProcess(p, exe, args, env=None)
            deferreds.append(p.deferred)

        deferredList = defer.DeferredList(deferreds, consumeErrors=True)
        deferredList.addCallback(_check, protocols)
        return deferredList 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:27,代码来源:test_process.py

示例10: test_echo

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_echo(self):
        """
        A spawning a subprocess which echoes its stdin to its stdout via
        C{reactor.spawnProcess} will result in that echoed output being
        delivered to outReceived.
        """
        finished = defer.Deferred()
        p = EchoProtocol(finished)

        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_echoer.py")
        reactor.spawnProcess(p, exe, [exe, scriptPath], env=None)

        def asserts(ignored):
            self.failIf(p.failure, p.failure)
            self.failUnless(hasattr(p, 'buffer'))
            self.assertEquals(len(''.join(p.buffer)), len(p.s * p.n))

        def takedownProcess(err):
            p.transport.closeStdin()
            return err

        return finished.addCallback(asserts).addErrback(takedownProcess) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:25,代码来源:test_process.py

示例11: testOpeningTTY

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def testOpeningTTY(self):
        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_tty.py")
        p = Accumulator()
        d = p.endedDeferred = defer.Deferred()
        reactor.spawnProcess(p, exe, [exe, "-u", scriptPath], env=None,
                            path=None, usePTY=self.usePTY)
        p.transport.write("hello world!\n")

        def processEnded(ign):
            self.assertRaises(
                error.ProcessExitedAlready, p.transport.signalProcess, 'HUP')
            self.assertEquals(
                p.outF.getvalue(),
                "hello world!\r\nhello world!\r\n",
                "Error message from process_tty follows:\n\n%s\n\n" % p.outF.getvalue())
        return d.addCallback(processEnded) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_process.py

示例12: startServer

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def startServer(self, cgi):
        root = resource.Resource()
        cgipath = util.sibpath(__file__, cgi)
        root.putChild("cgi", PythonScript(cgipath))
        site = server.Site(root)
        self.p = reactor.listenTCP(0, site)
        return self.p.getHost().port 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_cgi.py

示例13: sibpath

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def sibpath(filename):
    """
    For finding files in twisted/trial/test
    """
    return util.sibpath(__file__, filename) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_script.py

示例14: test_testmoduleOnModule

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_testmoduleOnModule(self):
        """
        Check that --testmodule loads a suite which contains the tests
        referred to in test-case-name inside its parameter.
        """
        self.config.opt_testmodule(sibpath('moduletest.py'))
        self.assertSuitesEqual(trial._getSuite(self.config),
                               ['twisted.trial.test.test_log']) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_script.py

示例15: test_testmoduleTwice

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import sibpath [as 别名]
def test_testmoduleTwice(self):
        """
        When the same module is specified with two --testmodule flags, it
        should only appear once in the suite.
        """
        self.config.opt_testmodule(sibpath('moduletest.py'))
        self.config.opt_testmodule(sibpath('moduletest.py'))
        self.assertSuitesEqual(trial._getSuite(self.config),
                               ['twisted.trial.test.test_log']) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_script.py


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