- remove __all__ from util/__init__.py, no module uses from import *
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 30 Nov 2009 23:29:30 +0000 (23:29 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 30 Nov 2009 23:29:30 +0000 (23:29 +0000)
- fix import path for tools/getsshkeys.py
- add reboot.py to commands. it just uses monitor/reboot.py

commands/reboot.py [new file with mode: 0644]
monitor/bootman.py
monitor/reboot.py
monitor/util/__init__.py
tools/getsshkeys.py

diff --git a/commands/reboot.py b/commands/reboot.py
new file mode 100644 (file)
index 0000000..8b373d2
--- /dev/null
@@ -0,0 +1,35 @@
+from monitor.reboot import *
+
+def main():
+       logger.setLevel(logging.DEBUG)
+       ch = logging.StreamHandler()
+       ch.setLevel(logging.DEBUG)
+       formatter = logging.Formatter('LOGGER - %(message)s')
+       ch.setFormatter(formatter)
+       logger.addHandler(ch)
+
+       try:
+               if "test" in sys.argv:
+                       dryrun = True
+               else:
+                       dryrun = False
+
+               for node in sys.argv[1:]:
+                       if node == "test": continue
+
+                       print "Rebooting %s" % node
+                       if reboot_policy(node, True, dryrun):
+                               print "success"
+                       else:
+                               print "failed"
+       except Exception, err:
+               import traceback; traceback.print_exc()
+               from monitor.common import email_exception
+               email_exception(node)
+               print err
+
+if __name__ == '__main__':
+       main()
+       f = open("/tmp/rebootlog", 'a')
+       f.write("reboot %s\n" % sys.argv)
+       f.close()
index 1dd22cd..eac2761 100755 (executable)
@@ -826,4 +826,4 @@ def restore_basic(sitehist, hostname, config=None, forced_action=None):
        
 
 if __name__ == "__main__":
-       print "ERROR: Can not execute module as a command! Please use commands/%s." % __file__
+       print "ERROR: Can not execute module as a command! Please use commands/%s.py" % os.path.splitext(__file__)[0]
index 15d5c52..cd49a59 100755 (executable)
@@ -108,37 +108,6 @@ def reboot_policy(nodename, continue_probe, dryrun):
                print "return true"
                return True
 
-def main():
-       logger.setLevel(logging.DEBUG)
-       ch = logging.StreamHandler()
-       ch.setLevel(logging.DEBUG)
-       formatter = logging.Formatter('LOGGER - %(message)s')
-       ch.setFormatter(formatter)
-       logger.addHandler(ch)
+if __name__ == "__main__":
+       print "ERROR: Can not execute module as a command! Please use commands/%s.py" % os.path.splitext(__file__)[0]
 
-       try:
-               if "test" in sys.argv:
-                       dryrun = True
-               else:
-                       dryrun = False
-
-               for node in sys.argv[1:]:
-                       if node == "test": continue
-
-                       print "Rebooting %s" % node
-                       if reboot_policy(node, True, dryrun):
-                               print "success"
-                       else:
-                               print "failed"
-       except Exception, err:
-               import traceback; traceback.print_exc()
-               from monitor.common import email_exception
-               email_exception(node)
-               print err
-
-if __name__ == '__main__':
-       logger = logging.getLogger("monitor")
-       main()
-       f = open("/tmp/rebootlog", 'a')
-       f.write("reboot %s\n" % sys.argv)
-       f.close()
index 98802a3..c5a3dfd 100644 (file)
@@ -1,4 +1,3 @@
-__all__=["writepid","removepid","daemonize"]
 
 import time
 import math
index ed90652..0104deb 100755 (executable)
@@ -1,7 +1,10 @@
 #!/usr/bin/python
 
 import sys
-from monitor.util.sshknownhosts import SSHKnownHosts
+sys.path.append('.')
+sys.path.append('..')
+
+from monitor.util.file import *
 
 def main(hosts):
        k = SSHKnownHosts()