Skip to content

Commit d983f19

Browse files
committed
flake8: fix warnings
Signed-off-by: Heiko Thiery <[email protected]>
1 parent 85812ee commit d983f19

File tree

15 files changed

+53
-39
lines changed

15 files changed

+53
-39
lines changed

pyipmi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from . import msgs
3636

3737
from .errors import IpmiTimeoutError, CompletionCodeError, RetryError
38-
from .msgs.registry import create_request_by_name, create_message
38+
from .msgs.registry import create_request_by_name
3939
from .session import Session
4040
from .utils import check_completion_code, is_string
4141

pyipmi/chassis.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
BOOT_PARAMETER_BOOT_INITIATOR_INFO = 6
3737
BOOT_PARAMETER_BOOT_INITIATOR_MAILBOX = 7
3838

39+
3940
class BootDevice(str, Enum):
4041
NO_OVERRIDE = "no override",
4142
PXE = "pxe",
@@ -91,6 +92,7 @@ def data_to_boot_mode(data):
9192
boot_mode = "legacy" if boot_mode_raw == 0 else "efi"
9293
return boot_mode
9394

95+
9496
def data_to_boot_persistency(data):
9597
"""
9698
Convert a `GetSystemBootOptions(BOOT_PARAMETER_BOOT_FLAGS)` response data
@@ -99,6 +101,7 @@ def data_to_boot_persistency(data):
99101
boot_persistent_raw = (data[0] >> 6) & 1
100102
return boot_persistent_raw == 1
101103

104+
102105
def data_to_boot_device(data):
103106
"""
104107
Convert a `GetSystemBootOptions(BOOT_PARAMETER_BOOT_FLAGS)` response data
@@ -107,6 +110,7 @@ def data_to_boot_device(data):
107110
boot_device_raw = (data[1] >> 2) & 0b1111
108111
return CONVERT_RAW_TO_BOOT_DEVICE[boot_device_raw]
109112

113+
110114
def boot_options_to_data(boot_device, boot_mode, boot_persistency):
111115
"""
112116
Convert a boot mode (string), boot device (string) and boot persistency (bool)
@@ -138,6 +142,7 @@ def boot_options_to_data(boot_device, boot_mode, boot_persistency):
138142
data = ByteBuffer([boot_mode_raw | boot_persistent_raw, device_raw << 2, 0, 0, 0])
139143
return data
140144

145+
141146
class Chassis(object):
142147
def get_chassis_status(self):
143148
return ChassisStatus(self.send_message_with_name('GetChassisStatus'))
@@ -223,9 +228,9 @@ class ChassisStatus(State):
223228
fault = None
224229
control_fault = None
225230
restore_policy = None
226-
id_cmd_state_info_support=None
227-
chassis_id_state=None
228-
front_panel_button_capabilities=None
231+
id_cmd_state_info_support = None
232+
chassis_id_state = None
233+
front_panel_button_capabilities = None
229234
last_event = []
230235
chassis_state = []
231236

@@ -236,10 +241,12 @@ def _from_response(self, rsp):
236241
self.fault = bool(rsp.current_power_state.power_fault)
237242
self.control_fault = bool(rsp.current_power_state.power_control_fault)
238243
self.restore_policy = rsp.current_power_state.power_restore_policy
239-
self.id_cmd_state_info_support=bool(rsp.misc_chassis_state.id_cmd_state_info_support)
240-
self.chassis_id_state=rsp.misc_chassis_state.chassis_id_state
244+
self.id_cmd_state_info_support = \
245+
bool(rsp.misc_chassis_state.id_cmd_state_info_support)
246+
self.chassis_id_state = rsp.misc_chassis_state.chassis_id_state
241247
if rsp.front_panel_button_capabilities is not None:
242-
self.front_panel_button_capabilities=rsp.front_panel_button_capabilities
248+
self.front_panel_button_capabilities = \
249+
rsp.front_panel_button_capabilities
243250

244251
if rsp.last_power_event.ac_failed:
245252
self.last_event.append('ac_failed')

pyipmi/emulation.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import random
55
import socket
6-
import sys
76
import threading
87
import yaml
98

@@ -20,7 +19,6 @@
2019
create_response_message, create_request_by_name)
2120
from pyipmi.msgs import constants
2221
from pyipmi.session import Session
23-
from pyipmi.utils import ByteBuffer
2422

2523
UDP_IP = "127.0.0.1"
2624
UDP_PORT = 1623
@@ -87,8 +85,6 @@ def handle_get_device_id(context, req):
8785
@register_message_handler("GetFruInventoryAreaInfo")
8886
def handle_fru_inventory_are_info(context, req):
8987
rsp = create_response_message(req)
90-
fru_file_name = None
91-
9288
cfg = context.config
9389

9490
try:
@@ -102,7 +98,6 @@ def handle_fru_inventory_are_info(context, req):
10298
rsp.completion_code = constants.CC_REQ_DATA_NOT_PRESENT
10399
return rsp
104100

105-
106101
try:
107102
statinfo = os.stat(fru_filename)
108103
rsp.area_size = statinfo.st_size
@@ -117,8 +112,6 @@ def handle_fru_inventory_are_info(context, req):
117112
@register_message_handler("ReadFruData")
118113
def handle_fru_read(context, req):
119114
rsp = create_response_message(req)
120-
fru_file_name = None
121-
122115
cfg = context.config
123116

124117
try:
@@ -197,19 +190,13 @@ def handle_reserve_device_sdr_repository(context, req):
197190
return rsp
198191

199192

200-
#@register_message_handler("GetDeviceSdr")
201-
#def handle_get_device_sdr(config, session, req):
202-
# rsp = create_response_message(req)
203-
# return rsp
204-
205193
@register_message_handler("SendMessage")
206194
def handle_send_message(context, req):
207195
rsp = create_response_message(req)
208196
rsp.completion_code = constants.CC_PARAM_OUT_OF_RANGE
209197
return rsp
210198

211199

212-
213200
def handle_ipmi_request_msg(context, req):
214201
try:
215202
fct = handler_registry[type(req)]
@@ -293,7 +280,7 @@ def _create_invalid_response(ipmi_sdu):
293280

294281
tx_data = ipmb.encode_ipmb_msg(rsp_header, data)
295282
log().debug('IPMI TX: {}: {:s}'.format(rsp,
296-
' '.join('%02x' % b for b in array('B', tx_data))))
283+
' '.join('%02x' % b for b in array('B', tx_data))))
297284

298285
# rmcp ipmi rsp msg
299286
ipmi_tx = rmcp.IpmiMsg(context.session)
@@ -385,7 +372,7 @@ def main(args=None):
385372
connections = {}
386373

387374
while True:
388-
pdu, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
375+
pdu, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
389376

390377
# create new connection
391378
if addr not in connections:

pyipmi/interfaces/aardvark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
try:
2727
import pyaardvark
28-
except ImportError: # python 2
28+
except ImportError: # python 2
2929
pyaardvark = None
30-
except RuntimeError: # python 3
30+
except RuntimeError: # python 3
3131
pyaardvark = None
3232

3333

pyipmi/interfaces/ipmb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def decode(self, data):
107107
self.rq_sa = data[0]
108108
self.netfn = data[1] >> 2
109109
self.rq_lun = data[1] & 3
110-
self.checksum = data[2]
110+
self.checksum = data[2]
111111
self.rs_sa = data[3]
112112
self.rq_seq = data[4] >> 2
113113
self.rs_lun = data[4] & 3

pyipmi/interfaces/ipmbdev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _receive_raw(self, header):
7373
raise IpmiTimeoutError()
7474

7575
r, w, e = select.select([self._dev], [], [], timeout)
76-
if not self._dev in r:
76+
if self._dev not in r:
7777
poll_returned_no_data = True
7878
continue
7979

pyipmi/interfaces/ipmitool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def _parse_output(self, output):
112112
if self.re_unable_establish.match(line):
113113
raise IpmiConnectionError('ipmitool: {}'.format(line))
114114

115-
116115
# Check for completion code
117116
match_completion_code = self.re_completion_code.match(line)
118117
if match_completion_code:
@@ -268,7 +267,6 @@ def _build_open_ipmitool_cmd(self, target, lun, netfn, raw_bytes):
268267

269268
return cmd
270269

271-
272270
@staticmethod
273271
def _run_ipmitool(cmd):
274272
"""Legacy call of ipmitool (will be removed in future)."""

pyipmi/ipmitool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,12 @@ def main():
619619
if verbose:
620620
traceback.print_exc()
621621
sys.exit(1)
622-
except pyipmi.errors.IpmiTimeoutError as e:
622+
except pyipmi.errors.IpmiTimeoutError:
623623
print('Command timed out')
624624
if verbose:
625625
traceback.print_exc()
626626
sys.exit(1)
627-
except KeyboardInterrupt as e:
627+
except KeyboardInterrupt:
628628
if verbose:
629629
traceback.print_exc()
630630
sys.exit(1)

pyipmi/lan.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ def data_to_ip_address(data):
6868
"""
6969
return '.'.join(map(str, data))
7070

71+
7172
def ip_address_to_data(ip_address):
7273
"""
7374
Convert an ip address (string) into a
7475
`SetLanConfigurationParameters(LAN_PARAMETER_IP_ADDRESS)` request data.
7576
"""
7677
return ByteBuffer(map(int, ip_address.split('.')))
7778

79+
7880
def data_to_ip_source(data):
7981
"""
8082
Convert a `GetLanConfigurationParameters(LAN_PARAMETER_IP_ADDRESS_SOURCE)`
@@ -83,6 +85,7 @@ def data_to_ip_source(data):
8385
# The ip source is encoded in the last 4 bits of the response
8486
return CONVERT_RAW_TO_IP_SRC[data[0] & 0b1111]
8587

88+
8689
def ip_source_to_data(ip_source):
8790
"""
8891
Convert an ip source (string) into a
@@ -96,6 +99,7 @@ def ip_source_to_data(ip_source):
9699
raise ValueError(f"Unknown value for ip_source argument: {ip_source}. Possible values are: dhcp, static.")
97100
return data
98101

102+
99103
def data_to_mac_address(data):
100104
"""
101105
Convert a `GetLanConfigurationParameters(LAN_PARAMETER_MAC_ADDRESS)` response
@@ -104,6 +108,7 @@ def data_to_mac_address(data):
104108
"""
105109
return ':'.join([f"{i:02x}" for i in data])
106110

111+
107112
def data_to_vlan(data):
108113
"""
109114
Convert a `GetLanConfigurationParameters(LAN_PARAMETER_802_1Q_VLAN_ID)` response
@@ -126,6 +131,7 @@ def data_to_vlan(data):
126131
# 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 = 394
127132
return ((data[1] & 0b1111) << 8) | data[0]
128133

134+
129135
def vlan_to_data(vlan):
130136
"""
131137
Convert a vlan (int) into a

pyipmi/messaging.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .utils import check_completion_code
2222
from .state import State
2323

24+
2425
class PasswordOperation(int, Enum):
2526
DISABLE = 0b00
2627
ENABLE = 0b01
@@ -58,6 +59,7 @@ class UserPrivilegeLevel(str, Enum):
5859
UserPrivilegeLevel.NO_ACCESS: 0x0F
5960
}
6061

62+
6163
class Messaging(object):
6264
def get_channel_authentication_capabilities(self, channel, priv_lvl):
6365
req = create_request_by_name('GetChannelAuthenticationCapabilities')
@@ -128,6 +130,7 @@ def disable_user(self, userid):
128130
rsp = self.send_message(req)
129131
check_completion_code(rsp.completion_code)
130132

133+
131134
class ChannelAuthenticationCapabilities(State):
132135

133136
_functions = {
@@ -139,7 +142,7 @@ class ChannelAuthenticationCapabilities(State):
139142
}
140143

141144
def _from_response(self, rsp):
142-
self.channel= rsp.channel_number
145+
self.channel = rsp.channel_number
143146
self.auth_types = []
144147

145148
self.ipmi_1_5 = False
@@ -169,6 +172,7 @@ def __str__(self):
169172
s += ' Max Auth. type: %s\n' % self.get_max_auth_type()
170173
return s
171174

175+
172176
class UserAccess(State):
173177

174178
def _from_response(self, rsp):

0 commit comments

Comments
 (0)