aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlas Oliva <blas@gcoop.coop>2015-05-10 22:45:42 -0300
committerBlas Oliva <blas@gcoop.coop>2015-05-10 22:45:42 -0300
commitd408f4427c9e195be4347e095585b2e76c85717d (patch)
treedad8371d1c5c1ea9aa2203da51de0e7e7512eb7e
parent5dc77a485d60716d657453635602b98a5624ee32 (diff)
downloadreebot-d408f4427c9e195be4347e095585b2e76c85717d.tar.gz
reebot-d408f4427c9e195be4347e095585b2e76c85717d.zip
reebot matate
-rw-r--r--reefuncs.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/reefuncs.py b/reefuncs.py
index ade775e..cc7c057 100644
--- a/reefuncs.py
+++ b/reefuncs.py
@@ -28,16 +28,16 @@ class reefuncs:
28 28
29 # Adding arguments 29 # Adding arguments
30 parser.add_argument('-t', '--task', type=self.task, help='show task status', action='store', dest='task', nargs='+') 30 parser.add_argument('-t', '--task', type=self.task, help='show task status', action='store', dest='task', nargs='+')
31 parser.add_argument('-p', '--ping', type=self.ping, help='send ping to server', action='store', dest='host', nargs='+') 31 # parser.add_argument('-p', '--ping', type=self.ping, help='send ping to server', action='store', dest='host', nargs='+')
32 parser.add_argument('-m', '--msg', help='send message', action='store', dest='message', nargs='+') 32 parser.add_argument('-m', '--msg', help='send message', action='store', dest='message', nargs='+')
33 parser.add_argument('-i', '--info', type=self.info, help='print host information', action='store', dest='hostname', nargs='+') 33 # parser.add_argument('-i', '--info', type=self.info, help='print host information', action='store', dest='hostname', nargs='+')
34 parser.add_argument('-k', '--matate', type=self.matate, help='killing myself', action='store', dest='matate') 34 parser.add_argument('-k', '--matate', type=self.matate, help='killing myself', action='store', dest='matate')
35 35
36 # Parsing arguments 36 # Parsing arguments
37 args = parser.parse_args(arguments.split()) 37 args = parser.parse_args(arguments.split())
38 38
39 # Put responses in a list (the library may already do this...) 39 # Put responses in a list (the library may already do this...)
40 responses = [args.task, args.host, args.hostname, args.message] 40 responses = [args.task, args.message]
41 41
42 # Return responses 42 # Return responses
43 for r in responses: 43 for r in responses:
@@ -55,13 +55,13 @@ class reefuncs:
55 rc = killreebot.returncode 55 rc = killreebot.returncode
56 return rc 56 return rc
57 57
58 def ping(self, host): 58 # def ping(self, host):
59 """ Send ping to host """ 59 # """ Send ping to host """
60 msg = [] 60 # msg = []
61 cmd = ['ping', '-c 1', host] 61 # cmd = ['ping', '-c 1', host]
62 ping = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 62 # ping = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
63 out, err = ping.communicate() 63 # out, err = ping.communicate()
64 rc = ping.returncode 64 # rc = ping.returncode
65 msg.append('Host %s is %s\n' % \ 65 # msg.append('Host %s is %s\n' % \
66 (host, 'up' if rc == 0 else 'down')) 66 # (host, 'up' if rc == 0 else 'down'))
67 return '\n'.join(msg) 67 # return '\n'.join(msg)