Commit 477ca2ed by Michael DeHaan

Make pep8 tests run against the library directory as well, and associated tweaks…

Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library
directory.
parent 72faf8eb
...@@ -71,7 +71,8 @@ pep8: ...@@ -71,7 +71,8 @@ pep8:
@echo "#############################################" @echo "#############################################"
@echo "# Running PEP8 Compliance Tests" @echo "# Running PEP8 Compliance Tests"
@echo "#############################################" @echo "#############################################"
pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261 lib/ bin/ -pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261 lib/ bin/
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261 --filename "*" library/
pyflakes: pyflakes:
pyflakes lib/ansible/*.py bin/* pyflakes lib/ansible/*.py bin/*
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
import traceback import traceback
# added to stave off future warnings about apt api # added to stave off future warnings about apt api
import warnings; import warnings
warnings.filterwarnings('ignore', "apt API not stable yet", FutureWarning) warnings.filterwarnings('ignore', "apt API not stable yet", FutureWarning)
# APT related constants # APT related constants
...@@ -30,8 +30,7 @@ APT = "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical %s" % APT_PATH ...@@ -30,8 +30,7 @@ APT = "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical %s" % APT_PATH
def run_apt(command): def run_apt(command):
try: try:
cmd = subprocess.Popen(command, shell=True, cmd = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate() out, err = cmd.communicate()
except (OSError, IOError), e: except (OSError, IOError), e:
rc = 1 rc = 1
...@@ -131,7 +130,8 @@ def main(): ...@@ -131,7 +130,8 @@ def main():
) )
try: try:
import apt, apt_pkg import apt
import apt_pkg
except: except:
module.fail_json("Could not import python modules: apt, apt_pkg. Please install python-apt package.") module.fail_json("Could not import python modules: apt, apt_pkg. Please install python-apt package.")
......
...@@ -58,7 +58,7 @@ def main(): ...@@ -58,7 +58,7 @@ def main():
module_fail_json(ansible_job_id=jid, results_file=log_path, module_fail_json(ansible_job_id=jid, results_file=log_path,
msg="Could not parse job output: %s" % data) msg="Could not parse job output: %s" % data)
if not data.has_key("started"): if not 'started' in data:
data['finished'] = 1 data['finished'] = 1
data['ansible_job_id'] = jid data['ansible_job_id'] = jid
module.exit_json(**data) module.exit_json(**data)
......
...@@ -113,13 +113,6 @@ def selinux_context(path): ...@@ -113,13 +113,6 @@ def selinux_context(path):
return context return context
# =========================================== # ===========================================
# ===========================================
# support functions # support functions
def user_and_group(filename): def user_and_group(filename):
...@@ -222,7 +215,9 @@ def rmtree_error(func, path, exc_info): ...@@ -222,7 +215,9 @@ def rmtree_error(func, path, exc_info):
def main(): def main():
# FIXME: pass this around, should not use global
global module global module
module = AnsibleModule( module = AnsibleModule(
check_invalid_arguments = False, check_invalid_arguments = False,
argument_spec = dict( argument_spec = dict(
......
...@@ -147,9 +147,9 @@ def mount(**kwargs): ...@@ -147,9 +147,9 @@ def mount(**kwargs):
name = kwargs['name'] name = kwargs['name']
if os.path.ismount(name): if os.path.ismount(name):
cmd = ['/bin/mount', '-o', 'remount', name] cmd = [ '/bin/mount', '-o', 'remount', name ]
else: else:
cmd = ['/bin/mount', name ] cmd = [ '/bin/mount', name ]
call = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) call = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = call.communicate() out, err = call.communicate()
......
...@@ -207,11 +207,9 @@ def main(): ...@@ -207,11 +207,9 @@ def main():
if state: if state:
result['state'] = state result['state'] = state
rc, stdout, stderr = _run("%s %s status" % (SERVICE, name)) 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 # this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main() main()
...@@ -130,7 +130,7 @@ class Facts(object): ...@@ -130,7 +130,7 @@ class Facts(object):
self.facts['selinux']['policyvers'] = 'unknown' self.facts['selinux']['policyvers'] = 'unknown'
try: try:
(rc, configmode) = selinux.selinux_getenforcemode() (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] self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT[configmode]
else: else:
self.facts['selinux']['config_mode'] = 'unknown' self.facts['selinux']['config_mode'] = 'unknown'
...@@ -138,7 +138,7 @@ class Facts(object): ...@@ -138,7 +138,7 @@ class Facts(object):
self.facts['selinux']['config_mode'] = 'unknown' self.facts['selinux']['config_mode'] = 'unknown'
try: try:
mode = selinux.security_getenforce() 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] self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT[mode]
else: else:
self.facts['selinux']['mode'] = 'unknown' self.facts['selinux']['mode'] = 'unknown'
...@@ -196,19 +196,21 @@ class LinuxHardware(Hardware): ...@@ -196,19 +196,21 @@ class LinuxHardware(Hardware):
In addition, it also defines number of DMI facts. In addition, it also defines number of DMI facts.
""" """
platform = 'Linux' platform = 'Linux'
MEMORY_FACTS = ['MemTotal', 'SwapTotal', 'MemFree', 'SwapFree'] MEMORY_FACTS = ['MemTotal', 'SwapTotal', 'MemFree', 'SwapFree']
# DMI bits # DMI bits
DMI_DICT = { 'form_factor': '/sys/devices/virtual/dmi/id/chassis_type', DMI_DICT = dict(
'product_name': '/sys/devices/virtual/dmi/id/product_name', form_factor = '/sys/devices/virtual/dmi/id/chassis_type',
'product_serial': '/sys/devices/virtual/dmi/id/product_serial', product_name = '/sys/devices/virtual/dmi/id/product_name',
'product_uuid': '/sys/devices/virtual/dmi/id/product_uuid', product_serial = '/sys/devices/virtual/dmi/id/product_serial',
'product_version': '/sys/devices/virtual/dmi/id/product_version', product_uuid = '/sys/devices/virtual/dmi/id/product_uuid',
'system_vendor': '/sys/devices/virtual/dmi/id/sys_vendor', product_version = '/sys/devices/virtual/dmi/id/product_version',
'bios_date': '/sys/devices/virtual/dmi/id/bios_date', system_vendor = '/sys/devices/virtual/dmi/id/sys_vendor',
'bios_version': '/sys/devices/virtual/dmi/id/bios_version' } bios_date = '/sys/devices/virtual/dmi/id/bios_date',
# From smolt and DMI spec bios_version = '/sys/devices/virtual/dmi/id/bios_version'
# See http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf )
# DMI SPEC -- http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf
FORM_FACTOR = [ "Unknown", "Other", "Unknown", "Desktop", FORM_FACTOR = [ "Unknown", "Other", "Unknown", "Desktop",
"Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower", "Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower",
"Portable", "Laptop", "Notebook", "Hand Held", "Docking Station", "Portable", "Laptop", "Notebook", "Hand Held", "Docking Station",
...@@ -683,4 +685,3 @@ def main(): ...@@ -683,4 +685,3 @@ def main():
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main() main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment