def __init__(self, args): qt.QtGui.QApplication.__init__(self, args) # -- redirect stdout to null if pythonw -- set_stdout() # -- reconfigure LoggerOffice to use Qt log handler and a file handler -- logger.default_init(level=logger.DEBUG, handlers=["qt"]) #TODO get level from settings logger.connect_loggers_to_handlers(logger.get_logger_names(), logger.get_handler_names()) if __debug__: logger.set_global_logger_level(logger.DEBUG) else: logger.set_global_logger_level(logger.DEBUG) # -- show the splash screen -- self.splash = show_splash_screen() # -- main window -- self.win = MainWindow(None) self.win.setEnabled(False) self.win.show() self.win.raise_() self.sessionStarted.connect(self.win.on_session_started) # -- start session in a thread -- if MULTITHREAD: self.sessionth = threadit(timeit, self, self.__cb_session_thread_end, Session) else: session = Session() self.splash.finish(self.win) self.win.setEnabled(True) self.sessionStarted.emit(session)
def test_save_workspace(): pm = PackageManager() pm.init() asession = Session() import sys sgfactory = CompositeNodeFactory( name="SubGraphExample", description="Examples", category="Examples", ) sg = CompositeNode() # build the subgraph factory addid = sg.add_node(pm.get_node("pkg_test", "float")) sg.to_factory(sgfactory) instance = sgfactory.instantiate() instance.actor(addid).set_input(0, 3) asession.add_workspace(instance) asession.save('test.pic') asession.workspaces = [] asession.load('test.pic') try: os.remove('test.pic') except: os.remove('test.pic.db') i = asession.workspaces[0] assert type(i) == type(instance)
def test_save_datapool(): asession = Session() datapool = asession.datapool datapool['i'] = [1, 2, 3] add_user_class(datapool) asession.save('test.pic') asession.datapool.clear() asession.load('test.pic') assert asession.datapool['i'] == [1, 2, 3] try: os.remove('test.pic') except: os.remove('test.pic.db')
def build_raw_instance(self): from openalea.core.session import Session self.__session = Session() return self.__session