diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-08 13:25:44 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-08 13:25:44 -0400 |
| commit | 8864a4018c9b9088f330c3ef24ed7b5313ec36a2 (patch) | |
| tree | 2fe858d60c8c0a41b97002216949097887652f82 /run | |
| parent | 56a7f70965a17509898cf9e7eafb4e13208e5358 (diff) | |
Added -j option to send jabber update messages.
Diffstat (limited to 'run')
| -rw-r--r-- | run/experiment.py | 2 | ||||
| -rw-r--r-- | run/jabber.py | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/run/experiment.py b/run/experiment.py index ecb0241..03d6ab6 100644 --- a/run/experiment.py +++ b/run/experiment.py | |||
| @@ -52,7 +52,7 @@ class Experiment(object): | |||
| 52 | self.log("Enabling sched_trace") | 52 | self.log("Enabling sched_trace") |
| 53 | self.tracers.append( SchedTracer(working_dir) ) | 53 | self.tracers.append( SchedTracer(working_dir) ) |
| 54 | if LinuxTracer.enabled(): | 54 | if LinuxTracer.enabled(): |
| 55 | self.log("Enabling trace-cmd / ftrace / kernelshark") | 55 | self.log("Enabling trace-cmd") |
| 56 | self.tracers.append( LinuxTracer(working_dir) ) | 56 | self.tracers.append( LinuxTracer(working_dir) ) |
| 57 | if LogTracer.enabled(): | 57 | if LogTracer.enabled(): |
| 58 | self.log("Enabling logging") | 58 | self.log("Enabling logging") |
diff --git a/run/jabber.py b/run/jabber.py new file mode 100644 index 0000000..c9dd097 --- /dev/null +++ b/run/jabber.py | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | import os | ||
| 3 | import sys | ||
| 4 | import xmpp | ||
| 5 | |||
| 6 | class Jabber(object): | ||
| 7 | def __init__(self, target): | ||
| 8 | self.target = target | ||
| 9 | self.client = self.__create_client() | ||
| 10 | |||
| 11 | def __create_client(self): | ||
| 12 | params = {} | ||
| 13 | conf_file = os.environ['HOME'] + '/.xsend' | ||
| 14 | |||
| 15 | if os.access(conf_file, os.R_OK): | ||
| 16 | for line in open(conf_file, 'r').readlines(): | ||
| 17 | key, val = line.strip().split('=', 1) | ||
| 18 | params[key.lower()] = val | ||
| 19 | |||
| 20 | for field in ['login', 'password']: | ||
| 21 | if field not in params.keys(): | ||
| 22 | with open(conf_file, 'wc') as f: | ||
| 23 | f.write('#LOGIN=romeo@montague.net\n#PASSWORD=juliet\n') | ||
| 24 | raise IOError("Please ensure the ~/.xsend file has valid "+\ | ||
| 25 | "credentials for sending messages.") | ||
| 26 | |||
| 27 | jid = xmpp.protocol.JID(params['login']) | ||
| 28 | client = xmpp.Client(jid.getDomain(), debug=[]) | ||
| 29 | |||
| 30 | client.connect(server=(jid.getDomain(), 5223)) | ||
| 31 | client.auth(jid.getNode(), params['password']) | ||
| 32 | |||
| 33 | sys.stderr.write(("Jabber client loaded. Add '%s' to your friends " + \ | ||
| 34 | "or Jabber messages will not send") % params['login']) | ||
| 35 | |||
| 36 | return client | ||
| 37 | |||
| 38 | def send(self, text): | ||
| 39 | message = xmpp.protocol.Message(to=self.target, body=text, typ='chat') | ||
| 40 | self.client.send(message) | ||
