Skip to content

Commit 12e5ea4

Browse files
authored
fix plistlib deprecations (#5)
drop python <3.4 support
1 parent 3542137 commit 12e5ea4

File tree

10 files changed

+31
-30
lines changed

10 files changed

+31
-30
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
*.egg
22
*.egg-info
33
__pycache__
4+
.vscode
45
.coverage
56
.tox
67
build
78
dist
8-
htmlcov
9+
htmlcov

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
---
22
matrix:
33
include:
4-
- name: "Python 2.7.14 on macOS 10.13"
5-
os: osx
6-
osx_image: xcode9.3
7-
language: shell # 'language: python' errors on Travis CI macOS
8-
before_install:
9-
- python --version
10-
install: pip install tox --user
11-
script: tox -e py27
124
- name: "Python 3.7.5 on macOS 10.14"
135
os: osx
146
osx_image: xcode10.2
@@ -18,7 +10,7 @@ matrix:
1810
install: pip3 install tox --user
1911
script: tox -e py37
2012
env: PATH=/Users/travis/Library/Python/3.7/bin:$PATH
21-
- name: "Python 3.8.3 on macOS 10.15"
13+
- name: "Python 3.8 on macOS 10.15"
2214
os: osx
2315
osx_image: xcode12u
2416
language: shell # 'language: python' errors on Travis CI macOS
@@ -27,3 +19,12 @@ matrix:
2719
install: pip3 install tox --user
2820
script: tox -e py38
2921
env: PATH=/Users/travis/Library/Python/3.8/bin:$PATH
22+
- name: "Python 3.9 on macOS 10.15"
23+
os: osx
24+
osx_image: xcode12.2
25+
language: shell # 'language: python' errors on Travis CI macOS
26+
before_install:
27+
- python3 --version
28+
install: pip3 install tox --user
29+
script: tox -e py39
30+
env: PATH=/Users/travis/Library/Python/3.9/bin:$PATH

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release history
22
---------------
33

4+
0.2.0 (March 2021)
5+
++++++++++++++++++
6+
- drop python 2.x, 3.2, 3.3 support
7+
- fix plistlib calls (issue #4)
8+
49
0.1.2 (September 2020)
510
++++++++++++++++++++++
611
- added tox.ini for easier testing accross interpreter versions

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ or, if you want to work using the source tarball:
108108
Requirements
109109
============
110110
* OS X >= 10.6
111-
* Python 2.7, 3.2+
111+
* Python 3.4+

launchd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = 'Paul Kremer'
44
__email__ = 'paul@spurious.biz'
5-
__version__ = '0.1.2'
5+
__version__ = '0.2.0'
66

77
from .launchctl import jobs, LaunchdJob, load, unload
88
from . import plist

launchd/plist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def discover_filename(label, scopes=None):
4343

4444
def read(label, scope=None):
4545
with open(discover_filename(label, scope), 'rb') as f:
46-
return plistlib.readPlist(f)
46+
return plistlib.load(f)
4747

4848

4949
def write(label, plist, scope=USER):
@@ -57,5 +57,5 @@ def write(label, plist, scope=USER):
5757
'''
5858
fname = compute_filename(label, scope)
5959
with open(fname, "wb") as f:
60-
plistlib.writePlist(plist, f)
60+
plistlib.dump(plist, f)
6161
return fname

launchd/tests/cmd.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@ def testlaunchctl_invalid_args(self):
1919
self.assertRaises(ValueError, cmd.launchctl, ['foo'])
2020

2121
def testlaunchctl_list(self):
22-
if six.PY2:
23-
stdout = cmd.launchctl("list")
24-
else:
25-
stdout = cmd.launchctl("list").decode("utf-8")
22+
stdout = cmd.launchctl("list").decode("utf-8")
2623
self.assertTrue(isinstance(stdout, six.string_types))
2724

2825
def testlaunchctl_list_x(self):
2926
label = "com.apple.Finder"
30-
if six.PY2:
31-
stdout = cmd.launchctl("list", label)
32-
else:
33-
stdout = cmd.launchctl("list", label).decode("utf-8")
27+
stdout = cmd.launchctl("list", label).decode("utf-8")
3428
self.assertTrue(isinstance(stdout, six.string_types))

launchd/tests/plist.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def test_discover_filename(self):
4949
fname = plist.discover_filename("com.apple.kextd", plist.USER)
5050
self.assertEqual(None, fname)
5151

52+
@unittest.skipUnless(sys.platform.startswith("darwin"), "requires OS X")
53+
def test_read(self):
54+
result = plist.read("com.apple.kextd", plist.DAEMON_OS)
55+
self.assertIsInstance(result, dict)
56+
5257

5358
class PlistToolPersistencyTest(unittest.TestCase):
5459
def setUp(self):

setup.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,17 @@
2222
Natural Language :: English
2323
Operating System :: MacOS :: MacOS X
2424
Programming Language :: Python
25-
Programming Language :: Python :: 2.7
26-
Programming Language :: Python :: 3.2
27-
Programming Language :: Python :: 3.3
2825
Programming Language :: Python :: 3.4
2926
Programming Language :: Python :: 3.5
3027
Programming Language :: Python :: 3.6
3128
Programming Language :: Python :: 3.7
3229
Programming Language :: Python :: 3.8
30+
Programming Language :: Python :: 3.9
3331
Programming Language :: Python :: Implementation :: CPython
3432
""".splitlines() if len(line) > 0]
3533

3634
install_requires = ["six", "pyobjc-framework-ServiceManagement"]
3735

38-
if sys.version_info < (3, 2):
39-
install_requires.append("argparse")
40-
4136
if not 'darwin' in sys.platform:
4237
sys.stderr.write("Warning: The package 'launchd' can only be installed and run on OS X!" + os.linesep)
4338

@@ -51,7 +46,7 @@
5146
author="Paul Kremer",
5247
author_email="@".join(("paul", "spurious.biz")), # avoid spam,
5348
license="MIT License",
54-
description="pythonic interface for OS X launchd",
49+
description="pythonic interface for macOS launchd",
5550
long_description=(open('README.rst', 'r').read() + '\n\n' +
5651
open('CHANGELOG.rst', 'r').read()),
5752
url="https://github.com/infothrill/python-launchd",

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Tox (http://tox.testrun.org/)
22

33
[tox]
4-
envlist = py27, py32, py33, py34, py35, py36, py37, py38
4+
envlist = py34, py35, py36, py37, py38, py39
55

66
[testenv]
77
commands = {envpython} setup.py test

0 commit comments

Comments
 (0)