63 lines
2.0 KiB
Python
Executable File
63 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import logging, os, pwd, sys
|
|
|
|
sys.path.insert(0, "${PYTHON_SITEPACKAGES_PATH}")
|
|
sys.path.insert(0, "${PYTHON_SITELIB_PATH}")
|
|
|
|
from bongo.cmdparse import CommandParser, Command
|
|
|
|
from bongo.storetool import BackupCommands
|
|
from bongo.storetool import CalendarCommands
|
|
from bongo.storetool import ContactCommands
|
|
from bongo.storetool import InteractiveCommands
|
|
from bongo.storetool import MailCommands
|
|
from bongo.storetool import TestCommands
|
|
from bongo.storetool import StoreCommands
|
|
|
|
parser = CommandParser()
|
|
parser.add_option("", "--host", type="string", default="localhost",
|
|
help="hostname [default %default]")
|
|
parser.add_option("", "--port", type="string", default="689",
|
|
help="port [default %default]")
|
|
parser.add_option("", "--debug", action="store_true",
|
|
help="enable debugging output")
|
|
parser.add_option("-u", "--user", type="string",
|
|
help="connect as this user")
|
|
parser.add_option("-p", "--password", type="string",
|
|
help="connect with this password")
|
|
parser.add_option("-s", "--store", type="string",
|
|
help="store (if different from user)")
|
|
|
|
parser.add_commands(BackupCommands, "Backup")
|
|
parser.add_commands(CalendarCommands, "Calendar")
|
|
parser.add_commands(ContactCommands, "Contact")
|
|
parser.add_commands(InteractiveCommands)
|
|
parser.add_commands(MailCommands, "Mail")
|
|
parser.add_commands(TestCommands, "Testing")
|
|
parser.add_commands(StoreCommands, "Store")
|
|
|
|
if __name__ == '__main__':
|
|
(command, options, args) = parser.parse_args()
|
|
|
|
formatter = logging.Formatter("%(levelname)s: %(message)s")
|
|
console = logging.StreamHandler()
|
|
console.setFormatter(formatter)
|
|
logging.root.addHandler(console)
|
|
|
|
if options.debug:
|
|
logging.root.setLevel(logging.DEBUG)
|
|
else:
|
|
logging.root.setLevel(logging.ERROR)
|
|
|
|
if command is None:
|
|
parser.print_help()
|
|
parser.exit()
|
|
|
|
parser.check_required("-u")
|
|
|
|
if options.store is None:
|
|
options.store = options.user
|
|
|
|
command.Run(options, args)
|