Permalink
Browse files

Mac client integration support

  • Loading branch information...
1 parent ca8dd5b commit bdd7013bea23c20407f6d7f0371e0798bd9375f4 @nwgh nwgh committed Aug 9, 2012
Showing with 83 additions and 2 deletions.
  1. +23 −0 osx/org.mozilla.srdns.plist
  2. +31 −0 osx/org.mozilla.stoneridge_cronjob.plist
  3. +29 −2 srdns.py
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>org.mozilla.srdns</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/bin/python</string>
+ <string>/Users/hurley/srhome/stoneridge/srdns.py</string>
+ <string>--nodaemon</string>
+ </array>
+ <key>KeepAlive</key>
+ <true/>
+ <key>WorkingDirectory</key>
+ <string>/Users/hurley/srhome/stoneridge</string>
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>PATH</key>
+ <string>/usr/local/share/python:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin</string>
+ </dict>
+</dict>
+</plist>
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>org.mozilla.stoneridge_cronjob</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/bin/python</string>
+ <string>/Users/hurley/srhome/stoneridge/stoneridge_cronjob.py</string>
+ <string>--config</string>
+ <string>/Users/hurley/srhome/stoneridge.ini</string>
+ </array>
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Hour</key>
+ <integer>12</integer>
+ </dict>
+ <key>KeepAlive</key>
+ <false/>
+ <key>RunAtLoad</key>
+ <false/>
+ <key>WorkingDirectory</key>
+ <string>/Users/hurley/srhome/stoneridge</string>
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>PATH</key>
+ <string>/usr/local/share/python:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin</string>
+ </dict>
+</dict>
+</plist>
View
@@ -12,6 +12,7 @@
import SocketServer
import struct
import subprocess
+import sys
import tempfile
import stoneridge
@@ -157,11 +158,37 @@ def daemon():
shutil.rmtree(rundir)
+def do_exit(parser, msg):
+ parser.print_usage()
+ parser.exit(2, msg % (parser.prog,))
+
+def do_mutex_exit(parser, arg):
+ msg = '%%s: error: argument %s: not allowed with argument --nodaemon\n'
+ do_exit(parser, msg % (arg,))
+
+def do_missing_exit(parser, arg):
+ msg = '%%s: error: argument %s is required\n'
+ do_exit(parser, msg % (arg,))
+
@stoneridge.main
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--pidfile', dest='pidfile', required=True)
- parser.add_argument('--log', dest='log', required=True)
+ parser.add_argument('--pidfile', dest='pidfile')
+ parser.add_argument('--log', dest='log')
+ parser.add_argument('--nodaemon', dest='nodaemon', action='store_true')
args = parser.parse_args()
+ if args.nodaemon:
+ if args.pidfile:
+ do_mutex_exit(parser, '--pidfile')
+ if args.log:
+ do_mutex_exit(parser, '--log')
+ daemon()
+ sys.exit(0)
+
+ if not args.pidfile:
+ do_missing_exit(parser, '--pidfile')
+ if not args.log:
+ do_missing_exit(parser, '--log')
+
daemonize.start(daemon, args.pidfile, args.log)

0 comments on commit bdd7013

Please sign in to comment.