Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions blacs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@

# No splash update for Qt - the splash code has already imported it:
import qtutils
from qtutils import *
from qtutils import inmain_decorator, inmain_later, inmain, inthread, UiLoader
import qtutils.icons
from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import PYQT_VERSION_STR, QT_VERSION_STR, QTimer, Qt
from qtutils.qt.QtGui import QIcon
from qtutils.qt.QtWidgets import (
QMainWindow,
QToolButton,
QMessageBox,
QFileDialog,
QApplication
)
from qtutils.qt import QT_ENV


Expand Down Expand Up @@ -166,7 +172,7 @@ def on_click(self):
# Ensure they can't run the game twice at once:
self.setEnabled(False)
# Wait for the subprocess in a thread so that we know when it quits:
qtutils.inthread(self.run_measure_ball)
inthread(self.run_measure_ball)

def run_measure_ball(self):
try:
Expand Down
7 changes: 3 additions & 4 deletions blacs/analysis_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import sys
import queue

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt, QSize
from qtutils.qt.QtGui import QIcon

from qtutils import *
from qtutils import inmain_decorator, UiLoader
from zprocess import TimeoutError, raise_exception_in_thread
from zprocess.security import AuthenticationFailure
from labscript_utils.ls_zprocess import zmq_get
Expand Down
7 changes: 3 additions & 4 deletions blacs/compile_and_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
import os
import shutil

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt, QTimer
from qtutils.qt.QtWidgets import QDialog

from qtutils import *
from qtutils import inmain_decorator, UiLoader
import runmanager
from labscript_utils.qtwidgets.outputbox import OutputBox

Expand Down
20 changes: 14 additions & 6 deletions blacs/device_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
import time
from queue import Queue

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import QTimer
from qtutils.qt.QtGui import QIcon
from qtutils.qt.QtWidgets import (
QWidget,
QSpacerItem,
QSizePolicy,
QPushButton,
QHBoxLayout,
QApplication,
QVBoxLayout,
)

import labscript_utils.excepthook
from qtutils import UiLoader
Expand Down Expand Up @@ -339,15 +347,15 @@ def auto_place_widgets(self,*args):
for arg in args:
# A default sort algorithm that just returns the object (this is equivalent to not specifying the sort gorithm)
sort_algorithm = lambda x: x
if type(arg) == type(()) and len(arg) > 1 and type(arg[1]) == type({}) and len(arg[1].keys()) > 0:
if isinstance(arg, tuple) and len(arg) > 1 and isinstance(arg[1], dict) and len(arg[1].keys()) > 0:
# we have a name, use it!
name = arg[0]
widget_dict = arg[1]
if len(arg) > 2:
sort_algorithm = arg[2]
else:
# ignore things that are not dictionaries or empty dictionaries
if type(arg) != type({}) or len(arg.keys()) < 1:
if not isinstance(arg, dict) or len(arg.keys()) < 1:
continue
if isinstance(self.get_channel(list(arg.keys())[0]),AO):
name = 'Analog Outputs'
Expand Down Expand Up @@ -472,7 +480,7 @@ def check_remote_values(self):

# If no results were returned, raise an exception so that we don't keep calling this function over and over again,
# filling up the text box with the same error, eventually consuming all CPU/memory of the PC
if not self._last_remote_values or type(self._last_remote_values) != type({}):
if not self._last_remote_values or not isinstance(self._last_programmed_values, dict):
raise Exception('Failed to get remote values from device. Is it still connected?')

# A variable to indicate if any of the channels have a changed value
Expand Down
14 changes: 9 additions & 5 deletions blacs/experiment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
from tempfile import gettempdir
from binascii import hexlify

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt, QItemSelectionModel
from qtutils.qt.QtGui import QIcon, QAction, QStandardItemModel, QStandardItem
from qtutils.qt.QtWidgets import (
QTreeView,
QMenu,
QFileDialog,
)

import zprocess
from labscript_utils.ls_zprocess import ProcessTree
process_tree = ProcessTree.instance()
import labscript_utils.h5_lock, h5py

from qtutils import *
from qtutils import inmain_decorator, inmain

from labscript_utils.qtwidgets.elide_label import elide_label
from labscript_utils.connections import ConnectionTable
Expand Down Expand Up @@ -988,7 +992,7 @@ def restart_function(device_name):
message = self.process_request(path)
except Exception:
# TODO: make this error popup for the user
self._logger.exception('Failed to copy h5_file (%s) for repeat run'%s)
self._logger.exception('Failed to copy h5_file (%s) for repeat run' % path)
logger.info(message)

self.set_status("Idle")
Expand Down
10 changes: 4 additions & 6 deletions blacs/front_panel_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
import os
import logging

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtWidgets import QMessageBox

import labscript_utils.excepthook
import numpy
import labscript_utils.h5_lock, h5py
from qtutils import *
from qtutils import inmain_decorator

from labscript_utils.connections import ConnectionTable

Expand Down Expand Up @@ -137,7 +135,7 @@ def handle_return_code(self,row,result,settings,question,error):
# This is because we have the original channel, and the moved channel in the same place
#-1: Device no longer in the connection table, throw error
#-2: Device parameters not compatible, throw error
if type(result) == tuple:
if isinstance(result, tuple):
connection = result[1]
result = result[0]

Expand Down Expand Up @@ -285,7 +283,7 @@ def save_front_panel_to_h5(self,current_file,states,tab_positions,window_data,pl

if save_conn_table or result:
with h5py.File(current_file,'r+') as hdf5_file:
if hdf5_file['/'].get('front_panel') != None:
if hdf5_file['/'].get('front_panel') is not None:
# Create a dialog to ask whether we can overwrite!
overwrite = False
if not silent:
Expand Down
12 changes: 9 additions & 3 deletions blacs/output_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
import math
import sys

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt
from qtutils.qt.QtGui import QStandardItemModel, QStandardItem
from qtutils.qt.QtWidgets import (
QApplication,
QWidget,
QVBoxLayout,
QSpacerItem,
QSizePolicy,
)


from labscript_utils.qtwidgets.analogoutput import AnalogOutput
Expand Down
8 changes: 4 additions & 4 deletions blacs/plugins/connection_table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import sys
import ast

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt
from qtutils.qt.QtGui import QStandardItemModel, QStandardItem
from qtutils.qt.QtWidgets import QMessageBox, QFileDialog

from blacs.compile_and_restart import CompileAndRestart
from labscript_utils.filewatcher import FileWatcher
from qtutils import *
from qtutils import inmain, UiLoader
from blacs.plugins import PLUGINS_DIR

FILEPATH_COLUMN = 0
Expand Down
2 changes: 1 addition & 1 deletion blacs/plugins/theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging
import os

from qtutils import *
from qtutils import UiLoader

from blacs.plugins import PLUGINS_DIR

Expand Down
24 changes: 15 additions & 9 deletions blacs/tab_base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
from types import GeneratorType
from bisect import insort

from qtutils.qt.QtCore import *
from qtutils.qt.QtGui import *
from qtutils.qt.QtWidgets import *
from qtutils.qt.QtCore import Qt, QTimer
from qtutils.qt.QtGui import QIcon, QColor
from qtutils.qt.QtWidgets import QLabel, QWidget, QPushButton, QApplication, QVBoxLayout

from qtutils import *
from qtutils import inmain_decorator, inmain, inthread, UiLoader
from labscript_utils.qtwidgets.outputbox import OutputBox
import qtutils.icons

Expand Down Expand Up @@ -782,7 +782,7 @@ def mainloop(self):
# run the function in the Qt main thread
generator = inmain(func,self,*args,**kwargs)
# Do any work that was queued up:(we only talk to the worker if work has been queued up through the yield command)
if type(generator) == GeneratorType:
if isinstance(generator, GeneratorType):
# We need to call next recursively, queue up work and send the results back until we get a StopIteration exception
generator_running = True
# get the data from the first yield function
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def initUI(self):
# appearance settings). You should never be calling queue_work
# or do_after from un undecorated callback.
@define_state(MODE_MANUAL,True)
def foo(self):
def foo(self,button=None):
self.logger.debug('entered foo')
#self.toplevel.set_sensitive(False)
# Here's how you instruct the worker process to do
Expand All @@ -1113,7 +1113,7 @@ def fatal(self):
self.queue_work('My worker','foo', 5,6,7,x='x')

@define_state(MODE_MANUAL,True)
def bar(self):
def bar(self,button):
self.logger.debug('entered bar')
results = yield(self.queue_work('My worker','bar', 5,6,7,x=5))

Expand All @@ -1134,7 +1134,7 @@ def baz(self, button=None):
# This event shows what happens if you try to send a unpickleable
# event through a queue to the subprocess:
@define_state(MODE_MANUAL,True)
def baz_unpickleable(self):
def baz_unpickleable(self, button):
self.logger.debug('entered baz_unpickleable')
results = yield(self.queue_work('My worker','baz', 5,6,7,x=threading.Lock()))
self.logger.debug('leaving baz_unpickleable')
Expand Down Expand Up @@ -1167,7 +1167,10 @@ def init(self):
# the former.
global serial; import serial
self.logger.info('got x! %d' % self.x)
raise Exception('bad import!')
# randomly fail this on init, but only occasionally
import random
if random.random() < 0.15:
raise Exception('bad import!')

# Here's a function that will be called when requested by the parent
# process. There's nothing special about it really. Its return
Expand Down Expand Up @@ -1195,6 +1198,8 @@ def baz(self,zzz,*args,**kwargs):
import sys
import logging.handlers
# Setup logging:
from labscript_utils.setup_logging import setup_logging
setup_logging('BLACS')
logger = logging.getLogger('BLACS')
handler = logging.handlers.RotatingFileHandler(os.path.join(BLACS_DIR, 'BLACS.log'), maxBytes=1024**2, backupCount=0)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s: %(message)s')
Expand Down Expand Up @@ -1222,6 +1227,7 @@ def baz(self,zzz,*args,**kwargs):
class FakeConnection(object):
def __init__(self):
self.BLACS_connection = 'None'
self.properties = {}
class FakeConnectionTable(object):
def __init__(self):
pass
Expand Down