示例#1
0
def test_hal_film_4(qtbot, mock):
    """
    Test filming without actually recording.
    """

    # 'Fix' question boxes to always return yes.
    #
    # https://github.com/pytest-dev/pytest-qt/issues/18
    #
    mock.patch.object(QtWidgets.QMessageBox,
                      'question',
                      return_value=QtWidgets.QMessageBox.Yes)

    hdebug.startLogging(test.logDirectory(), "hal4000")

    config = params.config(
        test.halXmlFilePathAndName("none_classic_config.xml"))
    hal = hal4000.HalCore(config=config)

    # Get UI elements we need.
    mainWindow = hal.findChild(QtWidgets.QMainWindow, "MainWindow")
    saveMovieCheckBox = hal.findChild(QtWidgets.QCheckBox, "saveMovieCheckBox")
    recordButton = hal.findChild(QtWidgets.QPushButton, "recordButton")

    # Start HAL.
    qtbot.addWidget(hal)
    qtbot.waitForWindowShown(mainWindow)
    qtbot.wait(100)

    # Uncheck save movie and press record.
    qtbot.mouseClick(saveMovieCheckBox, QtCore.Qt.LeftButton)
    qtbot.mouseClick(recordButton, QtCore.Qt.LeftButton)

    # Wait a second for the film to complete, then exit.
    qtbot.wait(1000)
示例#2
0
def test_hal_film_4(qtbot, mock):
    """
    Test filming without actually recording.
    """

    # 'Fix' question boxes to always return yes.
    #
    # https://github.com/pytest-dev/pytest-qt/issues/18
    #
    mock.patch.object(QtWidgets.QMessageBox, 'question', return_value = QtWidgets.QMessageBox.Yes)

    hdebug.startLogging(test.logDirectory(), "hal4000")
        
    config = params.config(test.halXmlFilePathAndName("none_classic_config.xml"))
    hal = hal4000.HalCore(config = config)

    # Get UI elements we need.
    mainWindow = hal.findChild(QtWidgets.QMainWindow, "MainWindow")
    saveMovieCheckBox = hal.findChild(QtWidgets.QCheckBox, "saveMovieCheckBox")
    recordButton = hal.findChild(QtWidgets.QPushButton, "recordButton")

    # Start HAL.
    qtbot.addWidget(hal)
    qtbot.waitForWindowShown(mainWindow)
    qtbot.wait(100)
    
    # Uncheck save movie and press record.
    qtbot.mouseClick(saveMovieCheckBox, QtCore.Qt.LeftButton)
    qtbot.mouseClick(recordButton, QtCore.Qt.LeftButton)

    # Wait a second for the film to complete, then exit.
    qtbot.wait(1000)
示例#3
0
def test_steve_starts(qtbot):

    parameters = params.parameters(test.steveXmlFilePathAndName("test_default.xml"))
    hdebug.startLogging(test.logDirectory(), "steve")
    mainw = steve.Window(parameters)
    mainw.show()

    qtbot.addWidget(mainw)

    # Run for about 0.5 seconds.
    qtbot.wait(500)
示例#4
0
def test_hal_error_2(qtbot):
    """
    Test handling of an error in a HAL worker.
    """
    hdebug.startLogging(test.logDirectory(), "hal4000")
        
    config = params.config(test.halXmlFilePathAndName("none_hal_error_2.xml"))
    hal = hal4000.HalCore(config = config, show_gui = False)

    qtbot.addWidget(hal)
    qtbot.wait(500)

    assert not hal.running
示例#5
0
def test_hal_error_2(qtbot):
    """
    Test handling of an error in a HAL worker.
    """
    hdebug.startLogging(test.logDirectory(), "hal4000")

    config = params.config(test.halXmlFilePathAndName("none_hal_error_2.xml"))
    hal = hal4000.HalCore(config=config, show_gui=False)

    qtbot.addWidget(hal)
    qtbot.wait(500)

    assert not hal.running
示例#6
0
def test_hal_sequencing_1(qtbot):
    """
    Test module.processMessage() sequencing.
    """
    hdebug.startLogging(test.logDirectory(), "hal4000")
        
    config = params.config(test.halXmlFilePathAndName("none_hal_sequencing_1.xml"))
    hal = hal4000.HalCore(config = config, show_gui = False)

    qtbot.addWidget(hal)
    qtbot.wait(2000)

    assert not hal.running
示例#7
0
def test_steve_hal(qtbot):
    hal = halSteveTest.HalSteveTest(config_xml="none_tcp_config.xml")
    hal.run()

    parameters = params.parameters(
        test.steveXmlFilePathAndName("test_default.xml"))
    hdebug.startLogging(test.logDirectory(), "steve")
    mainw = steve.Window(parameters)
    mainw.show()

    qtbot.addWidget(mainw)

    # Run for about 0.5 seconds.
    qtbot.wait(500)

    hal.stop()
def halTest(config_xml = "", class_name = "Testing", test_module = "", show_gui = False):

    app = QtWidgets.QApplication(sys.argv)
    
    config = params.config(test.halXmlFilePathAndName(config_xml))

    # Add the class that will actually do the testing.
    c_test = config.addSubSection("modules.testing")
    c_test.add("class_name", class_name)
    c_test.add("module_name", test_module)
    
    hdebug.startLogging(test.logDirectory(), "hal4000")
    
    hal = hal4000.HalCore(config = config,
                          testing_mode = True,
                          show_gui = show_gui)
    
    app.exec_()
示例#9
0
        if self.item_store.loadMosaic(mosaic_filename):
            for elt in self.modules:
                elt.mosaicLoaded()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

    # Load settings.
    if (len(sys.argv) == 2):
        parameters = params.parameters(sys.argv[1])
    else:
        parameters = params.parameters("settings_default.xml")

    # Start logger.
    hdebug.startLogging(parameters.get("directory") + "logs/", "steve")

    # Load app.
    window = Window(parameters=parameters)
    window.show()
    app.exec_()

#
# The MIT License
#
# Copyright (c) 2013 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
示例#10
0
    # @param boolean Dummy parameter.
    #
    @hdebug.debug
    def quit(self, boolean):
        self.close()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    if (len(sys.argv) == 2):
        parameters = params.parameters(sys.argv[1])
    else:
        parameters = params.parameters("settings_default.xml")

    # Start logger.
    hdebug.startLogging(
        parameters.get("directory") + "logs" + os.path.sep, "dave")

    # Load app.
    window = Dave(parameters)
    window.show()
    app.exec_()

#
# The MIT License
#
# Copyright (c) 2013 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
示例#11
0
    # This keeps Qt from closing everything if a message box is displayed
    # before HAL's main window is shown.
    app.setQuitOnLastWindowClosed(False)

    # Splash Screen.
    pixmap = QtGui.QPixmap("splash.png")
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.processEvents()

    # Load configuration.
    config = params.config(args.config)

    # Start logger.
    hdebug.startLogging(config.get("directory") + "logs/", "hal4000")

    # Setup HAL and all of the modules.
    hal = HalCore(config=config, parameters_file_name=args.default_xml)

    # Hide splash screen and start.
    splash.hide()

    app.exec_()

#
# The MIT License
#
# Copyright (c) 2017 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
示例#12
0
    @hdebug.debug
    def quit(self, boolean):
        self.close()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

    # Load settings.
    if (len(sys.argv)==2):
        parameters = params.parameters(sys.argv[1])
    else:
        parameters = params.parameters("settings_default.xml")

    # Start logger.
    hdebug.startLogging(parameters.get("directory") + "logs/", "steve")

    # Load app.
    window = Window(parameters)
    window.show()
    app.exec_()


#
# The MIT License
#
# Copyright (c) 2013 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
示例#13
0
    # This keeps Qt from closing everything if a message box is displayed
    # before HAL's main window is shown.
    app.setQuitOnLastWindowClosed(False)

    # Splash Screen.
    pixmap = QtGui.QPixmap("splash.png")
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.processEvents()

    # Load configuration.
    config = params.config(args.config)

    # Start logger.
    hdebug.startLogging(config.get("directory") + "logs/", "hal4000")
    
    # Setup HAL and all of the modules.
    hal = HalCore(config = config,
                  parameters_file_name = args.default_xml)

    # Hide splash screen and start.
    splash.hide()

    # Configure ctrl-c handling.
    signal.signal(signal.SIGINT, ctrlCHandler)
    
    app.exec_()


#
示例#14
0
        self.config_xml = config_xml
        self.error_msg = ""
        self.process = None
        self.thread = None

    def run(self):
        cmd_line = ["python", "hal/halSteveTest.py", self.config_xml]

        def target():
            try:
                self.process = subprocess.Popen(cmd_line)
            except:
                self.error_msg = traceback.format_exc()

        self.thread = threading.Thread(target=target)
        self.thread.start()
        time.sleep(1.0)

    def stop(self):
        self.process.terminate()
        print(self.error_msg)


if (__name__ == "__main__"):
    app = QtWidgets.QApplication(sys.argv)
    config = params.config(test.halXmlFilePathAndName(sys.argv[1]))
    hdebug.startLogging(test.logDirectory(), "hal4000")
    hal = hal4000.HalCore(config=config, show_gui=True)
    app.exec_()
    app = None
示例#15
0
    # @param boolean Dummy parameter.
    #
    @hdebug.debug
    def quit(self, boolean):
        self.close()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    if (len(sys.argv) == 2):
        parameters = params.parameters(sys.argv[1])
    else:
        parameters = params.parameters("settings_default.xml")
        
    # Start logger.
    hdebug.startLogging(parameters.get("directory") + "logs" + os.path.sep, "dave")

    # Load app.
    window = Dave(parameters)
    window.show()
    app.exec_()

#
# The MIT License
#
# Copyright (c) 2013 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell