From 60216c4bbec1d4006fc86c2cdd412cdca6c87120 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 1 Nov 2017 17:59:51 +0200 Subject: Python 3 fixes --- machammer/__init__.py | 4 +++- machammer/decorators.py | 2 +- machammer/functions.py | 4 ++-- machammer/hooks.py | 2 +- tests.py | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/machammer/__init__.py b/machammer/__init__.py index 1ab391e..ccd52c7 100644 --- a/machammer/__init__.py +++ b/machammer/__init__.py @@ -1,6 +1,8 @@ __all__ = ['functions', 'printers', 'system_profiler'] __title__ = 'machammer' +__name__ = 'machammer' +__package__ = 'machammer' __author__ = 'Filipp Lepalaan' __version__ = '0.1' __license__ = 'MIT' -__copyright__ = 'Copyright 2016 Filipp Lepalaan' +__copyright__ = 'Copyright 2017 Filipp Lepalaan' diff --git a/machammer/decorators.py b/machammer/decorators.py index b73b52f..987cc5d 100644 --- a/machammer/decorators.py +++ b/machammer/decorators.py @@ -5,7 +5,7 @@ import os import stat import inspect -import hooks +from . import hooks APP_SUPPORT_DIR = '/Library/Application Support/' APP_ID = 'com.github.filipp.machammer' diff --git a/machammer/functions.py b/machammer/functions.py index 8ae0183..0031e61 100644 --- a/machammer/functions.py +++ b/machammer/functions.py @@ -146,10 +146,10 @@ def is_desktop(): return not is_laptop() -def mount_image(path): +def mount_image(path, mp=None): """Mount disk image and return path to mountpoint.""" logging.debug('Mounting DMG %s' % path) - mp = tempfile.mkdtemp() + mp = mp or tempfile.mkdtemp() p = subprocess.Popen(['/usr/bin/hdiutil', 'mount', '-mountpoint', mp, '-nobrowse', path], diff --git a/machammer/hooks.py b/machammer/hooks.py index f975aca..ccb1526 100644 --- a/machammer/hooks.py +++ b/machammer/hooks.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import defaults +from . import defaults PREF_DOMAIN = 'com.apple.loginwindow' diff --git a/tests.py b/tests.py index 081bd83..e51c90d 100755 --- a/tests.py +++ b/tests.py @@ -143,10 +143,10 @@ class FunctionsTestCase(TestCase): def test_remove_login_item(self): users.remove_login_item(path=self.stickes) - + def test_mount_image(self): p = functions.mount_image(os.getenv('MH_IMAGE')) - self.assertEquals(p, '/Volumes/Adobe Flash Player Installer') + self.assertIn('/var/folders', p) @skip('This works, trust me.') def test_create_media(self): -- cgit v1.2.3