Add 'from __future__ import absolute_import' to all files to enforce Python3-style imports

This commit is contained in:
Greg Neagle
2019-05-03 21:34:56 -07:00
parent 531d99a01a
commit df60207145
85 changed files with 112 additions and 76 deletions

View File

@@ -26,6 +26,7 @@ Borrowing lots of code and ideas from the crankd project, part of pymacadmin:
and the application_usage scripts created by Google MacOps:
https://github.com/google/macops/tree/master/crankd
"""
from __future__ import absolute_import
# standard Python libs
import logging

View File

@@ -24,7 +24,7 @@ Much code based on and adapted from autopkgserver by Per Olofsson
A privileged daemon that records app usage events and install requests to our
app usage database.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import sys

View File

@@ -27,7 +27,7 @@ Root user can trigger an authrestart, possibly using the password stored
earlier by a non-privileged user.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import sys

View File

@@ -22,6 +22,8 @@ Created by Greg Neagle on 2014-03-03.
Converts and imports icons as png files for Munki repo
"""
from __future__ import absolute_import
# standard libs
import os
from optparse import OptionParser

View File

@@ -25,7 +25,7 @@ Prevents multiple copies of the app from being launched
when Fast User Switching is in use
Intended for use by a launchd LaunchAgent.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import sys
import os

View File

@@ -23,6 +23,7 @@ A helper tool for forced logouts to allow munki to force install items by
a certain deadline.
"""
from __future__ import absolute_import
# standard libs
import os

View File

@@ -26,7 +26,7 @@ Assumes a pkgsinfo directory under repopath.
User calling this needs to be able to write to repo/catalogs.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import optparse
import sys

View File

@@ -31,7 +31,7 @@ The generated plist is printed to STDOUT.
Usage: makepkginfo /path/to/package_or_dmg [-f /path/to/item/it/installs ...]
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import optparse

View File

@@ -17,7 +17,7 @@
"""
managedsoftwareupdate
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import optparse
import os

View File

@@ -19,7 +19,7 @@ manifestutil
Created by Greg Neagle on 2011-03-04.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# TODO: add support for delete-manifest

View File

@@ -22,7 +22,7 @@ Created by Greg Neagle on 2010-09-29.
Assists with importing installer items into the munki repo
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# std lib imports
import optparse

View File

@@ -39,7 +39,7 @@ dictionary).
To work with plist data in strings, you can use readPlistFromString()
and writePlistToString().
"""
from __future__ import print_function
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.

View File

@@ -19,6 +19,7 @@ admin/common.py
Created by Greg Neagle on 2017-11-19.
Common code used by the admin libs
"""
from __future__ import absolute_import
import os

View File

@@ -19,7 +19,7 @@ makecatalogslib
Created by Greg Neagle on 2017-11-19.
Routines used by makecatalogs
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# std libs
import hashlib

View File

@@ -19,7 +19,7 @@ munkiimportlib
Created by Greg Neagle on 2017-11-18.
Routines used by munkimport to import items into Munki repo
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# std lib imports
import os

View File

@@ -19,7 +19,7 @@ pkginfolib
Created by Greg Neagle on 2017-11-18.
Routines used by makepkginfo to create pkginfo files
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import optparse

View File

@@ -1 +1,6 @@
from .core import *
'''Make all .core names available as adobeutils.foo'''
from __future__ import absolute_import
# pylint: disable=wildcard-import
from .core import *
# pylint: enable=wildcard-import

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-06.
Utilities to get info about Adobe installers/uninstallers
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import json

View File

@@ -19,7 +19,7 @@ Utilities to enable Munki to install/uninstall Adobe CS3/CS4/CS5 products
using the CS3/CS4/CS5 Deployment Toolkits.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os

View File

@@ -23,7 +23,7 @@ Much code lifted from the application_usage scripts created by Google MacOps:
https://github.com/google/macops/tree/master/crankd
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard Python libs
import logging

View File

@@ -1 +1,6 @@
from .core import *
'''Make names from .core available appleupdates.foo'''
from __future__ import absolute_import
# pylint: disable=wildcard-import
from .core import *
# pylint: enable=wildcard-import

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-06.
AppleUpdates object defined here
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import glob
import hashlib

View File

@@ -18,7 +18,7 @@ appleupdates.py
Utilities for dealing with Apple Software Update.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
from . import au
from . import su_prefs

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-04.
Utilities for working with Apple software update dist files
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
from xml.dom import minidom

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-06.
Utilities for working with Apple software update preferences
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import subprocess

View File

@@ -20,6 +20,7 @@ Created by Greg Neagle on 2019-03-20.
wrapper for running /usr/sbin/softwareupdate
"""
from __future__ import absolute_import
import os
import time

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-06.
Utilities for replicating and retrieving Apple software update metadata
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import gzip
import os

View File

@@ -21,7 +21,7 @@ Initial work by Wes Whetstone, Summer/Fall 2016
Functions supporting FileVault authrestart.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import subprocess

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2017-04-15.
Routines for communicating with authrestartd.
Socket communications code adapted from autopkg's PkgCreator by Per Olofsson
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import plistlib

View File

@@ -20,6 +20,7 @@ Created by Greg Neagle on 2017-08-31.
Functions supporting bootstrapping mode
"""
from __future__ import absolute_import
import os

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-03-12.
Functions supporting the admin command-line tools
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import ctypes
from ctypes.util import find_library

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-14.
Commonly used constants
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# NOTE: it's very important that defined exit codes are never changed!
# Preflight exit codes.

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-13.
Common output functions
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import sys
import warnings

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-13.
Utilities for working with disk images.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -19,7 +19,7 @@ fetch.py
Created by Greg Neagle on 2011-09-29.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import calendar

View File

@@ -21,7 +21,7 @@ Modified in Feb 2016 to add support for NSURLSession.
curl replacement using NSURLConnection and friends
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
from urlparse import urlparse

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2014-05-15.
Functions to work with product images ('icons') for Managed Software Center
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import glob
import os

View File

@@ -20,7 +20,8 @@ Created by Greg Neagle on 2016-12-14.
Utilities that retrieve information from the current machine.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import ctypes
import ctypes.util

View File

@@ -1 +1,6 @@
from .core import *
'''Make names in .core available as installer.foo'''
from __future__ import absolute_import
# pylint: disable=wildcard-import
from .core import *
# pylint: enable=wildcard-import

View File

@@ -19,7 +19,7 @@ installer.core
munki module to automatically install pkgs, mpkgs, and dmgs
(containing pkgs and mpkgs) from a defined folder.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import datetime
import os

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-03.
Routines for copying items from disk images
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import shutil

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-03.
Routines for installing Apple pkgs
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import pwd

View File

@@ -23,7 +23,7 @@ is made to revert to older versions of a file when uninstalling;
only file removals are done.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-01.
Functions for getting data from the InstallInfo.plist, etc
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import os

View File

@@ -22,7 +22,7 @@ Incorporating work and ideas from Michael Lynn here:
and here:
https://gist.github.com/pudquick/836a19b5ff17c5b7640d#file-cert_tricks-py
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import base64
import hashlib

View File

@@ -25,7 +25,7 @@ Returns a file descriptor for a socket defined in a launchd plist.
A wrapper for using launchd to run a process as root outside of Munki's
process space. Needed to properly run /usr/sbin/softwareupdate, for example.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
'''Python wrapper for original launchd checkin API'''
from __future__ import absolute_import
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

View File

@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
'''Python wrapper for updated launchd checkin API'''
from __future__ import absolute_import
import os
# pylint: disable=wildcard-import

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2008-11-18.
Common functions used by the munki tools.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# this module currently exists purely for backwards compatibility so that
# anything calling munkicommon functions will still work (for now)

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-14.
Munki's hash functions
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import hashlib
import os

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-14.
Logging functions for Munki
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import logging
import logging.handlers

View File

@@ -1,6 +1,6 @@
# encoding: utf-8
'''Defines FileRepo plugin. See docstring for FileRepo class'''
from __future__ import print_function
from __future__ import absolute_import, print_function
import errno
import getpass

View File

@@ -1,6 +1,6 @@
# encoding: utf-8
'''Subclasses FileRepo to do git commits of file changes'''
from __future__ import print_function
from __future__ import absolute_import, print_function
import inspect
import os

View File

@@ -1,6 +1,6 @@
# encoding: utf-8
'''Defines MWA2APIRepo plugin. See docstring for MWA2APIRepo class'''
from __future__ import print_function
from __future__ import absolute_import, print_function
import base64
import getpass

View File

@@ -1,4 +1,5 @@
from __future__ import print_function
'''Base bits for repo plugins'''
from __future__ import absolute_import, print_function
import imp
import os

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2009-09-24.
Utility functions for using MunkiStatus.app
to display status and progress.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import time

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-03-29.
Support for using startosinstall to install macOS.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# stdlib imports
import os

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-13.
Common functions and classes used by the munki tools.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import platform
import os

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-14.
Common pkg/receipt functions and classes used by the munki tools.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import re

View File

@@ -17,7 +17,7 @@
powermgr.py
Munki module to handle Power Manager tasks
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
from . import display

View File

@@ -20,7 +20,8 @@ Created by Greg Neagle on 2016-12-13.
Preferences functions and classes used by the munki tools.
"""
from __future__ import print_function
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.
# pylint: disable=E0611

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-14.
Functions for finding, listing, etc processes
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import signal

View File

@@ -17,7 +17,7 @@
profiles.py
Munki module for working with configuration profiles.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-14.
Reporting functions
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-14.
Functions to run scripts inside Munki
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import subprocess

View File

@@ -1 +1,6 @@
from .core import *
'''Make names in .core available as updatecheck.foo'''
from __future__ import absolute_import
# pylint: disable=wildcard-import
from .core import *
# pylint: enable=wildcard-import

View File

@@ -19,7 +19,7 @@ updatecheck.analyze
Created by Greg Neagle on 2017-01-10.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import datetime
import os

View File

@@ -20,7 +20,8 @@ Created by Greg Neagle on 2018-04-17.
Functions for automatically discovering and configuring some Munki settings.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# Apple frameworks via PyObjC
# PyLint cannot properly find names inside Cocoa libraries, so issues bogus
# No name 'Foo' in module 'Bar' warnings. Disable them.

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-01.
Functions for working with Munki catalogs
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2016-12-13.
Comparison/checking functions used by updatecheck
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
from operator import itemgetter

View File

@@ -19,7 +19,7 @@ updatecheck.core
Created by Greg Neagle on 2008-11-13.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# standard libs
import os

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-31.
Functions for downloading resources from the Munki server
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import urllib2

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-01-01.
Utilities for determining installation status for Munki items.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os

View File

@@ -19,7 +19,7 @@ updatecheck.licensing
Created by Greg Neagle on 2017-01-01.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
from urllib import quote_plus

View File

@@ -21,7 +21,7 @@ Created by Greg Neagle on 2016-12-16.
Functions for working with manifest files
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
import urllib2

View File

@@ -20,7 +20,7 @@ Created by Greg Neagle on 2017-02-18.
Functions for removing unused optional install items
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# Apple frameworks via PyObjC
# PyLint cannot properly find names inside Cocoa libraries, so issues bogus

View File

@@ -22,7 +22,7 @@ Common utility functions used throughout Munki.
Note: this module should be 100% free of ObjC-dependent Python imports.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import grp

View File

@@ -21,6 +21,8 @@ Created by Greg Neagle on 2018-07-18.
A privileged agent that downloads optional installs items marked for precaching.
"""
from __future__ import absolute_import
import signal
import sys
import time

View File

@@ -25,7 +25,7 @@ This will have the effect of unbuffering output I/O from the subprocess.
stdin of the subprocess is not connected to the stdin of this parent
process.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import fcntl
import os

View File

@@ -26,7 +26,7 @@ is made to revert to older versions of a file when uninstalling;
only file removals are done.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import optparse
import os

View File

@@ -22,7 +22,7 @@ Created by Greg Neagle on 2016-06-22.
A tool to remove older, unused software items from a Munki repo.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import plistlib
import subprocess

View File

@@ -16,8 +16,7 @@
# limitations under the License.
"""Tool to supervise launch other binaries."""
from __future__ import print_function
from __future__ import absolute_import, print_function
import errno
import getopt

View File

@@ -19,6 +19,7 @@ Unit tests for display.display_* functions.
# 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.
from __future__ import absolute_import
import unittest

View File

@@ -6,7 +6,7 @@ test_isapprunning.py
Unit tests for processes.isAppRunning.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
# Copyright 2016-present Nate Walck.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ from __future__ import print_function
# 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.
from __future__ import absolute_import
import unittest

2
code/client/tests/travisci.py Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#!/usr/bin/python env
from __future__ import absolute_import, print_function
from __future__ import print_function
import subprocess
import sys