From 282b78dc5decd319ed2284f90fd7716cd395a048 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 2 Nov 2016 11:51:30 +0200 Subject: Added some functions --- machammer/functions.py | 16 +++++++++++++--- tests.py | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/machammer/functions.py b/machammer/functions.py index a52dea0..900569d 100644 --- a/machammer/functions.py +++ b/machammer/functions.py @@ -117,7 +117,7 @@ def enable_ard(username): def sleep(): - """Put this Mac to sleep""" + """Put this Mac to sleep.""" tell_app('Finder', 'sleep') @@ -191,8 +191,8 @@ def install_su(restart=True): def disable_wifi(port='en1'): - subprocess.call(['/usr/sbin/networksetup', '-setairportpower', port, 'off']) - subprocess.call(['/usr/sbin/networksetup', '-setnetworkserviceenabled', 'Wi-Fi', 'off']) + call('/usr/sbin/networksetup', '-setairportpower', port, 'off') + call('/usr/sbin/networksetup', '-setnetworkserviceenabled', 'Wi-Fi', 'off') def log(msg): @@ -205,3 +205,13 @@ def install_service(src): os.mkdir(SERVICEDIR) ditto(src, SERVICEDIR) + + +def clear_xattr(path): + """Clear all extended attributes on path.""" + call('/usr/bin/xattr', '-c', path) + + +def create_os_media(src, dst): + fp = os.path.join(src, 'Contents/Resources/createinstallmedia') + call(fp, '--volume', dst, '--applicationpath', src, '--nointeraction') diff --git a/tests.py b/tests.py index 38e436a..10057ec 100755 --- a/tests.py +++ b/tests.py @@ -96,6 +96,10 @@ class FunctionsTestCase(TestCase): p = mh.mount_image('/Users/filipp/Downloads/AdobeFlashPlayer_22au_a_install.dmg') self.assertEquals(p, '/Volumes/Adobe Flash Player Installer') + def test_create_media(self): + mh.create_os_media('/Applications/Install macOS Sierra.app', + '/Volumes/Untitled') + @skip('This works, trust me.') def test_sleep(self): mh.sleep() -- cgit v1.2.3