aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-11-02 11:51:30 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-11-02 11:51:30 +0200
commit282b78dc5decd319ed2284f90fd7716cd395a048 (patch)
treea281baedd56078dc47133c0241687cabed61c4a5
parentd5107fb63a688236c4bd8275cb3884c2a58ec2f6 (diff)
downloadmachammer-282b78dc5decd319ed2284f90fd7716cd395a048.tar.gz
machammer-282b78dc5decd319ed2284f90fd7716cd395a048.tar.bz2
machammer-282b78dc5decd319ed2284f90fd7716cd395a048.zip
Added some functions
-rw-r--r--machammer/functions.py16
-rwxr-xr-xtests.py4
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()