2424from types import GeneratorType
2525from bisect import insort
2626
27- from qtutils .qt .QtCore import *
28- from qtutils .qt .QtGui import *
29- from qtutils .qt .QtWidgets import *
27+ from qtutils .qt .QtCore import Qt , QTimer
28+ from qtutils .qt .QtGui import QIcon , QColor
29+ from qtutils .qt .QtWidgets import QLabel , QWidget , QPushButton , QApplication , QVBoxLayout
3030
31- from qtutils import *
31+ from qtutils import inmain_decorator , inmain , inthread , UiLoader
3232from labscript_utils .qtwidgets .outputbox import OutputBox
3333import qtutils .icons
3434
@@ -782,7 +782,7 @@ def mainloop(self):
782782 # run the function in the Qt main thread
783783 generator = inmain (func ,self ,* args ,** kwargs )
784784 # Do any work that was queued up:(we only talk to the worker if work has been queued up through the yield command)
785- if type (generator ) == GeneratorType :
785+ if isinstance (generator , GeneratorType ) :
786786 # We need to call next recursively, queue up work and send the results back until we get a StopIteration exception
787787 generator_running = True
788788 # get the data from the first yield function
@@ -1087,7 +1087,7 @@ def initUI(self):
10871087 # appearance settings). You should never be calling queue_work
10881088 # or do_after from un undecorated callback.
10891089 @define_state (MODE_MANUAL ,True )
1090- def foo (self ):
1090+ def foo (self , button = None ):
10911091 self .logger .debug ('entered foo' )
10921092 #self.toplevel.set_sensitive(False)
10931093 # Here's how you instruct the worker process to do
@@ -1113,7 +1113,7 @@ def fatal(self):
11131113 self .queue_work ('My worker' ,'foo' , 5 ,6 ,7 ,x = 'x' )
11141114
11151115 @define_state (MODE_MANUAL ,True )
1116- def bar (self ):
1116+ def bar (self , button ):
11171117 self .logger .debug ('entered bar' )
11181118 results = yield (self .queue_work ('My worker' ,'bar' , 5 ,6 ,7 ,x = 5 ))
11191119
@@ -1134,7 +1134,7 @@ def baz(self, button=None):
11341134 # This event shows what happens if you try to send a unpickleable
11351135 # event through a queue to the subprocess:
11361136 @define_state (MODE_MANUAL ,True )
1137- def baz_unpickleable (self ):
1137+ def baz_unpickleable (self , button ):
11381138 self .logger .debug ('entered baz_unpickleable' )
11391139 results = yield (self .queue_work ('My worker' ,'baz' , 5 ,6 ,7 ,x = threading .Lock ()))
11401140 self .logger .debug ('leaving baz_unpickleable' )
@@ -1167,7 +1167,10 @@ def init(self):
11671167 # the former.
11681168 global serial ; import serial
11691169 self .logger .info ('got x! %d' % self .x )
1170- raise Exception ('bad import!' )
1170+ # randomly fail this on init, but only occasionally
1171+ import random
1172+ if random .random () < 0.15 :
1173+ raise Exception ('bad import!' )
11711174
11721175 # Here's a function that will be called when requested by the parent
11731176 # process. There's nothing special about it really. Its return
@@ -1195,6 +1198,8 @@ def baz(self,zzz,*args,**kwargs):
11951198 import sys
11961199 import logging .handlers
11971200 # Setup logging:
1201+ from labscript_utils .setup_logging import setup_logging
1202+ setup_logging ('BLACS' )
11981203 logger = logging .getLogger ('BLACS' )
11991204 handler = logging .handlers .RotatingFileHandler (os .path .join (BLACS_DIR , 'BLACS.log' ), maxBytes = 1024 ** 2 , backupCount = 0 )
12001205 formatter = logging .Formatter ('%(asctime)s %(levelname)s %(name)s: %(message)s' )
@@ -1222,6 +1227,7 @@ def baz(self,zzz,*args,**kwargs):
12221227 class FakeConnection (object ):
12231228 def __init__ (self ):
12241229 self .BLACS_connection = 'None'
1230+ self .properties = {}
12251231 class FakeConnectionTable (object ):
12261232 def __init__ (self ):
12271233 pass
0 commit comments