Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library

directory.
reviewable/pr18780/r1
Michael DeHaan 12 years ago
parent 61d10cd773
commit 3c2eba57fd

8
apt

@ -21,7 +21,7 @@
import traceback
# added to stave off future warnings about apt api
import warnings;
import warnings
warnings.filterwarnings('ignore', "apt API not stable yet", FutureWarning)
# APT related constants
@ -30,8 +30,7 @@ APT = "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical %s" % APT_PATH
def run_apt(command):
try:
cmd = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmd = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
except (OSError, IOError), e:
rc = 1
@ -131,7 +130,8 @@ def main():
)
try:
import apt, apt_pkg
import apt
import apt_pkg
except:
module.fail_json("Could not import python modules: apt, apt_pkg. Please install python-apt package.")

@ -58,7 +58,7 @@ def main():
module_fail_json(ansible_job_id=jid, results_file=log_path,
msg="Could not parse job output: %s" % data)
if not data.has_key("started"):
if not 'started' in data:
data['finished'] = 1
data['ansible_job_id'] = jid
module.exit_json(**data)

@ -112,13 +112,6 @@ def selinux_context(path):
context = ret[1].split(':')
return context
# ===========================================
# ===========================================
# support functions
@ -222,7 +215,9 @@ def rmtree_error(func, path, exc_info):
def main():
# FIXME: pass this around, should not use global
global module
module = AnsibleModule(
check_invalid_arguments = False,
argument_spec = dict(

@ -207,11 +207,9 @@ def main():
if state:
result['state'] = state
rc, stdout, stderr = _run("%s %s status" % (SERVICE, name))
module.exit_json(**result);
module.exit_json(**result)
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()

27
setup

@ -130,7 +130,7 @@ class Facts(object):
self.facts['selinux']['policyvers'] = 'unknown'
try:
(rc, configmode) = selinux.selinux_getenforcemode()
if rc == 0 and Facts.SELINUX_MODE_DICT.has_key(configmode):
if rc == 0 and configmode in Facts.SELINUX_MODE_DICT:
self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT[configmode]
else:
self.facts['selinux']['config_mode'] = 'unknown'
@ -138,7 +138,7 @@ class Facts(object):
self.facts['selinux']['config_mode'] = 'unknown'
try:
mode = selinux.security_getenforce()
if Facts.SELINUX_MODE_DICT.has_key(mode):
if mode in Facts.SELINUX_MODE_DICT:
self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT[mode]
else:
self.facts['selinux']['mode'] = 'unknown'
@ -196,19 +196,21 @@ class LinuxHardware(Hardware):
In addition, it also defines number of DMI facts.
"""
platform = 'Linux'
MEMORY_FACTS = ['MemTotal', 'SwapTotal', 'MemFree', 'SwapFree']
# DMI bits
DMI_DICT = { 'form_factor': '/sys/devices/virtual/dmi/id/chassis_type',
'product_name': '/sys/devices/virtual/dmi/id/product_name',
'product_serial': '/sys/devices/virtual/dmi/id/product_serial',
'product_uuid': '/sys/devices/virtual/dmi/id/product_uuid',
'product_version': '/sys/devices/virtual/dmi/id/product_version',
'system_vendor': '/sys/devices/virtual/dmi/id/sys_vendor',
'bios_date': '/sys/devices/virtual/dmi/id/bios_date',
'bios_version': '/sys/devices/virtual/dmi/id/bios_version' }
# From smolt and DMI spec
# See http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf
DMI_DICT = dict(
form_factor = '/sys/devices/virtual/dmi/id/chassis_type',
product_name = '/sys/devices/virtual/dmi/id/product_name',
product_serial = '/sys/devices/virtual/dmi/id/product_serial',
product_uuid = '/sys/devices/virtual/dmi/id/product_uuid',
product_version = '/sys/devices/virtual/dmi/id/product_version',
system_vendor = '/sys/devices/virtual/dmi/id/sys_vendor',
bios_date = '/sys/devices/virtual/dmi/id/bios_date',
bios_version = '/sys/devices/virtual/dmi/id/bios_version'
)
# DMI SPEC -- http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf
FORM_FACTOR = [ "Unknown", "Other", "Unknown", "Desktop",
"Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower",
"Portable", "Laptop", "Notebook", "Hand Held", "Docking Station",
@ -683,4 +685,3 @@ def main():
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()

Loading…
Cancel
Save