aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-07-11 17:48:49 -0400
committerbnewbold <bnewbold@robocracy.org>2012-07-11 17:48:49 -0400
commitabaec3f515523310a8b743f13d60b905885a9f13 (patch)
tree3cf02adf6b889330e49cdd268dd5c1df7a4596af
parentbb0ec725b508e339ff790eb63c0bf193c14a20c7 (diff)
downloadexmachina-abaec3f515523310a8b743f13d60b905885a9f13.tar.gz
exmachina-abaec3f515523310a8b743f13d60b905885a9f13.zip
close methods, quiet mode, more tests
-rwxr-xr-xexmachina.py9
-rwxr-xr-xtest.py4
2 files changed, 13 insertions, 0 deletions
diff --git a/exmachina.py b/exmachina.py
index a72ac55..229a465 100755
--- a/exmachina.py
+++ b/exmachina.py
@@ -141,6 +141,9 @@ class ExMachinaClient():
self.initd.start = self.conn.call.initd_start
self.initd.stop = self.conn.call.initd_stop
self.initd.restart = self.conn.call.initd_restart
+
+ def close(self):
+ self.sock.close()
def run_server(socket_path="/tmp/exmachina.sock"):
# TODO: check for root permissions, warn if not root
@@ -174,6 +177,10 @@ def main():
default=False,
help="Show more debugging statements",
action="store_true")
+ parser.add_option("-q", "--quiet",
+ default=False,
+ help="Show fewer informational statements",
+ action="store_true")
(options, args) = parser.parse_args()
@@ -188,6 +195,8 @@ def main():
if options.verbose:
log.setLevel(logging.DEBUG)
+ elif options.quiet:
+ log.setLevel(logging.ERROR)
else:
log.setLevel(logging.INFO)
diff --git a/test.py b/test.py
index d780906..0ef2fa8 100755
--- a/test.py
+++ b/test.py
@@ -30,11 +30,15 @@ def main():
print c.call.initd_status("bluetooth")
print "hostname: %s" % c.call.augeas_get("/files/etc/hostname/*")
print "localhost: %s" % c.call.augeas_get("/files/etc/hosts/1/canonical")
+ sock.close()
print "========= Testing user client library"
client = ExMachinaClient()
print client.augeas.match("/files/etc/*")
print client.initd.restart("bluetooth")
+ print client.initd.status("bluetooth")
+ print client.initd.status("greentooth")
+ client.close()
if __name__ == '__main__':
main()