Browse Source

Created the initial skeleton implementation of jwmud.

Helmut Pozimski 10 years ago
parent
commit
1f11aceeb7
3 changed files with 70 additions and 1 deletions
  1. 1 1
      README
  2. 2 0
      TODO
  3. 67 0
      jwmud

+ 1 - 1
README

@@ -1,7 +1,7 @@
 About
 =====
 
-jwmud is a simple daemon implemented in python that's initended to be used
+jwmud is a simple daemon implemented in python that's intended to be used
 on low-power devices like the Raspberry Pi to turn them into an alarm clock.
 
 It allows you to set different times you want to be waked for the days of the

+ 2 - 0
TODO

@@ -10,6 +10,7 @@ TODO for jwmud
 * Implement setup.py
 * Create debian packaging infomation
 * Implement argument parsing based on argparser
+* Create a man page
 
 TODO for jwmuc
 ==============
@@ -18,3 +19,4 @@ TODO for jwmuc
 * Also use argparser for this tool
 * Use logger for stdout and sterr logging
 * Implement parsing of Ical files for import into categories
+* Create a man page

+ 67 - 0
jwmud

@@ -0,0 +1,67 @@
+#! /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)
+