aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2018-03-08 09:58:30 +0200
committerFilipp Lepalaan <filipp@mac.com>2018-03-08 09:58:30 +0200
commita96902b13e48c4c3d8badf9c02d19c0694a95685 (patch)
tree56b8e3f17cc799cf30b54dd6533d825aceb29f14
parent9efb1646e5aeba6287b9909050e85f13bc59271e (diff)
downloadmachammer-a96902b13e48c4c3d8badf9c02d19c0694a95685.tar.gz
machammer-a96902b13e48c4c3d8badf9c02d19c0694a95685.tar.bz2
machammer-a96902b13e48c4c3d8badf9c02d19c0694a95685.zip
Use mount() in mount_and_install
-rw-r--r--machammer/functions.py6
-rwxr-xr-xtests.py9
2 files changed, 13 insertions, 2 deletions
diff --git a/machammer/functions.py b/machammer/functions.py
index 01e49bb..fa4fc63 100644
--- a/machammer/functions.py
+++ b/machammer/functions.py
@@ -145,7 +145,6 @@ def is_laptop():
def is_desktop():
return not is_laptop()
-
def mount_image(path, mp=None, *args):
"""Mount disk image and return path to mountpoint."""
logging.debug('Mounting image %s' % path)
@@ -160,6 +159,7 @@ def mount_image(path, mp=None, *args):
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
+
# work around EULA prompt
out, err = p.communicate(input=b'Q\nY\n')
logging.debug('mount_image got %s' % out)
@@ -172,7 +172,7 @@ def mount_image(path, mp=None, *args):
def mount_and_install(dmg, pkg):
"""Mounts the DMG and installs the PKG."""
- with mount_image(dmg) as p:
+ with mount(dmg) as p:
install_pkg(os.path.join(p, pkg))
@@ -241,7 +241,9 @@ def mount(what, where=None):
raise Exception('Invalid path: %s' % what)
where = mount_image(what, where)
+
yield where
+
eject(where)
diff --git a/tests.py b/tests.py
index e860cfc..95288b7 100755
--- a/tests.py
+++ b/tests.py
@@ -144,6 +144,15 @@ class AppsTestCase(TestCase):
self.assertTrue(len(results) > 10)
+class InstallerTestCase(TestCase):
+ def setUp(self):
+ self.pkg = os.getenv('MH_PKG')
+ self.image = os.getenv('MH_IMAGE')
+
+ def test_mount_and_install(self):
+ functions.mount_and_install(self.image, self.pkg)
+
+
class MountTestCase(TestCase):
def setUp(self):
self.mp = None