def __init__(self, app=None, scene_id="default", spinviewer_fps=30): global log self.app = app self.user_id = self.app.config.user_id self.scene_id = scene_id self.has_ever_started_viewer = False self.spinviewer_fps = spinviewer_fps unique_master_id = "spinic" log_dir = master.DEFAULT_LOG_DIR log_level = 'warning' if self.app.config.verbose: log_level = 'info' if self.app.config.debug: log_level = 'debug' master.start_logging(log_level=log_level) log = logger.start(name="launching") pid_file = master.write_master_pid_file(identifier=unique_master_id, directory=log_dir) # might raise a RuntimeError: self.lunch_master = master.Master(log_dir=log_dir, pid_file=pid_file, verbose=True) self.lunch_gui = gui.start_gui(self.lunch_master) self._start()
#sys.exit(1) except Exception, e: error_message = "There is an error in your lunch file !\n" error_message += traceback.format_exc() if error_message is not None: print(error_message) if GUI_ENABLED: from lunch import dialogs def _cb(result): # stops reactor when the error dialog is closed reactor.stop() d = defer.Deferred() d.addCallback(_cb) error_dialog = dialogs.ErrorDialog(d, error_message) print("Running reactor to show error dialog.") reactor.run() # need it for the GTK error dialog print("Reactor stopped. Exiting.") sys.exit(1) if GUI_ENABLED: from lunch import gui app = gui.start_gui(lunch_master) #print("Done starting the app.") try: reactor.run() except KeyboardInterrupt: #log.msg("Ctrl-C in Master.", logging.INFO) #lunch_master.quit_master() reactor.stop()
This example demonstrate how to use lunch master as a library. """ from twisted.internet import gtk2reactor gtk2reactor.install() # has to be done before importing reactor from twisted.internet import reactor from twisted.internet import task from lunch import commands from lunch import master from lunch import gui if __name__ == "__main__": unique_master_id = "example" log_dir = master.DEFAULT_LOG_DIR pid_file = master.write_master_pid_file(identifier=unique_master_id, directory=log_dir) # XXX add_command here m = master.Master(log_dir=log_dir, pid_file=pid_file) m.add_command(commands.Command("xeyes", identifier="xeyes")) m.add_command(commands.Command("xlogo", identifier="xlogo")) m.add_command(commands.Command("xcalc", identifier="xcalc")) def _test(): print("Adding one more!") m.add_command(commands.Command("xeyes")) looping_call = task.LoopingCall(_test) looping_call.start(1.0, False) gui.start_gui(m) reactor.run()
except Exception, e: error_message = "There is an error in your lunch file !\n" error_message += traceback.format_exc() if error_message is not None: print(error_message) if GUI_ENABLED: from lunch import dialogs def _cb(result): # stops reactor when the error dialog is closed reactor.stop() d = defer.Deferred() d.addCallback(_cb) error_dialog = dialogs.ErrorDialog(d, error_message) print("Running reactor to show error dialog.") reactor.run() # need it for the GTK error dialog print("Reactor stopped. Exiting.") sys.exit(1) if GUI_ENABLED: from lunch import gui app = gui.start_gui(lunch_master) # print("Done starting the app.") try: reactor.run() except KeyboardInterrupt: # log.msg("Ctrl-C in Master.", logging.INFO) # lunch_master.quit_master() reactor.stop()
counter += 1 has_them = True def _test(): global has_them global counter if not has_them: print("Adding them again!") m.add_command(commands.Command("xeyes", identifier="xeyes")) m.add_command(commands.Command("xlogo", identifier="xlogo")) m.add_command(commands.Command("xcalc", identifier="xcalc")) m.add_command( commands.Command("xterm -hold -e /bin/bash -c \"echo %d\"" % (counter), identifier="xterm")) counter += 1 has_them = True else: print("Removing them.") m.remove_command("xeyes") m.remove_command("xlogo") m.remove_command("xcalc") m.remove_command("xterm") has_them = False # a GUI! app = gui.start_gui(m) looping_call = task.LoopingCall(_test) looping_call.start(3.0, False) reactor.run()
#!/usr/bin/env python """ This example demonstrate how to use lunch master as a library. """ from twisted.internet import gtk2reactor gtk2reactor.install() # has to be done before importing reactor from twisted.internet import reactor from twisted.internet import task from lunch import commands from lunch import master from lunch import gui if __name__ == "__main__": unique_master_id = "example" log_dir = master.DEFAULT_LOG_DIR pid_file = master.write_master_pid_file(identifier=unique_master_id, directory=log_dir) # XXX add_command here m = master.Master(log_dir=log_dir, pid_file=pid_file) m.add_command(commands.Command("xeyes", identifier="xeyes")) m.add_command(commands.Command("xlogo", identifier="xlogo")) m.add_command(commands.Command("xcalc", identifier="xcalc")) def _test(): print("Adding one more!") m.add_command(commands.Command("xeyes")) looping_call = task.LoopingCall(_test) looping_call.start(1.0, False) gui.start_gui(m) reactor.run()
m.add_command(commands.Command("xcalc", identifier="xcalc")) m.add_command(commands.Command("xterm -hold -e /bin/bash -c \"echo %d\"" % (counter), identifier="xterm")) counter += 1 has_them = True def _test(): global has_them global counter if not has_them: print("Adding them again!") m.add_command(commands.Command("xeyes", identifier="xeyes")) m.add_command(commands.Command("xlogo", identifier="xlogo")) m.add_command(commands.Command("xcalc", identifier="xcalc")) m.add_command(commands.Command("xterm -hold -e /bin/bash -c \"echo %d\"" % (counter), identifier="xterm")) counter += 1 has_them = True else: print("Removing them.") m.remove_command("xeyes") m.remove_command("xlogo") m.remove_command("xcalc") m.remove_command("xterm") has_them = False # a GUI! app = gui.start_gui(m) looping_call = task.LoopingCall(_test) looping_call.start(3.0, False) reactor.run()