Skip to content

Commit 24341f9

Browse files
anoo1bradbishop
authored andcommitted
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 <[email protected]>
1 parent a30ab9d commit 24341f9

File tree

10 files changed

+47
-27
lines changed

10 files changed

+47
-27
lines changed

pychassisctl/chassis_control.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def getUuid(self):
2828
uuid = data
2929
else:
3030
print "ERROR: UUID is not formatted correctly: " + data
31-
except:
31+
except Exception:
3232
print "ERROR: Unable to open uuid file: " + MACHINE_ID
3333

3434
return uuid
@@ -37,7 +37,7 @@ def __init__(self, bus, name):
3737
super(ChassisControlObject, self).__init__(
3838
conn=bus,
3939
object_path=name)
40-
## load utilized objects
40+
# load utilized objects
4141
self.dbus_objects = {
4242
'power_control': {
4343
'bus_name': 'org.openbmc.control.Power',
@@ -154,7 +154,7 @@ def getPowerState(self):
154154
intf = self.getInterface('power_control')
155155
return intf.getPowerState()
156156

157-
## Signal handler
157+
# Signal handler
158158

159159
def SystemStateHandler(self, state_name):
160160
if state_name in ["HOST_POWERED_OFF", "HOST_POWERED_ON"]:

pyflashbmc/bmc_update.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ def doExtract(members, files):
3030
def save_fw_env():
3131
fw_env = "/etc/fw_env.config"
3232
lines = 0
33-
files=[]
33+
files = []
3434
envcfg = open(fw_env, 'r')
3535
try:
3636
for line in envcfg.readlines():
3737
# ignore lines that are blank or start with #
38-
if (line.startswith("#")): continue
39-
if (not len(line.strip())): continue
40-
fn = line.partition("\t")[0];
38+
if (line.startswith("#")):
39+
continue
40+
if (not len(line.strip())):
41+
continue
42+
fn = line.partition("\t")[0]
4143
files.append(fn)
4244
lines += 1
4345
finally:
@@ -46,6 +48,7 @@ def save_fw_env():
4648
raise Exception("Error parsing %s\n" % fw_env)
4749
shutil.copyfile(files[0], os.path.join(UPDATE_PATH, "image-u-boot-env"))
4850

51+
4952
class BmcFlashControl(DbusProperties, DbusObjectManager):
5053
def __init__(self, bus, name):
5154
super(BmcFlashControl, self).__init__(
@@ -85,13 +88,13 @@ def TftpDownload(self, ip, filename):
8588
self.Set(DBUS_NAME, "filename", filename)
8689
pass
8790

88-
## Signal handler
91+
# Signal handler
8992
def download_error_handler(self, filename):
9093
if (filename == self.Get(DBUS_NAME, "filename")):
9194
self.Set(DBUS_NAME, "status", "Download Error")
9295

9396
def download_complete_handler(self, outfile, filename):
94-
## do update
97+
# do update
9598
if (filename != self.Get(DBUS_NAME, "filename")):
9699
return
97100

@@ -100,7 +103,7 @@ def download_complete_handler(self, outfile, filename):
100103
self.Set(DBUS_NAME, "status", "Download Complete")
101104
copy_files = {}
102105

103-
## determine needed files
106+
# determine needed files
104107
if not self.Get(DBUS_NAME, "update_kernel_and_apps"):
105108
copy_files["image-bmc"] = True
106109
else:
@@ -110,7 +113,7 @@ def download_complete_handler(self, outfile, filename):
110113
if self.Get(DBUS_NAME, "restore_application_defaults"):
111114
copy_files["image-rwfs"] = True
112115

113-
## make sure files exist in archive
116+
# make sure files exist in archive
114117
try:
115118
tar = tarfile.open(outfile, "r")
116119
files = {}
@@ -178,7 +181,7 @@ def Verify(self):
178181
self.Set(DBUS_NAME, "status", "Image ready to apply.")
179182
if (self.Get(DBUS_NAME, "auto_apply")):
180183
self.Apply()
181-
except:
184+
except Exception:
182185
self.Set(DBUS_NAME, "auto_apply", False)
183186
try:
184187
subprocess.check_output([
@@ -218,7 +221,7 @@ def Abort(self):
218221
if self.update_process:
219222
try:
220223
self.update_process.kill()
221-
except:
224+
except Exception:
222225
pass
223226
for file in os.listdir(UPDATE_PATH):
224227
if file.startswith('image-'):
@@ -285,13 +288,13 @@ def Apply(self):
285288
progress.close()
286289
os.unlink(progress.name)
287290
self.progress_name = None
288-
except:
291+
except Exception:
289292
pass
290293
raise
291294

292295
try:
293296
progress.close()
294-
except:
297+
except Exception:
295298
pass
296299

297300
@dbus.service.method(

pyinventorymgr/inventory_items.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, bus, name, data):
4040

4141
self.SetMultiple(INTF_NAME, data)
4242

43-
## this will load properties from cache
43+
# this will load properties from cache
4444
PropertyCacher.load(name, INTF_NAME, self.properties)
4545

4646
@dbus.service.method(
@@ -104,8 +104,8 @@ def getVersion():
104104
obj = InventoryItem(bus, obj_path, FRUS[f])
105105
obj_parent.add(obj_path, obj)
106106

107-
## TODO: this is a hack to update bmc inventory item with version
108-
## should be done by flash object
107+
# TODO: this is a hack to update bmc inventory item with version
108+
# should be done by flash object
109109
if (FRUS[f]['fru_type'] == "BMC"):
110110
version = getVersion()
111111
obj.update({'version': version})

pyinventorymgr/sync_inventory_items.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def get_bmc_mac_address(bus, prop):
7171
mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
7272
return mproxy(INV_INTF_NAME, prop)
7373

74+
7475
# Get Network Interface object.
7576
def get_network_interface_object(bus):
7677
mapper = obmc.mapper.Mapper(bus)
@@ -125,7 +126,7 @@ def get_sys_mac(obj):
125126
sys_mac = ''
126127
try:
127128
sys_mac = subprocess.check_output(["fw_printenv", "-n", "ethaddr"])
128-
except:
129+
except Exception:
129130
# Handle when mac does not exist in u-boot
130131
return sys_mac
131132
return sys_mac
@@ -159,6 +160,7 @@ def set_sys_uuid(uuid):
159160
else:
160161
print "Error setting uuid"
161162

163+
162164
if __name__ == '__main__':
163165
arg = argparse.ArgumentParser()
164166
arg.add_argument('-p')

pyipmitest/ipmi_debug.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DBUS_NAME = 'org.openbmc.HostIpmi'
1515
OBJ_NAME = '/org/openbmc/HostIpmi/1'
1616

17+
1718
def header(seq, netfn, lun, cmd):
1819
return (
1920
'seq: 0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd: 0x%02x\n') % (
@@ -25,16 +26,18 @@ def print_request(seq, netfn, lun, cmd, data):
2526
str += 'data: [%s]' % ', '.join(['0x%02x' % x for x in data])
2627
print str
2728

29+
2830
def print_response(seq, netfn, lun, cmd, cc, data):
2931
str = header(seq, netfn, lun, cmd)
3032
str += 'cc: 0x%02x\ndata: [%s]' % (
3133
cc, ', '.join(['0x%02x' % x for x in data])
3234
)
3335
print str
3436

37+
3538
class IpmiDebug(dbus.service.Object):
36-
def __init__(self,bus,name):
37-
dbus.service.Object.__init__(self,bus,name)
39+
def __init__(self, bus, name):
40+
dbus.service.Object.__init__(self, bus, name)
3841

3942
@dbus.service.signal(DBUS_NAME, "yyyyay")
4043
def ReceivedMessage(self, seq, netfn, lun, cmd, data):
@@ -51,6 +54,7 @@ def sendMessage(self, seq, netfn, lun, cmd, ccode, data):
5154
def setAttention(self):
5255
print "IPMI SMS_ATN set"
5356

57+
5458
class ConsoleReader(object):
5559
def __init__(self, ipmi_obj):
5660
self.buffer = ''
@@ -83,6 +87,7 @@ def line(self, data):
8387
self.seq += 1
8488
self.ipmi_obj.ReceivedMessage(self.seq, data[0], 0, data[1], data[2:])
8589

90+
8691
def main():
8792
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
8893
bus = dbus.SystemBus()
@@ -94,9 +99,10 @@ def main():
9499
name = dbus.service.BusName(DBUS_NAME, bus)
95100

96101
print ("Enter IPMI packet as hex values. First three bytes will be used"
97-
"as netfn and cmd.\nlun will be zero.")
102+
"as netfn and cmd.\nlun will be zero.")
98103
mainloop.run()
99104

105+
100106
if __name__ == '__main__':
101107
sys.exit(main())
102108

pysensormgr/sensor_manager2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ def SensorChange(self, value, path=None):
4444
else:
4545
print "ERROR: Sensor not found: "+path
4646

47+
4748
if __name__ == '__main__':
4849
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
4950
bus = get_dbus()
5051
root_sensor = SensorManager(bus, OBJ_PATH)
5152

52-
## instantiate non-polling sensors
53-
## these don't need to be in separate process
53+
# instantiate non-polling sensors
54+
# these don't need to be in separate process
5455
if has_system:
5556
for (id, the_sensor) in System.MISC_SENSORS.items():
5657
sensor_class = the_sensor['class']

pystatemgr/discover_system_state.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ def getProperty(bus, objs, key, prop):
6969
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
7070
return intf.Get(objs[key]['interface_name'], prop)
7171

72+
7273
def setProperty(bus, objs, key, prop, prop_value):
7374
obj = bus.get_object(
7475
objs[key]['bus_name'], objs[key]['object_name'])
7576
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
7677
return intf.Set(objs[key]['interface_name'], prop, prop_value)
7778

79+
7880
bus = dbus.SystemBus()
7981
pgood = getProperty(bus, dbus_objects, 'power', 'pgood')
8082

pysystemmgr/obmc/system/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from os.path import join
22
from glob import glob
33

4+
45
def find_gpio_base(path="/sys/class/gpio/"):
56
pattern = "gpiochip*"
67
for gc in glob(join(path, pattern)):
@@ -12,8 +13,10 @@ def find_gpio_base(path="/sys/class/gpio/"):
1213
# trigger a file not found exception
1314
open(join(path, "gpiochip"))
1415

16+
1517
GPIO_BASE = find_gpio_base()
1618

19+
1720
def convertGpio(name):
1821
offset = int(filter(str.isdigit, name))
1922
port = filter(str.isalpha, name.upper())

pysystemmgr/system_manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def gpioInit(self, name):
184184
return r
185185

186186
@dbus.service.method(DBUS_NAME, in_signature='',
187-
out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
187+
out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
188188
def getGpioConfiguration(self):
189189
power_config = System.GPIO_CONFIGS.get('power_config', {})
190190
power_good_in = power_config.get('power_good_in', '')
@@ -198,8 +198,9 @@ def getGpioConfiguration(self):
198198
fsi_enable = hostctl_config.get('fsi_enable', '')
199199
cronus_sel = hostctl_config.get('cronus_sel', '')
200200
optionals = hostctl_config.get('optionals', [])
201-
r = [power_good_in, latch_out, power_up_outs, reset_outs, pci_reset_outs,\
202-
fsi_data, fsi_clk, fsi_enable, cronus_sel, optionals]
201+
r = [power_good_in, latch_out, power_up_outs, reset_outs,
202+
pci_reset_outs, fsi_data, fsi_clk, fsi_enable, cronus_sel,
203+
optionals]
203204
print "Power GPIO config: " + str(r)
204205
return r
205206

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[install]
22
install_scripts=/usr/sbin
3+
[pycodestyle]
4+
exclude=./configs/

0 commit comments

Comments
 (0)