Code style changes
* make code PEP8 clean (addresses #18) * add copyright information to all python files git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@257 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
7c4d25da43
commit
09180938f1
45 changed files with 759 additions and 514 deletions
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,10 +18,12 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
|
||||
import getopt, sys, logging
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
from gnuviechadmin.exceptions import GnuviechadminError
|
||||
|
||||
|
||||
class CliCommand:
|
||||
"""Base class for command line interface.
|
||||
|
||||
|
@ -65,17 +66,17 @@ Common options:
|
|||
|
||||
%(option)s
|
||||
%(mandatory)s %(optiondesc)s
|
||||
""" % { 'called' : sys.argv[0],
|
||||
'command' : self.name,
|
||||
'description' : self.description,
|
||||
'option' : '-v, --verbose',
|
||||
'optiondesc' : 'verbose operation',
|
||||
'mandatory' : " "}
|
||||
""" % {'called': sys.argv[0],
|
||||
'command': self.name,
|
||||
'description': self.description,
|
||||
'option': '-v, --verbose',
|
||||
'optiondesc': 'verbose operation',
|
||||
'mandatory': " "}
|
||||
for commandname in self._optionmap.keys():
|
||||
cmdl = "%(called)s %(command)s %(subcommand)s [-v|--verbose]" % {
|
||||
'called' : sys.argv[0],
|
||||
'command' : self.name,
|
||||
'subcommand' : commandname}
|
||||
'called': sys.argv[0],
|
||||
'command': self.name,
|
||||
'subcommand': commandname}
|
||||
desc = """
|
||||
%s
|
||||
""" % (self._optionmap[commandname][0])
|
||||
|
@ -97,9 +98,9 @@ Common options:
|
|||
if not mandatory:
|
||||
cmd = cmd + "]"
|
||||
descmap = {
|
||||
'option' : ", ".join(pairs),
|
||||
'optiondesc' : optiondesc,
|
||||
'mandatory' : ' '}
|
||||
'option': ", ".join(pairs),
|
||||
'optiondesc': optiondesc,
|
||||
'mandatory': ' '}
|
||||
if mandatory:
|
||||
descmap['mandatory'] = '*'
|
||||
desc = desc + """ %(option)s
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,7 +18,6 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
|
||||
"""This is the gnuviechadmin.cli package.
|
||||
|
||||
This package provides modules for the command line interface of the
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,8 +18,9 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
import CliCommand
|
||||
import sys
|
||||
|
||||
import CliCommand, sys
|
||||
|
||||
class ClientCli(CliCommand.CliCommand):
|
||||
"""Command line interface command for client management."""
|
||||
|
@ -28,37 +28,36 @@ class ClientCli(CliCommand.CliCommand):
|
|||
name = "client"
|
||||
description = "manage clients"
|
||||
_optionmap = {
|
||||
'create' : ("creates a new client",
|
||||
[(["-f", "--firstname"], "firstname",
|
||||
"the client's first name", True),
|
||||
(["-l", "--lastname"], "lastname",
|
||||
"the client's last name", True),
|
||||
(["-t", "--title"], "title",
|
||||
"the client's title", False),
|
||||
(["-a", "--address"], "address1",
|
||||
"the address of the client", True),
|
||||
(["--address2"], "address2",
|
||||
"second line of the client's address", False),
|
||||
(["-z", "--zip"], "zip",
|
||||
"the zipcode of the client's address", True),
|
||||
(["-c", "--city"], "city",
|
||||
"the city of the client's address", True),
|
||||
(["--country"], "country",
|
||||
"the client's country", False),
|
||||
(["-e", "--email"], "email",
|
||||
"the client's email address", True),
|
||||
(["-p", "--phone"], "phone",
|
||||
"the client's phone number", True),
|
||||
(["-m", "--mobile"], "mobile",
|
||||
"the client's mobile phone number", False),
|
||||
(["-x", "--fax"], "fax",
|
||||
"the client's fax number", False)]),
|
||||
'list' : ("lists existing clients",
|
||||
[]),
|
||||
'delete' : ("deletes the specified client if it has no dependent data",
|
||||
[(["-c", "--clientid"], "clientid",
|
||||
"the client id", True)])}
|
||||
|
||||
'create': ("creates a new client",
|
||||
[(["-f", "--firstname"], "firstname",
|
||||
"the client's first name", True),
|
||||
(["-l", "--lastname"], "lastname",
|
||||
"the client's last name", True),
|
||||
(["-t", "--title"], "title",
|
||||
"the client's title", False),
|
||||
(["-a", "--address"], "address1",
|
||||
"the address of the client", True),
|
||||
(["--address2"], "address2",
|
||||
"second line of the client's address", False),
|
||||
(["-z", "--zip"], "zip",
|
||||
"the zipcode of the client's address", True),
|
||||
(["-c", "--city"], "city",
|
||||
"the city of the client's address", True),
|
||||
(["--country"], "country",
|
||||
"the client's country", False),
|
||||
(["-e", "--email"], "email",
|
||||
"the client's email address", True),
|
||||
(["-p", "--phone"], "phone",
|
||||
"the client's phone number", True),
|
||||
(["-m", "--mobile"], "mobile",
|
||||
"the client's mobile phone number", False),
|
||||
(["-x", "--fax"], "fax",
|
||||
"the client's fax number", False)]),
|
||||
'list': ("lists existing clients", []),
|
||||
'delete': ("deletes the specified client if it has no dependent data",
|
||||
[(["-c", "--clientid"], "clientid",
|
||||
"the client id", True)])}
|
||||
|
||||
def _execute(self, subcommand):
|
||||
self.logger.debug("execute %s with data %s", subcommand,
|
||||
str(self._data))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,8 +18,9 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
import CliCommand
|
||||
import sys
|
||||
|
||||
import CliCommand, sys
|
||||
|
||||
class DomainCli(CliCommand.CliCommand):
|
||||
"""Command line interface command for domain management."""
|
||||
|
@ -28,20 +28,19 @@ class DomainCli(CliCommand.CliCommand):
|
|||
name = "domain"
|
||||
description = "manage domains"
|
||||
_optionmap = {
|
||||
'create' : ("creates a new domain",
|
||||
[(["-n", "--name"], "name",
|
||||
"the domain name", True),
|
||||
(["-t", "--type"], "type",
|
||||
"domain type m for master or s for slave", False),
|
||||
(["-m", "--master"], "master",
|
||||
"master server for slave domains", False),
|
||||
(["-s", "--sysuserid"], "sysuserid",
|
||||
"system user id", True)]),
|
||||
'list' : ("lists existing domains",
|
||||
[]),
|
||||
'delete' : ("delete a domain",
|
||||
[(["-d", "--domainid"], "domainid",
|
||||
"the domain id", True)])}
|
||||
'create': ("creates a new domain",
|
||||
[(["-n", "--name"], "name",
|
||||
"the domain name", True),
|
||||
(["-t", "--type"], "type",
|
||||
"domain type m for master or s for slave", False),
|
||||
(["-m", "--master"], "master",
|
||||
"master server for slave domains", False),
|
||||
(["-s", "--sysuserid"], "sysuserid",
|
||||
"system user id", True)]),
|
||||
'list': ("lists existing domains", []),
|
||||
'delete': ("delete a domain",
|
||||
[(["-d", "--domainid"], "domainid",
|
||||
"the domain id", True)])}
|
||||
|
||||
def _execute(self, subcommand):
|
||||
self.logger.debug("execute %s with data %s", subcommand,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,8 +18,9 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
import CliCommand
|
||||
import sys
|
||||
|
||||
import CliCommand, sys
|
||||
|
||||
class RecordCli(CliCommand.CliCommand):
|
||||
"""Command line interface command for DNS record management."""
|
||||
|
@ -28,25 +28,25 @@ class RecordCli(CliCommand.CliCommand):
|
|||
name = "record"
|
||||
description = "manage DNS records"
|
||||
_optionmap = {
|
||||
'create' : ("creates a new record",
|
||||
[(["-n", "--name"], "name",
|
||||
"the record name", True),
|
||||
(["-t", "--type"], "type",
|
||||
"record type", True),
|
||||
(["-c", "--content"], "content",
|
||||
"record content", True),
|
||||
(["-p", "--prio"], "prio",
|
||||
"MX record priority", False),
|
||||
(["--ttl"], "ttl",
|
||||
"time to live", False),
|
||||
(["-d", "--domainid"], "domainid",
|
||||
"domain id", True)]),
|
||||
'list' : ("lists existing records",
|
||||
[(["-d", "--domainid"], "domainid",
|
||||
"domain id", False)]),
|
||||
'delete' : ("delete a record",
|
||||
[(["-r", "--recordid"], "recordid",
|
||||
"the record id", True)])}
|
||||
'create': ("creates a new record",
|
||||
[(["-n", "--name"], "name",
|
||||
"the record name", True),
|
||||
(["-t", "--type"], "type",
|
||||
"record type", True),
|
||||
(["-c", "--content"], "content",
|
||||
"record content", True),
|
||||
(["-p", "--prio"], "prio",
|
||||
"MX record priority", False),
|
||||
(["--ttl"], "ttl",
|
||||
"time to live", False),
|
||||
(["-d", "--domainid"], "domainid",
|
||||
"domain id", True)]),
|
||||
'list': ("lists existing records",
|
||||
[(["-d", "--domainid"], "domainid",
|
||||
"domain id", False)]),
|
||||
'delete': ("delete a record",
|
||||
[(["-r", "--recordid"], "recordid",
|
||||
"the record id", True)])}
|
||||
|
||||
def _execute(self, subcommand):
|
||||
self.logger.debug("execute %s with data %s", subcommand,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
|
@ -19,33 +18,33 @@
|
|||
# USA.
|
||||
#
|
||||
# Version: $Id$
|
||||
import CliCommand
|
||||
import sys
|
||||
|
||||
import CliCommand, sys
|
||||
|
||||
class SysuserCli(CliCommand.CliCommand):
|
||||
"""Command line interface command for system user managament."""
|
||||
|
||||
name = "sysuser"
|
||||
name = "sysuser"
|
||||
description = "manage system users"
|
||||
_optionmap = {
|
||||
"create" : ("create a new system user with the given options.",
|
||||
[(["-n", "--username"], "username",
|
||||
"the system user name", False),
|
||||
(["-t", "--usertype"], "usertype",
|
||||
"the numeric user type", False),
|
||||
(["-h", "--home"], "home",
|
||||
"the home directory", False),
|
||||
(["-s", "--shell"], "shell",
|
||||
"true if the user should get shell access", False),
|
||||
(["-p", "--password"], "clearpass",
|
||||
"the password for the user", False),
|
||||
(["-c", "--clientid"], "clientid",
|
||||
"the client id", True)]),
|
||||
"list" : ("list existing system users.",
|
||||
[]),
|
||||
"delete" : ("delete a system user.",
|
||||
[(["-s", "--sysuserid"], "sysuserid",
|
||||
"the system user id", True)])}
|
||||
_optionmap = {
|
||||
"create": ("create a new system user with the given options.",
|
||||
[(["-n", "--username"], "username",
|
||||
"the system user name", False),
|
||||
(["-t", "--usertype"], "usertype",
|
||||
"the numeric user type", False),
|
||||
(["-h", "--home"], "home",
|
||||
"the home directory", False),
|
||||
(["-s", "--shell"], "shell",
|
||||
"true if the user should get shell access", False),
|
||||
(["-p", "--password"], "clearpass",
|
||||
"the password for the user", False),
|
||||
(["-c", "--clientid"], "clientid",
|
||||
"the client id", True)]),
|
||||
"list": ("list existing system users.", []),
|
||||
"delete": ("delete a system user.",
|
||||
[(["-s", "--sysuserid"], "sysuserid",
|
||||
"the system user id", True)])}
|
||||
|
||||
def _execute(self, subcommand):
|
||||
self.logger.debug("execute %s with data %s", subcommand,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue