diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-07-25 19:18:50 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-07-25 19:18:50 +0200 |
commit | 5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6 (patch) | |
tree | b1bdca0bb1c959913188cd887cc1ec353c27f60f | |
parent | bf08c26ec6e30575092b5c213d460ae1ae92c70a (diff) | |
download | bot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.tar.gz bot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.tar.bz2 bot-5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6.zip |
add pid setting for config to specify a pid path
-rwxr-xr-x | __init__.py | 10 | ||||
-rwxr-xr-x | phenny | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/__init__.py b/__init__.py index 5699583..b33d0cf 100755 --- a/__init__.py +++ b/__init__.py @@ -12,9 +12,15 @@ import bot class Watcher(object): # Cf. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496735 - def __init__(self): + def __init__(self, config): self.child = os.fork() if self.child != 0: + if config.pid is not None: + f = open(config.pid, 'w') + try: + f.write(str(self.child)) + finally: + f.close() self.watch() def watch(self): @@ -36,7 +42,7 @@ def run_phenny(config): p = bot.Phenny(config) p.run(config.host, config.port) - try: Watcher() + try: Watcher(config) except Exception, e: print >> sys.stderr, 'Warning:', e, '(in __init__.py)' @@ -148,6 +148,9 @@ def main(argv=None): if not hasattr(module, 'password'): module.password = None + if not hasattr(module, 'pid'): + module.pid = None + if module.host == 'irc.example.net': error = ('Error: you must edit the config file first!\n' + "You're currently using %s" % module.filename) |