• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python _twistd_unix.UnixApplicationRunner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_removePIDErrors

 def test_removePIDErrors(self):
     """
     Calling L{UnixApplicationRunner.removePID} with a non-existent filename logs
     an OSError.
     """
     runner = UnixApplicationRunner({})
     runner.removePID("fakepid")
     errors = self.flushLoggedErrors(OSError)
     self.assertEquals(len(errors), 1)
     self.assertEquals(errors[0].value.errno, errno.ENOENT)
开发者ID:P13RR3,项目名称:FrostCore,代码行数:10,代码来源:test_twistd.py


示例2: test_removePID

 def test_removePID(self):
     """
     L{UnixApplicationRunner.removePID} deletes the file the name of
     which is passed to it.
     """
     runner = UnixApplicationRunner({})
     path = self.mktemp()
     os.makedirs(path)
     pidfile = os.path.join(path, "foo.pid")
     file(pidfile, "w").close()
     runner.removePID(pidfile)
     self.assertFalse(os.path.exists(pidfile))
开发者ID:P13RR3,项目名称:FrostCore,代码行数:12,代码来源:test_twistd.py


示例3: test_setupEnvironment

    def test_setupEnvironment(self):
        """
        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        """
        options = twistd.ServerOptions()
        options.parseOptions([
                '--nodaemon',
                '--umask', '0070',
                '--chroot', '/foo/chroot',
                '--rundir', '/foo/rundir',
                '--pidfile', '/foo/pidfile'])
        application = service.Application("test_setupEnvironment")
        self.runner = UnixApplicationRunner(options)

        args = []
        def fakeSetupEnvironment(self, chroot, rundir, nodaemon, umask, pidfile):
            args.extend((chroot, rundir, nodaemon, umask, pidfile))

        # Sanity check
        self.assertEqual(
            inspect.getargspec(self.runner.setupEnvironment),
            inspect.getargspec(fakeSetupEnvironment))

        self.patch(UnixApplicationRunner, 'setupEnvironment', fakeSetupEnvironment)
        self.patch(UnixApplicationRunner, 'shedPrivileges', lambda *a, **kw: None)
        self.patch(app, 'startApplication', lambda *a, **kw: None)
        self.runner.startApplication(application)

        self.assertEqual(
            args,
            ['/foo/chroot', '/foo/rundir', True, 56, '/foo/pidfile'])
开发者ID:P13RR3,项目名称:FrostCore,代码行数:34,代码来源:test_twistd.py


示例4: setUp

 def setUp(self):
     self.root = self.unset
     self.cwd = self.unset
     self.mask = self.unset
     self.daemon = False
     self.pid = os.getpid()
     self.patch(os, 'chroot', lambda path: setattr(self, 'root', path))
     self.patch(os, 'chdir', lambda path: setattr(self, 'cwd', path))
     self.patch(os, 'umask', lambda mask: setattr(self, 'mask', mask))
     self.patch(_twistd_unix, "daemonize", self.daemonize)
     self.runner = UnixApplicationRunner({})
开发者ID:P13RR3,项目名称:FrostCore,代码行数:11,代码来源:test_twistd.py


示例5: UnixApplicationRunnerSetupEnvironmentTests

class UnixApplicationRunnerSetupEnvironmentTests(unittest.TestCase):
    """
    Tests for L{UnixApplicationRunner.setupEnvironment}.

    @ivar root: The root of the filesystem, or C{unset} if none has been
        specified with a call to L{os.chroot} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests.chroot ).

    @ivar cwd: The current working directory of the process, or C{unset} if
        none has been specified with a call to L{os.chdir} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.chdir).

    @ivar mask: The current file creation mask of the process, or C{unset} if
        none has been specified with a call to L{os.umask} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.umask).

    @ivar daemon: A boolean indicating whether daemonization has been performed
        by a call to L{_twistd_unix.daemonize} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests.
    """
    if _twistd_unix is None:
        skip = "twistd unix not available"

    unset = object()

    def setUp(self):
        self.root = self.unset
        self.cwd = self.unset
        self.mask = self.unset
        self.daemon = False
        self.pid = os.getpid()
        self.patch(os, 'chroot', lambda path: setattr(self, 'root', path))
        self.patch(os, 'chdir', lambda path: setattr(self, 'cwd', path))
        self.patch(os, 'umask', lambda mask: setattr(self, 'mask', mask))
        self.patch(_twistd_unix, "daemonize", self.daemonize)
        self.runner = UnixApplicationRunner({})


    def daemonize(self):
        """
        Indicate that daemonization has happened and change the PID so that the
        value written to the pidfile can be tested in the daemonization case.
        """
        self.daemon = True
        self.patch(os, 'getpid', lambda: self.pid + 1)


    def test_chroot(self):
        """
        L{UnixApplicationRunner.setupEnvironment} changes the root of the
        filesystem if passed a non-C{None} value for the C{chroot} parameter.
        """
        self.runner.setupEnvironment("/foo/bar", ".", True, None, None)
        self.assertEqual(self.root, "/foo/bar")


    def test_noChroot(self):
        """
        L{UnixApplicationRunner.setupEnvironment} does not change the root of
        the filesystem if passed C{None} for the C{chroot} parameter.
        """
        self.runner.setupEnvironment(None, ".", True, None, None)
        self.assertIdentical(self.root, self.unset)


    def test_changeWorkingDirectory(self):
        """
        L{UnixApplicationRunner.setupEnvironment} changes the working directory
        of the process to the path given for the C{rundir} parameter.
        """
        self.runner.setupEnvironment(None, "/foo/bar", True, None, None)
        self.assertEqual(self.cwd, "/foo/bar")


    def test_daemonize(self):
        """
        L{UnixApplicationRunner.setupEnvironment} daemonizes the process if
        C{False} is passed for the C{nodaemon} parameter.
        """
        self.runner.setupEnvironment(None, ".", False, None, None)
        self.assertTrue(self.daemon)


    def test_noDaemonize(self):
        """
        L{UnixApplicationRunner.setupEnvironment} does not daemonize the
        process if C{True} is passed for the C{nodaemon} parameter.
        """
        self.runner.setupEnvironment(None, ".", True, None, None)
        self.assertFalse(self.daemon)


    def test_nonDaemonPIDFile(self):
        """
        L{UnixApplicationRunner.setupEnvironment} writes the process's PID to
        the file specified by the C{pidfile} parameter.
        """
        pidfile = self.mktemp()
        self.runner.setupEnvironment(None, ".", True, None, pidfile)
        fObj = file(pidfile)
#.........这里部分代码省略.........
开发者ID:P13RR3,项目名称:FrostCore,代码行数:101,代码来源:test_twistd.py


示例6: postApplication

    def postApplication(self):
        reactor.callLater(0, self.start_globaleaks)

        UnixApplicationRunner.postApplication(self)
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:4,代码来源:runner.py


示例7: postApplication

 def postApplication(self):
     self.createOpenvpn2DnsService()
     from twisted.internet import reactor
     deferLater(reactor, 1, self.zones.start_notify)
     UnixApplicationRunner.postApplication(self)
开发者ID:algby,项目名称:openvpn2dns,代码行数:5,代码来源:launch.py


示例8: __init__

 def __init__(self, config, twisted_config):
     UnixApplicationRunner.__init__(self, twisted_config)
     self.service_config = config
开发者ID:algby,项目名称:openvpn2dns,代码行数:3,代码来源:launch.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python trial._getLoader函数代码示例发布时间:2022-05-27
下一篇:
Python _twistd_unix.UnixAppLogger类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap