Esempio n. 1
0
    def test_groups(self):
        """
        CompleteGroups produces zsh shell-code that completes system group
        names.
        """
        c = usage.CompleteGroups()
        out = c._shellCode('some-option', usage._ZSH)
        self.assertEqual(out, ':group:_groups')

        c = usage.CompleteGroups(descr='some action', repeat=True)
        out = c._shellCode('some-option', usage._ZSH)
        self.assertEqual(out, '*:some action:_groups')
Esempio n. 2
0
class ServerOptions(app.ServerOptions):
    synopsis = "Usage: twistd [options]"

    optFlags = [
        ["nodaemon", "n", "don't daemonize, don't use default umask of 0077"],
        ["originalname", None, "Don't try to change the process name"],
        ["syslog", None, "Log to syslog, not to file"],
        [
            "euid",
            "",
            "Set only effective user-id rather than real user-id. "
            "(This option has no effect unless the server is running as "
            "root, in which case it means not to shed all privileges "
            "after binding ports, retaining the option to regain "
            "privileges in cases such as spawning processes. "
            "Use with caution.)",
        ],
    ]

    optParameters = [
        ["prefix", None, "twisted", "use the given prefix when syslogging"],
        ["pidfile", "", "twistd.pid", "Name of the pidfile"],
        ["chroot", None, None, "Chroot to a supplied directory before running"],
        ["uid", "u", None, "The uid to run as.", uidFromString],
        [
            "gid",
            "g",
            None,
            "The gid to run as.  If not specified, the default gid "
            "associated with the specified --uid is used.",
            gidFromString,
        ],
        ["umask", None, None, "The (octal) file creation mask to apply.", _umask],
    ]

    compData = usage.Completions(
        optActions={
            "pidfile": usage.CompleteFiles("*.pid"),
            "chroot": usage.CompleteDirs(descr="chroot directory"),
            "gid": usage.CompleteGroups(descr="gid to run as"),
            "uid": usage.CompleteUsernames(descr="uid to run as"),
            "prefix": usage.Completer(descr="syslog prefix"),
        },
    )

    def opt_version(self):
        """
        Print version information and exit.
        """
        print(
            "twistd (the Twisted daemon) {}".format(copyright.version), file=self.stdout
        )
        print(copyright.copyright, file=self.stdout)
        sys.exit()

    def postOptions(self):
        app.ServerOptions.postOptions(self)
        if self["pidfile"]:
            self["pidfile"] = os.path.abspath(self["pidfile"])
Esempio n. 3
0
class ServerOptions(app.ServerOptions):
    synopsis = "Usage: twistd [options]"

    optFlags = [
        ['nodaemon', 'n', "don't daemonize, don't use default umask of 0077"],
        ['originalname', None, "Don't try to change the process name"],
        ['syslog', None, "Log to syslog, not to file"],
        [
            'euid', '', "Set only effective user-id rather than real user-id. "
            "(This option has no effect unless the server is running as "
            "root, in which case it means not to shed all privileges "
            "after binding ports, retaining the option to regain "
            "privileges in cases such as spawning processes. "
            "Use with caution.)"
        ],
    ]

    optParameters = [
        ['prefix', None, 'twisted', "use the given prefix when syslogging"],
        ['pidfile', '', 'twistd.pid', "Name of the pidfile"],
        [
            'chroot', None, None,
            'Chroot to a supplied directory before running'
        ],
        ['uid', 'u', None, "The uid to run as.", uidFromString],
        ['gid', 'g', None, "The gid to run as.", gidFromString],
        [
            'umask', None, None, "The (octal) file creation mask to apply.",
            _umask
        ],
    ]

    compData = usage.Completions(optActions={
        "pidfile":
        usage.CompleteFiles("*.pid"),
        "chroot":
        usage.CompleteDirs(descr="chroot directory"),
        "gid":
        usage.CompleteGroups(descr="gid to run as"),
        "uid":
        usage.CompleteUsernames(descr="uid to run as"),
        "prefix":
        usage.Completer(descr="syslog prefix"),
    }, )

    def opt_version(self):
        """Print version information and exit.
        """
        print 'twistd (the Twisted daemon) %s' % copyright.version
        print copyright.copyright
        sys.exit()

    def postOptions(self):
        app.ServerOptions.postOptions(self)
        if self['pidfile']:
            self['pidfile'] = os.path.abspath(self['pidfile'])