PyLint cleanup: replace all unused_foo variables with dummy_foo variables to make PyLint happy

This commit is contained in:
Greg Neagle
2014-10-26 11:42:33 -07:00
parent c4017c9aef
commit 423ec8b790
12 changed files with 58 additions and 59 deletions
@@ -384,7 +384,7 @@ def pythonScriptRunning(scriptname):
proc = subprocess.Popen(cmd, shell=False, bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, unused_err) = proc.communicate()
(out, dummy_err) = proc.communicate()
mypid = os.getpid()
lines = str(out).splitlines()
for line in lines:
@@ -421,7 +421,7 @@ def getRunningProcessesWithUsers():
shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
if proc.returncode == 0:
proc_lines = [item for item in output.splitlines()]
LaunchCFMApp = ('/System/Library/Frameworks/Carbon.framework'
@@ -443,7 +443,7 @@ def getRunningProcessesWithUsers():
shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
if proc.returncode == 0:
proc_lines = [item for item in output.splitlines()]
for line in proc_lines:
@@ -507,7 +507,7 @@ def getPowerInfo():
cmd = ['/usr/bin/pmset', '-g', 'ps']
proc = subprocess.Popen(cmd, bufsize=-1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_error) = proc.communicate()
(output, dummy_error) = proc.communicate()
if proc.returncode:
# handle error
return power_dict
+1 -1
View File
@@ -76,7 +76,7 @@ def pythonScriptRunning(scriptname):
proc = subprocess.Popen(cmd, shell=False, bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, unused_err) = proc.communicate()
(out, dummy_err) = proc.communicate()
mypid = os.getpid()
lines = str(out).splitlines()
for line in lines:
+1 -1
View File
@@ -817,7 +817,7 @@ def main():
"To use it with munki, you should encapsulate it "
"in a disk image.\n") % item
# need to walk the dir and add it all up
for (path, unused_dirs, files) in os.walk(item):
for (path, dummy_dirs, files) in os.walk(item):
for name in files:
filename = os.path.join(path, name)
# use os.lstat so we don't follow symlinks
+9 -9
View File
@@ -57,7 +57,7 @@ else:
from munkilib import utils
def signal_handler(signum, unused_frame):
def signal_handler(signum, dummy_frame):
"""Handle any signals we've been told to.
Right now just handle SIGTERM so clean up can happen, like
garbage collection, which will trigger object destructors and
@@ -72,7 +72,7 @@ def getIdleSeconds():
cmd = ['/usr/sbin/ioreg', '-c', 'IOHIDSystem']
proc = subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
ioreglines = str(output).splitlines()
idle_time = 0
regex = re.compile(r'"?HIDIdleTime"?\s+=\s+(\d+)')
@@ -94,7 +94,7 @@ def networkUp():
cmd = ['/sbin/ifconfig', '-a', 'inet']
proc = subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
lines = str(output).splitlines()
for line in lines:
if 'inet' in line:
@@ -269,7 +269,7 @@ def doRestart():
if not consoleuser or consoleuser == u'loginwindow':
# no-one is logged in or we're at the loginwindow
time.sleep(5)
unused_retcode = subprocess.call(['/sbin/shutdown', '-r', 'now'])
dummy_retcode = subprocess.call(['/sbin/shutdown', '-r', 'now'])
else:
if munkicommon.munkistatusoutput:
# someone is logged in and we're using munkistatus
@@ -465,7 +465,7 @@ def main():
p.add_option('--version', '-V', action='store_true',
help='Print the version of the munki tools and exit.')
options, unused_arguments = p.parse_args()
options, dummy_arguments = p.parse_args()
if options.version:
print munkicommon.get_version()
@@ -520,7 +520,7 @@ def main():
# network interfaces to come up
# before continuing
munkicommon.display_status_minor('Waiting for network...')
for unused_i in range(5):
for dummy_i in range(5):
if networkUp():
break
time.sleep(2)
@@ -820,7 +820,7 @@ def main():
# check for packages that need to be force installed
# soon and convert them to unattended_installs if they
# don't require a logout
unused_action = updatecheck.checkForceInstallPackages()
dummy_action = updatecheck.checkForceInstallPackages()
# now install anything that can be done unattended
munkicommon.log('Installing only items marked unattended '
'because SuppressLoginwindowInstall is '
@@ -851,7 +851,7 @@ def main():
# check for packages that need to be force installed
# soon and convert them to unattended_installs if they
# don't require a logout
unused_action = updatecheck.checkForceInstallPackages()
dummy_action = updatecheck.checkForceInstallPackages()
# install anything that can be done unattended
ignore_restart = doInstallTasks(
appleupdatesavailable, only_unattended=True)
@@ -970,7 +970,7 @@ def main():
#munkicommon.log(
# 'Killing loginwindow so we will run again...')
#cmd = ['/usr/bin/killall', 'loginwindow']
#unused_retcode = subprocess.call(cmd)
#dummy_retcode = subprocess.call(cmd)
# with the new LaunchAgent, we don't have to kill
# the loginwindow
pass
+3 -3
View File
@@ -120,8 +120,8 @@ def mountRepoGUI():
return
print 'Attempting to connect to munki repo...'
cmd = ['/usr/bin/open', REPO_URL]
unused_retcode = subprocess.call(cmd)
for unused_i in range(60):
dummy_retcode = subprocess.call(cmd)
for dummy_i in range(60):
# wait up to 60 seconds to connect to repo
if os.path.exists(REPO_PATH):
break
@@ -393,7 +393,7 @@ def openPkginfoInEditor(pkginfo_path):
else:
cmd = [editor, pkginfo_path]
try:
unused_returncode = subprocess.check_call(cmd)
dummy_returncode = subprocess.check_call(cmd)
except (OSError, subprocess.CalledProcessError), err:
print >> sys.stderr, 'Problem running editor %s: %s.' % (
editor, err)
+14 -14
View File
@@ -58,7 +58,7 @@ class AdobeInstallProgressMonitor(object):
proc = subprocess.Popen(['/bin/ls', '-t1', logpath],
bufsize=-1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
if output:
firstitem = str(output).splitlines()[0]
if firstitem.endswith(".log"):
@@ -91,7 +91,7 @@ class AdobeInstallProgressMonitor(object):
proc = subprocess.Popen(cmd, bufsize=-1,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
if output:
lines = str(output).splitlines()
completed_payloads = len(lines)
@@ -170,7 +170,7 @@ def getCS5mediaSignature(dirpath):
payloads_dir = ""
# look for a payloads folder
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith('/payloads'):
payloads_dir = path
@@ -277,7 +277,7 @@ def getAdobeSetupInfo(installroot):
payloads = []
# look for all the payloads folders
for (path, unused_dirs, unused_files) in os.walk(installroot):
for (path, dummy_dirs, dummy_files) in os.walk(installroot):
if path.endswith('/payloads'):
driverfolder = ''
mediaSignature = ''
@@ -316,7 +316,7 @@ def getAdobeSetupInfo(installroot):
if not payloads:
# look for an extensions folder; almost certainly this is an Updater
for (path, unused_dirs, unused_files) in os.walk(installroot):
for (path, dummy_dirs, dummy_files) in os.walk(installroot):
if path.endswith("/extensions"):
for item in munkicommon.listdir(path):
#skip LanguagePacks
@@ -398,7 +398,7 @@ def getAdobePackageInfo(installroot):
def countPayloads(dirpath):
'''Attempts to count the payloads in the Adobe installation item'''
count = 0
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith("/payloads"):
for subitem in munkicommon.listdir(path):
subitempath = os.path.join(path, subitem)
@@ -426,7 +426,7 @@ def getPercent(current, maximum):
def findSetupApp(dirpath):
'''Search dirpath and enclosed directories for Setup.app.
Returns the path to the actual executable.'''
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith("Setup.app"):
setup_path = os.path.join(path, "Contents", "MacOS", "Setup")
if os.path.exists(setup_path):
@@ -437,7 +437,7 @@ def findSetupApp(dirpath):
def findInstallApp(dirpath):
'''Searches dirpath and enclosed directories for Install.app.
Returns the path to the actual executable.'''
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith("Install.app"):
setup_path = os.path.join(path, "Contents", "MacOS", "Install")
if os.path.exists(setup_path):
@@ -448,7 +448,7 @@ def findInstallApp(dirpath):
def findAdobePatchInstallerApp(dirpath):
'''Searches dirpath and enclosed directories for AdobePatchInstaller.app.
Returns the path to the actual executable.'''
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith("AdobePatchInstaller.app"):
setup_path = os.path.join(path, "Contents", "MacOS",
"AdobePatchInstaller")
@@ -460,7 +460,7 @@ def findAdobePatchInstallerApp(dirpath):
def findAdobeDeploymentManager(dirpath):
'''Searches dirpath and enclosed directories for AdobeDeploymentManager.
Returns path to the executable.'''
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith("pkg/Contents/Resources"):
dm_path = os.path.join(path, "AdobeDeploymentManager")
if os.path.exists(dm_path):
@@ -741,7 +741,7 @@ def runAdobeCS5AAMEEInstall(dmgpath, payloads=None):
cmd, number_of_payloads, killAdobeAIR=True, payloads=payloads,
kind='CS5', operation='install')
# now clean up our symlink hackfest
unused_result = subprocess.call(["/bin/rm", "-rf", tmpdir])
dummy_result = subprocess.call(["/bin/rm", "-rf", tmpdir])
else:
munkicommon.display_error(
"%s doesn't appear to contain AdobeDeploymentManager" %
@@ -773,7 +773,7 @@ def runAdobeCS5PatchInstaller(dmgpath, copylocal=False, payloads=None):
return -1
# remove the dmg file to free up space, since we don't need it
# any longer
unused_result = subprocess.call(["/bin/rm", dmgpath])
dummy_result = subprocess.call(["/bin/rm", dmgpath])
else:
updatedir = mountpoints[0]
@@ -796,7 +796,7 @@ def runAdobeCS5PatchInstaller(dmgpath, copylocal=False, payloads=None):
retcode = -1
if copylocal:
# clean up our mess
unused_result = subprocess.call(["/bin/rm", "-rf", updatedir])
dummy_result = subprocess.call(["/bin/rm", "-rf", updatedir])
else:
munkicommon.unmountdmg(mountpoints[0])
return retcode
@@ -859,7 +859,7 @@ def findAcrobatPatchApp(dirpath):
in dirpath. If found, returns the path to the bundled
patching script.'''
for (path, unused_dirs, unused_files) in os.walk(dirpath):
for (path, dummy_dirs, dummy_files) in os.walk(dirpath):
if path.endswith(".app"):
# look for Adobe's patching script
patch_script_path = os.path.join(path, "Contents", "Resources",
+5 -5
View File
@@ -492,7 +492,7 @@ class AppleUpdates(object):
blocking_apps = []
# use set() to eliminate any duplicate application ids
for app_id in set(must_close_app_ids):
unused_resultcode, unused_fileref, nsurl = LSFindApplicationForInfo(
dummy_resultcode, dummy_fileref, nsurl = LSFindApplicationForInfo(
0, app_id, None, None, None)
fileurl = str(nsurl)
if fileurl.startswith('file://localhost'):
@@ -698,7 +698,7 @@ class AppleUpdates(object):
self._ResetMunkiStatusAndDisplayMessage(msg)
munkicommon.display_detail('Caching CatalogURL %s', catalog_url)
try:
unused_file_changed = self.GetSoftwareUpdateResource(
dummy_file_changed = self.GetSoftwareUpdateResource(
catalog_url, self.apple_download_catalog_path, resume=True)
self.ExtractAndCopyDownloadedCatalog()
except fetch.MunkiDownloadError:
@@ -716,7 +716,7 @@ class AppleUpdates(object):
proc = subprocess.Popen(cmd, shell=False, bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, unused_err = proc.communicate()
output, dummy_err = proc.communicate()
current_apple_packages_checksum = hashlib.sha256(output).hexdigest()
old_apple_packages_checksum = munkicommon.pref(
@@ -1415,7 +1415,7 @@ class AppleUpdates(object):
# clean up our now stale local cache
if os.path.exists(self.cache_dir) and not only_unattended:
# TODO(unassigned): change this to Pythonic delete.
unused_retcode = subprocess.call(['/bin/rm', '-rf', self.cache_dir])
dummy_retcode = subprocess.call(['/bin/rm', '-rf', self.cache_dir])
# remove the now invalid AppleUpdates.plist file.
try:
os.unlink(self.apple_updates_plist)
@@ -1494,7 +1494,7 @@ class AppleUpdates(object):
proc = subprocess.Popen(cmd, shell=False, bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, unused_err = proc.communicate()
output, dummy_err = proc.communicate()
if proc.returncode == 0:
updates = [str(item)[5:] for item in str(output).splitlines()
if str(item).startswith(' * ')]
-1
View File
@@ -37,7 +37,6 @@ import xattr
import keychain
import munkicommon
from gurl import Gurl
#import munkistatus
from Foundation import NSHTTPURLResponse
+4 -4
View File
@@ -352,7 +352,7 @@ def ImportBom(bompath, curs):
proc = subprocess.Popen(["/usr/sbin/pkgutil", "--pkg-info-plist", pkgid],
bufsize=1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(pliststr, unused_err) = proc.communicate()
(pliststr, dummy_err) = proc.communicate()
if pliststr:
plist = FoundationPlist.readPlistFromString(pliststr)
if "install-location" in plist:
@@ -433,7 +433,7 @@ def ImportFromPkgutil(pkgname, curs):
proc = subprocess.Popen(["/usr/sbin/pkgutil", "--pkg-info-plist", pkgid],
bufsize=1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(pliststr, unused_err) = proc.communicate()
(pliststr, dummy_err) = proc.communicate()
if pliststr:
plist = FoundationPlist.readPlistFromString(pliststr)
if "pkg-version" in plist:
@@ -763,7 +763,7 @@ def removeReceipts(pkgkeylist, noupdateapplepkgdb):
if receiptpath and os.path.exists(receiptpath):
munkicommon.display_detail("Removing %s...", receiptpath)
unused_retcode = subprocess.call(
dummy_retcode = subprocess.call(
["/bin/rm", "-rf", receiptpath])
# remove pkg info from our database
@@ -806,7 +806,7 @@ def removeReceipts(pkgkeylist, noupdateapplepkgdb):
proc = subprocess.Popen(cmd, bufsize=1,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
(output, dummy_err) = proc.communicate()
if output:
munkicommon.display_detail(
str(output).decode('UTF-8').rstrip('\n'))
+15 -15
View File
@@ -155,7 +155,7 @@ def getInstalledPackages():
proc = subprocess.Popen(['/usr/sbin/pkgutil', '--regexp',
'--pkg-info-plist', '.*'], bufsize=8192,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, unused_err) = proc.communicate()
(out, dummy_err) = proc.communicate()
while out:
(pliststr, out) = munkicommon.getFirstPlist(out)
if pliststr:
@@ -1518,7 +1518,7 @@ def processManagedUpdate(manifestitem, cataloglist, installinfo):
if someVersionInstalled(item_pl):
# add to the list of processed managed_updates
installinfo['managed_updates'].append(manifestitemname)
unused_result = processInstall(manifestitem, cataloglist, installinfo)
dummy_result = processInstall(manifestitem, cataloglist, installinfo)
else:
munkicommon.display_debug1(
'%s does not appear to be installed, so no managed updates...',
@@ -1907,7 +1907,7 @@ def processInstall(manifestitem, cataloglist, installinfo):
for update_item in update_list:
# call processInstall recursively so we get the
# latest version and dependencies
unused_result = processInstall(update_item,
dummy_result = processInstall(update_item,
cataloglist,
installinfo)
return True
@@ -1975,7 +1975,7 @@ def processInstall(manifestitem, cataloglist, installinfo):
for update_item in update_list:
# call processInstall recursively so we get updates
# and any dependencies
unused_result = processInstall(update_item, cataloglist,
dummy_result = processInstall(update_item, cataloglist,
installinfo)
return True
@@ -2090,14 +2090,14 @@ def processManifestForKey(manifest, manifest_key, installinfo,
if munkicommon.stopRequested():
return {}
if manifest_key == 'managed_installs':
unused_result = processInstall(item, cataloglist,
dummy_result = processInstall(item, cataloglist,
installinfo)
elif manifest_key == 'managed_updates':
processManagedUpdate(item, cataloglist, installinfo)
elif manifest_key == 'optional_installs':
processOptionalInstall(item, cataloglist, installinfo)
elif manifest_key == 'managed_uninstalls':
unused_result = processRemoval(item, cataloglist,
dummy_result = processRemoval(item, cataloglist,
installinfo)
@@ -2396,7 +2396,7 @@ def processRemoval(manifestitem, cataloglist, installinfo):
lookForUpdates(alt_uninstall_item_name_with_version, cataloglist))
for update_item in update_list:
# call us recursively...
unused_result = processRemoval(update_item, cataloglist, installinfo)
dummy_result = processRemoval(update_item, cataloglist, installinfo)
# finish recording info for this removal
iteminfo['installed'] = True
@@ -2462,7 +2462,7 @@ def getCatalogs(cataloglist):
munkicommon.display_detail('Getting catalog %s...', catalogname)
message = 'Retrieving catalog "%s"...' % catalogname
try:
unused_value = getResourceIfChangedAtomically(
dummy_value = getResourceIfChangedAtomically(
catalogurl, catalogpath, message=message)
except fetch.MunkiDownloadError, err:
munkicommon.display_error(
@@ -2534,7 +2534,7 @@ def getmanifest(partialurl, suppress_errors=False):
manifestpath = os.path.join(manifest_dir, manifestname)
message = 'Retrieving list of software for this machine...'
try:
unused_value = getResourceIfChangedAtomically(
dummy_value = getResourceIfChangedAtomically(
manifesturl, manifestpath, message=message)
except fetch.MunkiDownloadError, err:
if not suppress_errors:
@@ -2545,7 +2545,7 @@ def getmanifest(partialurl, suppress_errors=False):
try:
# read plist to see if it is valid
unused_data = FoundationPlist.readPlist(manifestpath)
dummy_data = FoundationPlist.readPlist(manifestpath)
except FoundationPlist.NSPropertyListSerializationException:
errormsg = 'manifest returned for %s is invalid.' % manifestdisplayname
munkicommon.display_error(errormsg)
@@ -2756,7 +2756,7 @@ def download_icons(item_list):
item_name = item.get('display_name') or item['name']
message = 'Getting icon for %s...' % item_name
try:
unused_value = getResourceIfChangedAtomically(
dummy_value = getResourceIfChangedAtomically(
icon_url, icon_path, message=message)
except fetch.MunkiDownloadError, err:
munkicommon.display_debug1(
@@ -2818,7 +2818,7 @@ def download_client_resources():
for filename in filenames:
resource_url = resource_base_url + filename
try:
unused_value = getResourceIfChangedAtomically(
dummy_value = getResourceIfChangedAtomically(
resource_url, resource_archive_path, message=message)
downloaded_resource_path = resource_archive_path
break
@@ -2911,7 +2911,7 @@ def check(client_id='', localmanifestpath=None):
for item in autoremovalitems:
if munkicommon.stopRequested():
return 0
unused_result = processRemoval(item, cataloglist, installinfo)
dummy_result = processRemoval(item, cataloglist, installinfo)
# look for additional updates
munkicommon.display_detail('**Checking for managed updates**')
@@ -2976,7 +2976,7 @@ def check(client_id='', localmanifestpath=None):
selfserveinstalls = [item for item in selfserveinstalls
if item in available_optional_installs]
for item in selfserveinstalls:
unused_result = processInstall(
dummy_result = processInstall(
item, cataloglist, installinfo)
# we don't need to filter uninstalls
@@ -3328,7 +3328,7 @@ def getDataFromURL(url):
os.unlink(urldata)
except (IOError, OSError), err:
munkicommon.display_warning('Error in getDataFromURL: %s', err)
unused_result = getResourceIfChangedAtomically(url, urldata)
dummy_result = getResourceIfChangedAtomically(url, urldata)
try:
fdesc = open(urldata)
data = fdesc.read()
+1 -1
View File
@@ -80,7 +80,7 @@ class Supervisor(object):
for k in kwargs:
self.options[k] = kwargs[k]
def signalHandler(self, signum, unused_frame):
def signalHandler(self, signum, dummy_frame):
if signum == signal.SIGUSR1:
self.continue_sleeping = False
+1 -1
View File
@@ -155,7 +155,7 @@ def main():
help='Munki packages dir name; default "pkgs".')
p.add_option('-u', "--update_existing", action='store_true',
help='Update existing hashes.')
options, unused_arguments = p.parse_args()
options, dummy_arguments = p.parse_args()
pkgsinfo_path = os.path.join(options.munki_root, options.pkgsinfo_dir_name)
pkgs_path = os.path.join(options.munki_root, options.pkgs_dir_name)