Skip to content
Snippets Groups Projects
Commit c8f51ea0 authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

PEP-8 stuff

parent e5214c8c
Branches
Tags
1 merge request!12Python 3 Support
......@@ -62,16 +62,17 @@ class TransmitError(Exception):
super(TransmitError, self).__init__(self,
"No reply received.")
def _serial_process(ser_port, proc_pipe, ctrl_pipe, data_pipe):
ser_logger = logging.getLogger("{}._serial_process".format(__name__))
connected = False
for i in range(5):
time.sleep(1) # Give OS time to enumerate
try:
ser = serial.Serial(ser_port, timeout=1)
# ser = serial.Serial(ser_port, timeout=1)
ser_logger.info("Connecting")
time.sleep(.5)
connected = True
......
......@@ -29,6 +29,7 @@ from ..errors import InputError, VarError
from ..dstat import state
from ..experiments.experiment_template import Experiment, dstat_logger
def measure_offset(time):
gain_trim_table = [None, 'r100_trim', 'r3k_trim', 'r30k_trim', 'r300k_trim',
'r3M_trim', 'r30M_trim', 'r100M_trim']
......@@ -46,6 +47,7 @@ def measure_offset(time):
return gain_offset
class CALExp(Experiment):
id = 'cal'
"""Offset calibration experiment"""
......
......@@ -16,7 +16,7 @@ class ChronoampBox(PlotBox):
subplot.ticklabel_format(style='sci', scilimits=(0, 3),
useOffset=False, axis='y')
subplot.plot([],[])
class Chronoamp(Experiment):
id = 'cae'
"""Chronoamperometry experiment"""
......
......@@ -57,6 +57,7 @@ logger = logging.getLogger(__name__)
dstat_logger = logging.getLogger("{}.DSTAT".format(comm.__name__))
exp_logger = logging.getLogger("{}.Experiment".format(__name__))
class Experiment(object):
"""Store and acquire a potentiostat experiment. Meant to be subclassed
to by different experiment types and not used instanced directly. Subclass
......@@ -214,8 +215,7 @@ class Experiment(object):
def run(self, ser, ctrl_pipe, data_pipe):
"""Execute experiment. Connects and sends handshake signal to DStat
then sends self.commands. Don't call directly as a process in Windows,
use run_wrapper instead.
then sends self.commands.
"""
self.serial = ser
self.ctrl_pipe = ctrl_pipe
......
......@@ -40,6 +40,7 @@ logger = logging.getLogger(__name__)
mod_dir = os.path.dirname(os.path.abspath(__file__))
class ExpInterface(GObject.Object):
"""Generic experiment interface class. Should be subclassed to implement
experiment interfaces by populating self.entry. Override class attributes
......@@ -67,7 +68,7 @@ class ExpInterface(GObject.Object):
@property
def params(self):
"""Dict of parameters"""
if self._params == None:
if self._params is None:
self._fill_params()
self._get_params()
return self._params
......@@ -79,7 +80,7 @@ class ExpInterface(GObject.Object):
@params.setter
def params(self, params):
if self._params == None:
if self._params is None:
self._fill_params()
for i in self._params:
try:
......@@ -99,7 +100,8 @@ class ExpInterface(GObject.Object):
self.emit('run_utility')
def on_done_utility(self, data=None):
self.emit('done_utility')
class Chronoamp(ExpInterface):
"""Experiment class for chronoamperometry. Extends ExpInterface class to
support treeview neeeded for CA.
......@@ -489,7 +491,7 @@ class CAL(ExpInterface):
GObject.timeout_add(700, restore_buttons, self.buttons)
def on_measure_button_clicked(self, data=None):
if (int(self.entry['time'].get_text()) <= 0 or int(self.entry['time'].get_text()) > 65535):
if int(self.entry['time'].get_text()) <= 0 or int(self.entry['time'].get_text()) > 65535:
logger.error("ERR: Time out of range")
return
......@@ -526,6 +528,7 @@ class CAL(ExpInterface):
GObject.timeout_add(700, restore_buttons, self.buttons)
__main__.MAIN.spinner.stop()
def restore_buttons(buttons):
""" Should be called with GObject callback """
for i in buttons:
......
......@@ -35,12 +35,13 @@ from pkg_resources import parse_version
from serial import SerialException
import zmq
from dstat_interface.core.utils.version import getVersion
from dstat_interface.core.experiments import idle, pot
from dstat_interface.core import params, analysis, dstat
from dstat_interface.core.dstat import boards
from dstat_interface.core.interface import (exp_window, adc_pot, plot_ui, data_view,
save, hw_info)
save, hw_info)
from dstat_interface.core.errors import InputError
from dstat_interface.core.plugin import DstatPlugin, get_hub_uri
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment