summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2018-01-26 15:07:23 -0600
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-02-12 23:17:41 +0000
commit24341f9d1335a7cb175cc67557f2a8bdbb89a2e8 (patch)
tree1f275b0eabac86f9f0469e6d7af4583e6f3f685c
parenta30ab9db33bb8d1c208b2b86b8e824c5c70dae54 (diff)
downloadtalos-skeleton-24341f9d1335a7cb175cc67557f2a8bdbb89a2e8.tar.gz
talos-skeleton-24341f9d1335a7cb175cc67557f2a8bdbb89a2e8.zip
pep8 fixes
Also ignore the configs/ directory since it only contains system configuration files named <system>.py. Change-Id: I0416239c4030ce5bc39473e65e560016cd4ffc75 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--pychassisctl/chassis_control.py6
-rw-r--r--pyflashbmc/bmc_update.py27
-rw-r--r--pyinventorymgr/inventory_items.py6
-rw-r--r--pyinventorymgr/sync_inventory_items.py4
-rw-r--r--pyipmitest/ipmi_debug.py12
-rw-r--r--pysensormgr/sensor_manager2.py5
-rw-r--r--pystatemgr/discover_system_state.py2
-rw-r--r--pysystemmgr/obmc/system/__init__.py3
-rw-r--r--pysystemmgr/system_manager.py7
-rw-r--r--setup.cfg2
10 files changed, 47 insertions, 27 deletions
diff --git a/pychassisctl/chassis_control.py b/pychassisctl/chassis_control.py
index 16fb554..091b8d6 100644
--- a/pychassisctl/chassis_control.py
+++ b/pychassisctl/chassis_control.py
@@ -28,7 +28,7 @@ class ChassisControlObject(DbusProperties, DbusObjectManager):
uuid = data
else:
print "ERROR: UUID is not formatted correctly: " + data
- except:
+ except Exception:
print "ERROR: Unable to open uuid file: " + MACHINE_ID
return uuid
@@ -37,7 +37,7 @@ class ChassisControlObject(DbusProperties, DbusObjectManager):
super(ChassisControlObject, self).__init__(
conn=bus,
object_path=name)
- ## load utilized objects
+ # load utilized objects
self.dbus_objects = {
'power_control': {
'bus_name': 'org.openbmc.control.Power',
@@ -154,7 +154,7 @@ class ChassisControlObject(DbusProperties, DbusObjectManager):
intf = self.getInterface('power_control')
return intf.getPowerState()
- ## Signal handler
+ # Signal handler
def SystemStateHandler(self, state_name):
if state_name in ["HOST_POWERED_OFF", "HOST_POWERED_ON"]:
diff --git a/pyflashbmc/bmc_update.py b/pyflashbmc/bmc_update.py
index a83eafe..c934e1a 100644
--- a/pyflashbmc/bmc_update.py
+++ b/pyflashbmc/bmc_update.py
@@ -30,14 +30,16 @@ def doExtract(members, files):
def save_fw_env():
fw_env = "/etc/fw_env.config"
lines = 0
- files=[]
+ files = []
envcfg = open(fw_env, 'r')
try:
for line in envcfg.readlines():
# ignore lines that are blank or start with #
- if (line.startswith("#")): continue
- if (not len(line.strip())): continue
- fn = line.partition("\t")[0];
+ if (line.startswith("#")):
+ continue
+ if (not len(line.strip())):
+ continue
+ fn = line.partition("\t")[0]
files.append(fn)
lines += 1
finally:
@@ -46,6 +48,7 @@ def save_fw_env():
raise Exception("Error parsing %s\n" % fw_env)
shutil.copyfile(files[0], os.path.join(UPDATE_PATH, "image-u-boot-env"))
+
class BmcFlashControl(DbusProperties, DbusObjectManager):
def __init__(self, bus, name):
super(BmcFlashControl, self).__init__(
@@ -85,13 +88,13 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
self.Set(DBUS_NAME, "filename", filename)
pass
- ## Signal handler
+ # Signal handler
def download_error_handler(self, filename):
if (filename == self.Get(DBUS_NAME, "filename")):
self.Set(DBUS_NAME, "status", "Download Error")
def download_complete_handler(self, outfile, filename):
- ## do update
+ # do update
if (filename != self.Get(DBUS_NAME, "filename")):
return
@@ -100,7 +103,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
self.Set(DBUS_NAME, "status", "Download Complete")
copy_files = {}
- ## determine needed files
+ # determine needed files
if not self.Get(DBUS_NAME, "update_kernel_and_apps"):
copy_files["image-bmc"] = True
else:
@@ -110,7 +113,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
if self.Get(DBUS_NAME, "restore_application_defaults"):
copy_files["image-rwfs"] = True
- ## make sure files exist in archive
+ # make sure files exist in archive
try:
tar = tarfile.open(outfile, "r")
files = {}
@@ -178,7 +181,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
self.Set(DBUS_NAME, "status", "Image ready to apply.")
if (self.Get(DBUS_NAME, "auto_apply")):
self.Apply()
- except:
+ except Exception:
self.Set(DBUS_NAME, "auto_apply", False)
try:
subprocess.check_output([
@@ -218,7 +221,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
if self.update_process:
try:
self.update_process.kill()
- except:
+ except Exception:
pass
for file in os.listdir(UPDATE_PATH):
if file.startswith('image-'):
@@ -285,13 +288,13 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
progress.close()
os.unlink(progress.name)
self.progress_name = None
- except:
+ except Exception:
pass
raise
try:
progress.close()
- except:
+ except Exception:
pass
@dbus.service.method(
diff --git a/pyinventorymgr/inventory_items.py b/pyinventorymgr/inventory_items.py
index 254cd9e..17b5eab 100644
--- a/pyinventorymgr/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -40,7 +40,7 @@ class InventoryItem(DbusProperties):
self.SetMultiple(INTF_NAME, data)
- ## this will load properties from cache
+ # this will load properties from cache
PropertyCacher.load(name, INTF_NAME, self.properties)
@dbus.service.method(
@@ -104,8 +104,8 @@ if __name__ == '__main__':
obj = InventoryItem(bus, obj_path, FRUS[f])
obj_parent.add(obj_path, obj)
- ## TODO: this is a hack to update bmc inventory item with version
- ## should be done by flash object
+ # TODO: this is a hack to update bmc inventory item with version
+ # should be done by flash object
if (FRUS[f]['fru_type'] == "BMC"):
version = getVersion()
obj.update({'version': version})
diff --git a/pyinventorymgr/sync_inventory_items.py b/pyinventorymgr/sync_inventory_items.py
index b00ef5c..a96c015 100644
--- a/pyinventorymgr/sync_inventory_items.py
+++ b/pyinventorymgr/sync_inventory_items.py
@@ -71,6 +71,7 @@ def get_bmc_mac_address(bus, prop):
mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
return mproxy(INV_INTF_NAME, prop)
+
# Get Network Interface object.
def get_network_interface_object(bus):
mapper = obmc.mapper.Mapper(bus)
@@ -125,7 +126,7 @@ def get_sys_mac(obj):
sys_mac = ''
try:
sys_mac = subprocess.check_output(["fw_printenv", "-n", "ethaddr"])
- except:
+ except Exception:
# Handle when mac does not exist in u-boot
return sys_mac
return sys_mac
@@ -159,6 +160,7 @@ def set_sys_uuid(uuid):
else:
print "Error setting uuid"
+
if __name__ == '__main__':
arg = argparse.ArgumentParser()
arg.add_argument('-p')
diff --git a/pyipmitest/ipmi_debug.py b/pyipmitest/ipmi_debug.py
index d81cb2e..a8b1001 100644
--- a/pyipmitest/ipmi_debug.py
+++ b/pyipmitest/ipmi_debug.py
@@ -14,6 +14,7 @@ import dbus.mainloop.glib
DBUS_NAME = 'org.openbmc.HostIpmi'
OBJ_NAME = '/org/openbmc/HostIpmi/1'
+
def header(seq, netfn, lun, cmd):
return (
'seq: 0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd: 0x%02x\n') % (
@@ -25,6 +26,7 @@ def print_request(seq, netfn, lun, cmd, data):
str += 'data: [%s]' % ', '.join(['0x%02x' % x for x in data])
print str
+
def print_response(seq, netfn, lun, cmd, cc, data):
str = header(seq, netfn, lun, cmd)
str += 'cc: 0x%02x\ndata: [%s]' % (
@@ -32,9 +34,10 @@ def print_response(seq, netfn, lun, cmd, cc, data):
)
print str
+
class IpmiDebug(dbus.service.Object):
- def __init__(self,bus,name):
- dbus.service.Object.__init__(self,bus,name)
+ def __init__(self, bus, name):
+ dbus.service.Object.__init__(self, bus, name)
@dbus.service.signal(DBUS_NAME, "yyyyay")
def ReceivedMessage(self, seq, netfn, lun, cmd, data):
@@ -51,6 +54,7 @@ class IpmiDebug(dbus.service.Object):
def setAttention(self):
print "IPMI SMS_ATN set"
+
class ConsoleReader(object):
def __init__(self, ipmi_obj):
self.buffer = ''
@@ -83,6 +87,7 @@ class ConsoleReader(object):
self.seq += 1
self.ipmi_obj.ReceivedMessage(self.seq, data[0], 0, data[1], data[2:])
+
def main():
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
@@ -94,9 +99,10 @@ def main():
name = dbus.service.BusName(DBUS_NAME, bus)
print ("Enter IPMI packet as hex values. First three bytes will be used"
- "as netfn and cmd.\nlun will be zero.")
+ "as netfn and cmd.\nlun will be zero.")
mainloop.run()
+
if __name__ == '__main__':
sys.exit(main())
diff --git a/pysensormgr/sensor_manager2.py b/pysensormgr/sensor_manager2.py
index 9e423e0..cfd8868 100644
--- a/pysensormgr/sensor_manager2.py
+++ b/pysensormgr/sensor_manager2.py
@@ -44,13 +44,14 @@ class SensorManager(DbusProperties, DbusObjectManager):
else:
print "ERROR: Sensor not found: "+path
+
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = get_dbus()
root_sensor = SensorManager(bus, OBJ_PATH)
- ## instantiate non-polling sensors
- ## these don't need to be in separate process
+ # instantiate non-polling sensors
+ # these don't need to be in separate process
if has_system:
for (id, the_sensor) in System.MISC_SENSORS.items():
sensor_class = the_sensor['class']
diff --git a/pystatemgr/discover_system_state.py b/pystatemgr/discover_system_state.py
index cc2ae10..9324eba 100644
--- a/pystatemgr/discover_system_state.py
+++ b/pystatemgr/discover_system_state.py
@@ -69,12 +69,14 @@ def getProperty(bus, objs, key, prop):
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
return intf.Get(objs[key]['interface_name'], prop)
+
def setProperty(bus, objs, key, prop, prop_value):
obj = bus.get_object(
objs[key]['bus_name'], objs[key]['object_name'])
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
return intf.Set(objs[key]['interface_name'], prop, prop_value)
+
bus = dbus.SystemBus()
pgood = getProperty(bus, dbus_objects, 'power', 'pgood')
diff --git a/pysystemmgr/obmc/system/__init__.py b/pysystemmgr/obmc/system/__init__.py
index ff6c537..03dc235 100644
--- a/pysystemmgr/obmc/system/__init__.py
+++ b/pysystemmgr/obmc/system/__init__.py
@@ -1,6 +1,7 @@
from os.path import join
from glob import glob
+
def find_gpio_base(path="/sys/class/gpio/"):
pattern = "gpiochip*"
for gc in glob(join(path, pattern)):
@@ -12,8 +13,10 @@ def find_gpio_base(path="/sys/class/gpio/"):
# trigger a file not found exception
open(join(path, "gpiochip"))
+
GPIO_BASE = find_gpio_base()
+
def convertGpio(name):
offset = int(filter(str.isdigit, name))
port = filter(str.isalpha, name.upper())
diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py
index 575304b..a36b7af 100644
--- a/pysystemmgr/system_manager.py
+++ b/pysystemmgr/system_manager.py
@@ -184,7 +184,7 @@ class SystemManager(DbusProperties, DbusObjectManager):
return r
@dbus.service.method(DBUS_NAME, in_signature='',
- out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
+ out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
def getGpioConfiguration(self):
power_config = System.GPIO_CONFIGS.get('power_config', {})
power_good_in = power_config.get('power_good_in', '')
@@ -198,8 +198,9 @@ class SystemManager(DbusProperties, DbusObjectManager):
fsi_enable = hostctl_config.get('fsi_enable', '')
cronus_sel = hostctl_config.get('cronus_sel', '')
optionals = hostctl_config.get('optionals', [])
- r = [power_good_in, latch_out, power_up_outs, reset_outs, pci_reset_outs,\
- fsi_data, fsi_clk, fsi_enable, cronus_sel, optionals]
+ r = [power_good_in, latch_out, power_up_outs, reset_outs,
+ pci_reset_outs, fsi_data, fsi_clk, fsi_enable, cronus_sel,
+ optionals]
print "Power GPIO config: " + str(r)
return r
diff --git a/setup.cfg b/setup.cfg
index ed3bf6e..b5cec1b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,4 @@
[install]
install_scripts=/usr/sbin
+[pycodestyle]
+exclude=./configs/
OpenPOWER on IntegriCloud