Skip to content

Commit

Permalink
Merge pull request #95 from homebysix/2.1.0-dev
Browse files Browse the repository at this point in the history
AutoPkg 2.x (Python 3) compatibility adjustments
  • Loading branch information
grahampugh authored Jan 20, 2020
2 parents c3a70e2 + 16e2df2 commit f9aaa5c
Show file tree
Hide file tree
Showing 46 changed files with 282 additions and 229 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]
### Fixed
- `urllib3` dependency version bumped to mitigate vulnerability.
## [2.1.0] - date TBD

### Added
- Retained compatibility with AutoPkg 1.x (Python 2) while adding compatibility for AutoPkg 2.x (Python 3).
- Added `$` to safe characters in URLs to allow hidden shares (#169).

### Changed
- Brought in latest upstream changes from [FoundationPlist](https://github.com/munki/munki/blob/72a0535/code/client/munkilib/FoundationPlist.py) and [GURL](https://github.com/munki/munki/blob/72a0535/code/client/munkilib/gurl.py).

### Security
- `urllib3` dependency version bumped to mitigate vulnerability.


## [2.0.1] - 2018-09-22 - The master and the student

Expand Down
4 changes: 3 additions & 1 deletion check_against_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"""


from __future__ import absolute_import
from __future__ import print_function
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

Expand Down Expand Up @@ -58,7 +60,7 @@ def main():

missing = sorted(h2_names.difference(jssobjects))

print '\n'.join('{:>2}: {}'.format(i, n) for i, n in enumerate(missing))
print('\n'.join('{:>2}: {}'.format(i, n) for i, n in enumerate(missing)))

# TODO: Expand all operations so we can chew on the juicy data within.
#expanders = [i for i in expands if i.text == "Expand Operations"]
Expand Down
5 changes: 3 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from __future__ import absolute_import
import os
import sys
sys.path.insert(0, os.path.abspath('../'))
Expand Down Expand Up @@ -64,9 +65,9 @@
# built documents.
#
# The short X.Y version.
version = u'2.0.1'
version = u'2.1.0'
# The full version, including alpha/beta/rc tags.
release = u'2.0.1'
release = u'2.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 3 additions & 2 deletions jss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"""


from __future__ import absolute_import
from .casper import Casper
from .curl_adapter import CurlAdapter
from .distribution_point import (AFPDistributionPoint, SMBDistributionPoint,
Expand All @@ -62,7 +63,7 @@
from .jamf_software_server import JSS
from .jssobject import JSSObject
from .jssobjects import *
import uapiobjects as uapi
from . import uapiobjects as uapi
from .jss_prefs import JSSPrefs
from .misc_endpoints import *
from .misc_uapi_endpoints import *
Expand All @@ -82,4 +83,4 @@
from .jssobjectlist import JSSObjectList


__version__ = "2.0.1"
__version__ = "2.1.0"
1 change: 1 addition & 0 deletions jss/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
a declared interface - mosen.
"""

from __future__ import absolute_import
import abc


Expand Down
1 change: 1 addition & 0 deletions jss/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import
import requests
from datetime import datetime
import logging
Expand Down
1 change: 1 addition & 0 deletions jss/casper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"""
from __future__ import unicode_literals

from __future__ import absolute_import
try:
# Python 2
from __builtin__ import str as text
Expand Down
26 changes: 15 additions & 11 deletions jss/contrib/FoundationPlist.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/python
# encoding: utf-8
#
# Copyright 2009-2014 Greg Neagle.
# Copyright 2009-2020 Greg Neagle.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""FoundationPlist.py -- a tool to generate and parse MacOSX .plist files.
"""FoundationPlist.py -- a tool to generate and parse OS X .plist files.
This is intended as a drop-in replacement for Python's included plistlib,
with a few caveats:
Expand All @@ -40,6 +39,7 @@
To work with plist data in strings, you can use readPlistFromString()
and writePlistToString().
"""
from __future__ import absolute_import, print_function

# PyLint cannot properly find names inside Cocoa libraries, so issues bogus
# No name 'Foo' in module 'Bar' warnings. Disable them.
Expand Down Expand Up @@ -88,11 +88,11 @@ def readPlist(filepath):


def readPlistFromString(data):
'''Read a plist data from a string. Return the root object.'''
try:
plistData = buffer(data)
except TypeError as err:
raise NSPropertyListSerializationException(err)
'''Read a plist data from a (byte)string. Return the root object.'''
plistData = NSData.dataWithBytes_length_(data, len(data))
if not plistData:
raise NSPropertyListSerializationException(
"Could not convert string to NSData")
dataObject, dummy_plistFormat, error = (
NSPropertyListSerialization.
propertyListFromData_mutabilityOption_format_errorDescription_(
Expand Down Expand Up @@ -130,7 +130,7 @@ def writePlist(dataObject, filepath):


def writePlistToString(rootObject):
'''Return 'rootObject' as a plist-formatted string.'''
'''Return 'rootObject' as a plist-formatted (byte)string.'''
plistData, error = (
NSPropertyListSerialization.
dataFromPropertyList_format_errorDescription_(
Expand All @@ -142,4 +142,8 @@ def writePlistToString(rootObject):
error = "Unknown error"
raise NSPropertyListSerializationException(error)
else:
return str(plistData)
return bytes(plistData)


if __name__ == '__main__':
print('This is a library of support tools for the Munki Suite.')
Loading

0 comments on commit f9aaa5c

Please sign in to comment.