Blackened everything

This commit is contained in:
Joel Collins 2019-09-15 14:17:52 +01:00
parent e213647217
commit 5966ce29be
57 changed files with 1938 additions and 1414 deletions

View file

@ -1,4 +1,4 @@
__all__ = ['Plugin', 'HelloWorldAPI', 'IdentifyAPI']
__all__ = ["Plugin", "HelloWorldAPI", "IdentifyAPI"]
from .plugin import Plugin
from .api import HelloWorldAPI, IdentifyAPI
from .api import HelloWorldAPI, IdentifyAPI

View file

@ -9,11 +9,14 @@ class IdentifyAPI(MicroscopeViewPlugin):
"""
A simple example API plugin, attached through the main microscope plugin.
"""
def get(self):
"""
Method to call when an HTTP GET request is made.
"""
data = self.plugin.identify() # Call a method from our plugin, using the MicroscopeViewPlugin.plugin shortcut
data = (
self.plugin.identify()
) # Call a method from our plugin, using the MicroscopeViewPlugin.plugin shortcut
return Response(escape(data))
@ -28,7 +31,7 @@ class HelloWorldAPI(MicroscopeViewPlugin):
"""
# If the microscope does not already contain our plugin_string attribute
if not hasattr(self.microscope, 'plugin_string'):
if not hasattr(self.microscope, "plugin_string"):
# Make a string, using the MicroscopeViewPlugin.plugin shortcut
self.microscope.plugin_string = self.plugin.hello_world()
@ -43,7 +46,7 @@ class HelloWorldAPI(MicroscopeViewPlugin):
payload = JsonResponse(request)
# Extract a value from the JSON key 'plugin_string', and convert to a string. If no value is given, default to empty.
new_plugin_string = payload.param('plugin_string', default='', convert=str)
new_plugin_string = payload.param("plugin_string", default="", convert=str)
if new_plugin_string: # If not None or empty
# Set microscope attribute to the specified string
@ -56,6 +59,7 @@ class LongRunningAPI(MicroscopeViewPlugin):
"""
An example API plugin that uses a long-running plugin method.
"""
def post(self):
"""
Method to call when an HTTP POST request is made.
@ -64,7 +68,7 @@ class LongRunningAPI(MicroscopeViewPlugin):
payload = JsonResponse(request)
# Extract a values from the JSON payload.
time_to_run = payload.param('time', default=10, convert=int)
time_to_run = payload.param("time", default=10, convert=int)
# Attach the long-running method as a microscope task
try:
@ -79,6 +83,7 @@ class SomeExceptionAPI(MicroscopeViewPlugin):
"""
An example API plugin that uses a long-running but broken plugin method.
"""
def post(self):
"""
Method to call when an HTTP POST request is made.

View file

@ -11,10 +11,10 @@ class Plugin(MicroscopePlugin):
"""
api_views = {
'/identify': IdentifyAPI,
'/hello': HelloWorldAPI,
'/long_running': LongRunningAPI,
'/some_exception': SomeExceptionAPI,
"/identify": IdentifyAPI,
"/hello": HelloWorldAPI,
"/long_running": LongRunningAPI,
"/some_exception": SomeExceptionAPI,
}
def identify(self):
@ -22,7 +22,9 @@ class Plugin(MicroscopePlugin):
Demonstrate access to Microscope.camera, and Microscope.stage
"""
response = "My parent camera is {}, and my parent stage is {}.".format(self.microscope.camera, self.microscope.stage)
response = "My parent camera is {}, and my parent stage is {}.".format(
self.microscope.camera, self.microscope.stage
)
print(response)
return response
@ -39,7 +41,7 @@ class Plugin(MicroscopePlugin):
"""
with self.microscope.lock:
time.sleep(3)
result = 15./0
result = 15.0 / 0
return result