add PasteDeploy dependency, remove pudge dependency
* upgrade migrate repository structure (fixes #32, #27) * switch to PasteDeploy (fixes #31) * update for SQLAlchemy 0.5 compatibility * add python-gnutls dependency (addresses #35)
This commit is contained in:
parent
483c1f9038
commit
222b35b033
24 changed files with 247 additions and 177 deletions
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
# Copyright (C) 2007, 2008, 2009 by Jan Dittberner.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -197,9 +197,10 @@ Common options:
|
|||
sys.exit()
|
||||
self._handleoption(subcommand, o, a)
|
||||
|
||||
def __init__(self, args):
|
||||
def __init__(self, args, config):
|
||||
"""This initializes the command with the given command line
|
||||
arguments and executes it."""
|
||||
self.config = config
|
||||
self.logger = logging.getLogger("%s.%s" % (
|
||||
self.__class__.__module__, self.__class__.__name__))
|
||||
self._data = {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
# Copyright (C) 2007, 2008, 2009 by Jan Dittberner.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,3 +24,39 @@ This package provides modules for the command line interface of the
|
|||
gnuviechadmin server administration suite."""
|
||||
|
||||
__all__ = ["client", "sysuser", "domain", "record"]
|
||||
|
||||
from logging import getLogger
|
||||
from sys import exit
|
||||
|
||||
|
||||
class CommandLineInterface(object):
|
||||
|
||||
def __init__(self, config, args):
|
||||
self.log = getLogger(__name__)
|
||||
self.config = config
|
||||
if len(args) < 2:
|
||||
self._usage(args[0])
|
||||
exit(1)
|
||||
self.commands = [command for command in self._get_commands() \
|
||||
if command.name == args[1]]
|
||||
self.cmdargs = args[2:]
|
||||
|
||||
|
||||
def _usage(self, callee):
|
||||
print """%s <command> [commandargs]
|
||||
|
||||
where command is one of
|
||||
""" % callee
|
||||
for command in self._get_commands():
|
||||
print "%10s - %s" % (command.name, command.description)
|
||||
|
||||
def run(self):
|
||||
for cmd in self.commands:
|
||||
cmd(self.cmdargs, self.config)
|
||||
|
||||
def _get_commands(self):
|
||||
from gnuviechadmin.cli.client import ClientCli
|
||||
from gnuviechadmin.cli.sysuser import SysuserCli
|
||||
from gnuviechadmin.cli.domain import DomainCli
|
||||
from gnuviechadmin.cli.record import RecordCli
|
||||
return [ClientCli, SysuserCli, DomainCli, RecordCli]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
||||
# Copyright (C) 2007, 2008, 2009 by Jan Dittberner.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -61,24 +61,25 @@ class ClientCli(CliCommand.CliCommand):
|
|||
def _execute(self, subcommand):
|
||||
self.logger.debug("execute %s with data %s", subcommand,
|
||||
str(self._data))
|
||||
from gnuviechadmin.backend import client
|
||||
from gnuviechadmin import exceptions
|
||||
from gnuviechadmin.backend.client import ClientHandler
|
||||
from gnuviechadmin.exceptions import CreationFailedError
|
||||
if subcommand == "create":
|
||||
try:
|
||||
myclient = client.ClientHandler(self._verbose).create(
|
||||
**self._data)
|
||||
myclient = ClientHandler(self.config,
|
||||
self._verbose).create(**self._data)
|
||||
if self._verbose:
|
||||
print myclient
|
||||
except exceptions.CreationFailedError, cfe:
|
||||
except CreationFailedError, cfe:
|
||||
self._usage()
|
||||
print cfe
|
||||
sys.exit(2)
|
||||
elif subcommand == "list":
|
||||
clients = client.ClientHandler(self._verbose).fetchall()
|
||||
clients = ClientHandler(self.config, self._verbose).fetchall()
|
||||
for client in clients:
|
||||
print client
|
||||
elif subcommand == "delete":
|
||||
client.ClientHandler(self._verbose).delete(self._data["clientid"])
|
||||
ClientHandler(self.config,
|
||||
self._verbose).delete(self._data["clientid"])
|
||||
|
||||
def __init__(self, argv):
|
||||
CliCommand.CliCommand.__init__(self, argv)
|
||||
def __init__(self, argv, config):
|
||||
CliCommand.CliCommand.__init__(self, argv, config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue