Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Apr 10, 2017
1 parent da65c30 commit e7942a2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions mpf/core/bcp/bcp_interface.py
Expand Up @@ -290,7 +290,7 @@ def _monitor_modes(self, client):
self.machine.bcp.transport.add_handler_to_transport("_modes", client)

def _monitor_modes_stop(self, client):
"""stop monitoring all mode events (start, stop) via the specified client."""
"""Stop monitoring all mode events (start, stop) via the specified client."""
self.machine.bcp.transport.remove_transport_from_handle("_modes", client)

if not self.machine.bcp.transport.get_transports_for_handler("_modes"):
Expand Down Expand Up @@ -405,8 +405,8 @@ def _bcp_receive_error(self, client, **kwargs):
kwargs, str(client))

def _bcp_receive_reset_complete(self, client, **kwargs):
"""A remote BCP host has sent a BCP reset_complete message indicating their reset process
has completed."""
"""A remote BCP host has sent a BCP reset_complete message indicating their reset process has completed."""
del kwargs
self.debug_log("Received reset_complete from client: %s %s", client.name)
self._client_reset_complete_status[client] = True

Expand Down
6 changes: 3 additions & 3 deletions mpf/core/file_manager.py
Expand Up @@ -83,9 +83,9 @@ class FileManager(object):
def init(cls):
"""Initialise file manager."""
# Needs to be a separate method to prevent circular import
for module in mpf.file_interfaces.__all__:
importlib.import_module('mpf.file_interfaces.{}'.format(module))
module_obj = getattr(mpf.file_interfaces, module)
for module_name in mpf.file_interfaces.__all__:
importlib.import_module('mpf.file_interfaces.{}'.format(module_name))
module_obj = getattr(mpf.file_interfaces, module_name)
interface_class = getattr(module_obj, "file_interface_class")

this_instance = interface_class()
Expand Down
2 changes: 1 addition & 1 deletion mpf/core/machine.py
Expand Up @@ -475,7 +475,7 @@ def _load_core_modules(self):
setattr(self, name, m)

def _load_hardware_platforms(self):
"""Load all hardware platforms"""
"""Load all hardware platforms."""
self.validate_machine_config_section('hardware')
# if platform is forced use that one
if self.options['force_platform']:
Expand Down
1 change: 0 additions & 1 deletion mpf/core/mode_controller.py
Expand Up @@ -431,7 +431,6 @@ def register_stop_method(self, callback, priority=0):

def remove_stop_method(self, callback, priority=0):
"""Remove an existing stop method."""

if (callback, priority) in self.stop_methods:
self.stop_methods.remove((callback, priority))

Expand Down
22 changes: 15 additions & 7 deletions tools/afl_fuzz.py
@@ -1,4 +1,5 @@
#!/usr/bin/python3
"""AFL fuzzer."""
import argparse
import asyncio
import os
Expand All @@ -16,7 +17,10 @@

class AflRunner(object):

"""AFL fuzzer."""

def __init__(self, use_virtual):
"""Initialize fuzzer."""
self.loop = None
self.clock = None
self.machine = None # type: TestMachineController
Expand All @@ -36,20 +40,22 @@ def _exception_handler(self, loop, context):
self._exception = context

def get_platform(self):
"""Return platform."""
if self.use_virtual:
return "virtual"
else:
return "smart_virtual"

def getConfigFile(self):
def getConfigFile(self): # noqa
"""Return config file."""
return "config.yaml"

def getAbsoluteMachinePath(self):
# creates an absolute path based on machine_path
def getAbsoluteMachinePath(self): # noqa
"""Return an absolute path based on machine_path."""
return "/home/kantert/cloud/flipper/src/good_vs_evil"

def getOptions(self):

def getOptions(self): # noqa
"""Return option arrays."""
mpfconfig = os.path.abspath(os.path.join(
mpf.core.__path__[0], os.pardir, 'mpfconfig.yaml'))

Expand All @@ -64,6 +70,7 @@ def getOptions(self):
}

def advance_time_and_run(self, delta=1.0):
"""Advance time and run."""
try:
self.loop.run_until_complete(asyncio.sleep(delay=delta, loop=self.loop))
return
Expand All @@ -75,6 +82,7 @@ def advance_time_and_run(self, delta=1.0):
raise e

def setUp(self, machine_path):
"""Set up fuzzer."""
self.loop = TimeTravelLoop()
self.loop.set_exception_handler(self._exception_handler)
self.clock = TestClock(self.loop)
Expand Down Expand Up @@ -106,7 +114,6 @@ def add_balls(self):
if device.config['entrance_switch']:
self.machine.switch_controller.process_switch_obj(device.config['entrance_switch'], 1, True)


# let balls settle
self.advance_time_and_run(10)

Expand All @@ -118,6 +125,7 @@ def start_game(self):
self.machine.switch_controller.process_switch_obj(switch, 0, True)

def run(self, actions):
"""Run fuzzer."""
for action in actions:
if action & 0b10000000:
ms = int(action & 0b01111111)
Expand Down Expand Up @@ -191,7 +199,7 @@ def run(self, actions):
# keep effort minimal after those two lines. everything before this will execute only once.
# everything after this on every run

import afl
import afl # noqa
afl.init()

action_str = sys.stdin.buffer.read(-1)
Expand Down

0 comments on commit e7942a2

Please sign in to comment.