Skip to content

Commit

Permalink
Merge branch 'master' into wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bochoven authored Feb 13, 2020
2 parents 6a12713 + 8106cf6 commit 798c362
Show file tree
Hide file tree
Showing 14 changed files with 843 additions and 665 deletions.
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-added-large-files
args: [--maxkb=100]
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
# - id: check-docstring-first
# - id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-xml
# - id: check-yaml
# - id: end-of-file-fixer
- id: mixed-line-ending
# - id: trailing-whitespace
# args: [--markdown-linebreak-ext=md]
- repo: https://github.com/digitalpulp/pre-commit-php
rev: 1.3.0
hooks:
- id: php-lint-all
- repo: https://github.com/python/black
rev: 19.3b0
hooks:
- id: black
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ DEPENDENCY UPDATES
- doctrine/cache (1.9.0 => 1.10.0)
- phpoption/phpoption (1.5.2 => 1.7.2)


### [5.1.3](https://github.com/munkireport/munkireport-php/compare/v5.1.2...v5.1.3) (November 12, 2019)

FEATURES
Expand Down
8 changes: 3 additions & 5 deletions build/mr_upgrade.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python3

"""
Script for upgrading MunkiReport.
"""
"""Script for upgrading MunkiReport."""

import argparse
import datetime
Expand Down Expand Up @@ -49,7 +47,7 @@ def run_command(args: list, suppress_output: bool = False) -> bool:


def get_current_version(install_path: str) -> str:
"""Return current build version"""
"""Return current build version."""
helper = install_path + "app/helpers/site_helper.php"
if os.path.exists(helper):
try:
Expand Down Expand Up @@ -231,7 +229,7 @@ def backup_files(backup_dir: str, install_path: str, current_time: str) -> bool:


def get_versions() -> dict:
"""Return MR versions"""
"""Return MR versions."""
mr_api = "https://api.github.com/repos/munkireport/munkireport-php/releases"
log.debug(f"Querying '{mr_api}' for latest release...")
versions = {}
Expand Down
21 changes: 10 additions & 11 deletions build/release/make_munkireport_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Requires an OAuth token with push access to the repo. Currently the GitHub
# Releases API is in a 'preview' status, and this script does very little error
# handling.
'''See docstring for main() function'''
"""See docstring for main() function."""

import json
import optparse
Expand All @@ -31,7 +31,7 @@
from time import strftime

class GitHubAPIError(BaseException):
'''Base error for GitHub API interactions'''
"""Base error for GitHub API interactions."""
pass


Expand Down Expand Up @@ -111,17 +111,16 @@ def run_command(cmd):
subprocess.check_call(cmd)

def main():
"""Builds and pushes a new munkireport-php release from an existing Git clone
of munkireport-php.
"""Builds and pushes a new munkireport-php release from an existing Git
clone of munkireport-php.
Requirements:
Requirements:
API token:
You'll need an API OAuth token with push access to the repo. You can create a
Personal Access Token in your user's Account Settings:
https://github.com/settings/applications
"""
API token:
You'll need an API OAuth token with push access to the repo. You can create a
Personal Access Token in your user's Account Settings:
https://github.com/settings/applications
"""
usage = __doc__
parser = optparse.OptionParser(usage=usage)
parser.add_option('-t', '--token',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,47 @@
from Foundation import NSPropertyListSerialization
from Foundation import NSPropertyListMutableContainers
from Foundation import NSPropertyListXMLFormat_v1_0

# pylint: enable=E0611

# Disable PyLint complaining about 'invalid' camelCase names
# pylint: disable=C0103


class FoundationPlistException(Exception):
"""Basic exception for plist errors"""
"""Basic exception for plist errors."""

pass


class NSPropertyListSerializationException(FoundationPlistException):
"""Read/parse error for plists"""
"""Read/parse error for plists."""

pass


class NSPropertyListWriteException(FoundationPlistException):
"""Write error for plists"""
"""Write error for plists."""

pass


def readPlist(filepath):
"""
Read a .plist file from filepath. Return the unpacked root object
(which is usually a dictionary).
"""Read a .plist file from filepath.
Return the unpacked root object (which is usually a dictionary).
"""
plistData = NSData.dataWithContentsOfFile_(filepath)
dataObject, dummy_plistFormat, error = (
NSPropertyListSerialization.
propertyListFromData_mutabilityOption_format_errorDescription_(
plistData, NSPropertyListMutableContainers, None, None))
(
dataObject,
dummy_plistFormat,
error,
) = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(
plistData, NSPropertyListMutableContainers, None, None
)
if dataObject is None:
if error:
error = error.encode('ascii', 'ignore')
error = error.encode("ascii", "ignore")
else:
error = "Unknown error"
errmsg = "%s in file %s" % (error, filepath)
Expand All @@ -87,18 +97,24 @@ def readPlist(filepath):


def readPlistFromString(data):
'''Read a plist data from a string. Return the root object.'''
"""Read a plist data from a string.
Return the root object.
"""
try:
plistData = buffer(data)
except TypeError, err:
raise NSPropertyListSerializationException(err)
dataObject, dummy_plistFormat, error = (
NSPropertyListSerialization.
propertyListFromData_mutabilityOption_format_errorDescription_(
plistData, NSPropertyListMutableContainers, None, None))
(
dataObject,
dummy_plistFormat,
error,
) = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(
plistData, NSPropertyListMutableContainers, None, None
)
if dataObject is None:
if error:
error = error.encode('ascii', 'ignore')
error = error.encode("ascii", "ignore")
else:
error = "Unknown error"
raise NSPropertyListSerializationException(error)
Expand All @@ -107,16 +123,16 @@ def readPlistFromString(data):


def writePlist(dataObject, filepath):
'''
Write 'rootObject' as a plist to filepath.
'''
plistData, error = (
NSPropertyListSerialization.
dataFromPropertyList_format_errorDescription_(
dataObject, NSPropertyListXMLFormat_v1_0, None))
"""Write 'rootObject' as a plist to filepath."""
(
plistData,
error,
) = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(
dataObject, NSPropertyListXMLFormat_v1_0, None
)
if plistData is None:
if error:
error = error.encode('ascii', 'ignore')
error = error.encode("ascii", "ignore")
else:
error = "Unknown error"
raise NSPropertyListSerializationException(error)
Expand All @@ -125,24 +141,27 @@ def writePlist(dataObject, filepath):
return
else:
raise NSPropertyListWriteException(
"Failed to write plist data to %s" % filepath)
"Failed to write plist data to %s" % filepath
)


def writePlistToString(rootObject):
'''Return 'rootObject' as a plist-formatted string.'''
plistData, error = (
NSPropertyListSerialization.
dataFromPropertyList_format_errorDescription_(
rootObject, NSPropertyListXMLFormat_v1_0, None))
"""Return 'rootObject' as a plist-formatted string."""
(
plistData,
error,
) = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(
rootObject, NSPropertyListXMLFormat_v1_0, None
)
if plistData is None:
if error:
error = error.encode('ascii', 'ignore')
error = error.encode("ascii", "ignore")
else:
error = "Unknown error"
raise NSPropertyListSerializationException(error)
else:
return str(plistData)


if __name__ == '__main__':
print 'This is a library of support tools for the Munki Suite.'
if __name__ == "__main__":
print "This is a library of support tools for the Munki Suite."
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
"""
constants.py
"""constants.py.
Created by Greg Neagle on 2016-12-14.
Expand All @@ -33,15 +32,16 @@
EXIT_STATUS_INVALID_PARAMETERS = 200
EXIT_STATUS_ROOT_REQUIRED = 201

BUNDLE_ID = 'MunkiReport'
BUNDLE_ID = "MunkiReport"
# the following two items are not used internally by Munki
# any longer, but remain for backwards compatibility with
# pre and postflight script that might access these files directly
MANAGED_INSTALLS_PLIST_PATH = '/Library/Preferences/' + BUNDLE_ID + '.plist'
SECURE_MANAGED_INSTALLS_PLIST_PATH = \
'/private/var/root/Library/Preferences/' + BUNDLE_ID + '.plist'
MANAGED_INSTALLS_PLIST_PATH = "/Library/Preferences/" + BUNDLE_ID + ".plist"
SECURE_MANAGED_INSTALLS_PLIST_PATH = (
"/private/var/root/Library/Preferences/" + BUNDLE_ID + ".plist"
)

ADDITIONAL_HTTP_HEADERS_KEY = 'AdditionalHttpHeaders'
ADDITIONAL_HTTP_HEADERS_KEY = "AdditionalHttpHeaders"

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

0 comments on commit 798c362

Please sign in to comment.