12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #! /usr/bin/env python3
- #jwmud - a program to create dynamic alarms based on configurable wake up
- # times
- #
- # written by Helmut Pozimski 2012-2014
- #
- # 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 the Free Software Foundation; version 2
- # of the License.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor,
- # Boston, MA 02110-1301, USA.
- import logging
- import logging.handlers
- import argparse
- import sys
- import os
- from jwmudlib import database
- from jwmudlib import jwmu_exceptions
- from jwmudlib import daemon
- parser = argparse.ArgumentParser(prog="jwmud", add_help=True)
- parser.add_argument("-d", "--daemon", action="store_true", dest="daemon",
- help="run jwmud as a daemon")
- parser.add_argument("-u", "--user", dest="user", help="define an unprivileged "
- "user to run the daemon")
- parser.add_argument("-g", "--group", dest="group", help = "define an "
- "unprivileged group "
- "to run the daemon")
- parser.add_argument("-c", "--config", dest="config", help="define an alternate"
- " path to the "
- "configuration file")
- arguments = parser.parse_args()
- # TODO: Implement configuration and insert it here
- logger = logging.getLogger("jwmud")
- # TODO: Set log level according to configuration
- logger.setLevel(logging.INFO)
- formatter = logging.Formatter("%(name)s[" + str(os.getpid()) + "]: %(message)s")
- # TODO: Set syslog facility according to configuration
- if arguments.daemon is True:
- syslog_handler = logging.handlers.SysLogHandler("/dev/log")
- syslog_handler.setFormatter(formatter)
- logger.addHandler(syslog_handler)
- else:
- console_handler = logging.StreamHandler()
- console_handler.setFormatter(formatter)
- logger.addHandler(console_handler)
|