示例#1
0
def main():
    try:
        # Load system configuration
        conf = parse_arguments()

        # Send logging output to a file if specified
        configure_log(conf["log.file"])

        # Look for available commands
        commands = find_commands("cmds/", conf["home.dir"])

        # Core components
        auth = AuthManager(conf["home.dir"] + "/users.auth")
        commander = Commander(auth)
        scanner = MailScanner(Parsers(commands))
        notifier = EmailNotifier(conf["smtp.host"], conf["smtp.port"])

        # Read the email from stdin
        email = UnicodeParser().parse(sys.stdin)

        cmd_id, data, sprops, authkey = scanner.scan(email)
        auth_users = [ key.user for key in auth.keys[cmd_id] if key.user ]

        command = commands[cmd_id]
        output = commander.execute(command, data, authkey)

        if output:
            notifier.send(SuccessNotification(conf["notification.sender"], \
                                              auth_users, command, sprops))
    except AuthException, err:
        notifier.send(AuthNotification(cmd_id, conf["commander.address"], \
                                       auth_users, email, data))
示例#2
0
def main():
    try:
        # Load system configuration
        conf = parse_arguments()

        # Send logging output to a file if specified
        configure_log(conf["log.file"])

        # Look for available commands
        commands = find_commands("cmds/", conf["home.dir"])

        # Core components
        auth = AuthManager(conf["home.dir"] + "/users.auth")
        commander = Commander(auth)
        scanner = MailScanner(Parsers(commands))
        notifier = EmailNotifier(conf["smtp.host"], conf["smtp.port"])

        # Read the email from stdin
        email = UnicodeParser().parse(sys.stdin)

        cmd_id, data, sprops, authkey = scanner.scan(email)
        auth_users = [key.user for key in auth.keys[cmd_id] if key.user]

        command = commands[cmd_id]
        output = commander.execute(command, data, authkey)

        if output:
            notifier.send(SuccessNotification(conf["notification.sender"], \
                                              auth_users, command, sprops))
    except AuthException, err:
        notifier.send(AuthNotification(cmd_id, conf["commander.address"], \
                                       auth_users, email, data))
示例#3
0
    def __init__(self, name):
        unittest.TestCase.__init__(self, name)

        commands = find_commands("test/cmds/")

        name = "test"
        self.command = commands[name]

        self.text = """
    def __init__(self, name):
        unittest.TestCase.__init__(self, name)

        commands = find_commands("test/cmds/")

        name = "test"
        self.command = commands[name]

        self.data = {"name": "MR SCRUFF", "hobby": "scruff", "color": "yellow"}
    def __init__(self, name):
        TestCase.__init__(self, name)

        self.commands = find_commands("test/cmds/")

        self.auth = AuthManager("test/etc/users.auth")
        self.commander = Commander(self.auth)

        self.scanner = MailScanner(Parsers(self.commands))
        self.email = UnicodeParser().parse(open("test/data/cmd.email"))

        self.notifier = EmailNotifier("10.2.1.2", 25)
    def __init__(self, name):
        TestCase.__init__(self, name)
        
        self.commands = find_commands("test/cmds/")

        self.auth = AuthManager("test/etc/users.auth")
        self.commander = Commander(self.auth)
        
        self.scanner = MailScanner(Parsers(self.commands))
        self.email = UnicodeParser().parse(open("test/data/cmd.email"))

        self.notifier = EmailNotifier("10.2.1.2", 25)
    def __init__(self, name):
        unittest.TestCase.__init__(self, name)

        commands = find_commands("test/cmds/")

        name = "test"
        self.command = commands[name]

        self.data = {
            "name": "MR SCRUFF",
            "hobby": "scruff",
            "color": "yellow"
        }
示例#8
0
import os

from parser import DataParser
from commands import Command
from util import find_classes, find_commands


def class_found(klass, cwd):
    print "Found: %s" % (klass.__name__)


print "FIND CLASSES"
find_classes(Command, "cmds/", class_found)

print "FIND COMMANDS"
print find_commands("test/cmds/")

#print find_commands(cwd, "cmds")
示例#9
0
import os

from parser import DataParser
from commands import Command
from util import find_classes, find_commands

def class_found(klass, cwd):
    print "Found: %s" % (klass.__name__)

print "FIND CLASSES"
find_classes(Command, "cmds/", class_found)

print "FIND COMMANDS"
print find_commands("test/cmds/")

#print find_commands(cwd, "cmds")