Skip to content

Commit

Permalink
Merge branch 'dev' into 080-backport-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Oct 29, 2024
2 parents 1ede5a3 + 6a2859a commit c05db9d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions mpf/core/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def __iter__(self):
self.machine.log.warning("Iterating device collections directly is deprecated and will be removed. "
"Access by value(): device_collections[%s] -> device_collections['%s'].values()",
self.name, self.name)
for item in self.values():
yield item
yield from self.values()

def items_tagged(self, tag) -> List["Device"]:
"""Return of list of device objects which have a certain tag.
Expand Down
9 changes: 5 additions & 4 deletions mpf/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ def format_log_line(self, msg, context, error_no) -> str:
if error_no:
error_slug = "Log-{}-{}".format(self.log.name if self.log else "", error_no)
error_url = log_url.format(error_slug)
if error_no and context:
return "{} Context: {} Log Code: {} ({})".format(msg, context, error_slug, error_url)

if context:
return "{} Context: {} Log Code: {} ({})".format(msg, context, error_slug, error_url)
return "{} Log Code: {} ({})".format(msg, error_slug, error_url)

if context:
return "{} Context: {} ".format(msg, context)
if error_no:
return "{} Log Code: {} ({})".format(msg, error_slug, error_url)

return msg

Expand Down
3 changes: 1 addition & 2 deletions mpf/core/utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ def flatten_list(incoming_list):
"""Convert a list of nested lists and/or values into a single one-dimensional list."""
for item in incoming_list:
if isinstance(item, IterableCollection) and not isinstance(item, str):
for inner_item in Util.flatten_list(item):
yield inner_item
yield from Util.flatten_list(item)
else:
yield item

Expand Down
3 changes: 2 additions & 1 deletion mpf/modes/service/code/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ def _generate_light_chains(self): # pylint: disable=too-many-locals
for board, l in items:
numbers = l.get_hw_numbers()
chain_2 = None
addr_2 = None
# Just choose the first one as representative?
number = numbers[0]
if "-" in number:
Expand Down Expand Up @@ -557,7 +558,7 @@ def _generate_light_chains(self): # pylint: disable=too-many-locals
items.append(LightChainMap(platform_name, chain_name, chain))
# do not crash if no lights are configured
if not items: # pragma: no cover
return
return []

items.sort(key=lambda x: x.chain)
return items
Expand Down
3 changes: 1 addition & 2 deletions mpf/platforms/fast/communicators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ async def _socket_writer(self):
if self.pause_sending_flag.is_set():
await self.pause_sending_flag.wait()

# TODO better way to catch shutting down?
except SerialException as e:
self.log.error(e)
return # TODO better way to catch shutting down?

def write_to_port(self, msg, log_msg=None):
"""Send a message as is, without encoding or adding a <CR> character."""
Expand All @@ -464,4 +464,3 @@ def write_to_port(self, msg, log_msg=None):
self.writer.write(msg)
except AttributeError:
self.log.warning("Serial connection is not open. Cannot send message: %s", msg)
return
5 changes: 3 additions & 2 deletions mpf/platforms/fast/fast_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def _pulse(self, pulse_settings: PulseSettings, hold_settings: HoldSettings = No
reconfigured = True

if hold_settings is not None:
hold_power = Util.float_to_pwm8_hex_string(hold_settings.power)
hold_ms = "00"

if hold_settings.duration > 25500:
raise AssertionError("FAST platform does not support hold durations > 25500ms")
if 25500 >= hold_settings.duration > 255:
Expand All @@ -512,8 +515,6 @@ def _pulse(self, pulse_settings: PulseSettings, hold_settings: HoldSettings = No
hold_ms = Util.int_to_hex_string(hold_settings.duration)
mode = '10'

hold_power = Util.float_to_pwm8_hex_string(hold_settings.power)

else:
hold_ms = self.current_driver_config.param3
hold_power = self.current_driver_config.param4
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/light_segment_displays.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging

from mpf.devices.segment_display.segment_display_text import ColoredSegmentDisplayText
from mpf.core.segment_mappings import SEVEN_SEGMENTS, BCD_SEGMENTS, FOURTEEN_SEGMENTS, SIXTEEN_SEGMENTS,\
from mpf.core.segment_mappings import SEVEN_SEGMENTS, BCD_SEGMENTS, FOURTEEN_SEGMENTS, SIXTEEN_SEGMENTS, \
EIGHT_SEGMENTS, TextToSegmentMapper
from mpf.platforms.interfaces.segment_display_platform_interface import SegmentDisplaySoftwareFlashPlatformInterface
from mpf.core.platform import SegmentDisplaySoftwareFlashPlatform
Expand Down
5 changes: 2 additions & 3 deletions mpf/platforms/opp/opp.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ def parse_light_number_to_channels(self, number: str, subtype: str):
]

self.raise_config_error("Unknown subtype {}".format(subtype), 8)
return []

def configure_light(self, number, subtype, config, platform_settings):
"""Configure a led or matrix light."""
Expand Down Expand Up @@ -949,7 +948,6 @@ def configure_light(self, number, subtype, config, platform_settings):
return self.opp_incands[index].configure_software_fade_incand(light_num)

self.raise_config_error("Unknown subtype {}".format(subtype), 12)
return None

async def _poll_sender(self, chain_serial):
"""Poll switches."""
Expand Down Expand Up @@ -1148,6 +1146,7 @@ async def configure_servo(self, number, config: dict) -> OPPServo:
"""Generate an OPPServo class with the given number."""
del config
chain_serial, _, pin_number = number.split('-') # Unused value is 'card'
possible_inputs = None

if self.min_version[chain_serial] < 0x02020002:
self.raise_config_error("Servos not supported on this OPP FW version: {}.".format(
Expand All @@ -1157,7 +1156,7 @@ async def configure_servo(self, number, config: dict) -> OPPServo:
if inputs.chain_serial == chain_serial:
possible_inputs = self._get_numbers(inputs.mask)

if 8 <= int(pin_number) < 16 and int(pin_number) in possible_inputs:
if 8 <= int(pin_number) < 16 and possible_inputs and int(pin_number) in possible_inputs:
servo_number = int(pin_number) - 8
else:
self.raise_config_error("Servo unavailable at this number: {}.".format(number), 24)
Expand Down
2 changes: 1 addition & 1 deletion mpf/plugins/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _load_defaults(self):

self.switchnames_to_audit = {
# Don't audit tagged switches, or credit switches during free play
x.name for x in self.machine.switches.values() if \
x.name for x in self.machine.switches.values() if
('no_audit' not in x.tags) and ('no_audit_free' not in x.tags or not is_free_play)
}

Expand Down

0 comments on commit c05db9d

Please sign in to comment.