From dd30b337f30f226d30f6cfc533ae183b79f31844 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 7 Nov 2016 18:49:18 +0200 Subject: Added network.flush_dns() --- README.md | 4 +++- machammer/network.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 301d009..8e4125d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### Introduction -`machammer` is library/microframework for Macintosh system administration. The idea is to provide a set of common, often-used functions for admins to build their own management tools. +`machammer` is library/microframework for Macintosh system administration. It provides a set of common, often-used functions for admins to build their own management tools. ### System Requirements @@ -134,6 +134,8 @@ Check `tests.py` for more usage examples. * Q: Why not use Munki? * A: No reason whatsoever. Munki is great and you should totally use it, if it works for you. I just prefer to read and write code than learn a new XML syntax. For me personally, it was difficult to "start small" with Munki - there's a lot you have to learn to get started. Also, there are plenty of apps out there that don't conform to the standard PKG/app bundle format (like the ArchiCAD example above) and your best bet at tackling those is just plain-old scripting. To paraphrase Einstein - an installation tool might take you from A to B, but scripting can take you anywhere. :-) +[![Documentation Status](https://readthedocs.org/projects/machammer/badge/?version=latest)](http://machammer.readthedocs.io/en/latest/?badge=latest) + ### License diff --git a/machammer/network.py b/machammer/network.py index 5f5fb87..2c4dcfc 100644 --- a/machammer/network.py +++ b/machammer/network.py @@ -19,7 +19,7 @@ def set_wifi_power(on=True): def get_wifi_power(): - """Get AirPort power state""" + """Get AirPort power state.""" results = [] for i in get_ports('AirPort'): iface = i['interface'] @@ -55,3 +55,8 @@ def get_primary(port=None): for i in [x for x in route if 'interface: ' in x]: p = i.split(': ')[1] return p == port if port else p + + +def flush_dns(): + """Flush the DNS cache.""" + call('/usr/bin/killall', '-HUP', 'mDNSResponder') -- cgit v1.2.3