def main(): args = parse_args() root_path = os.getcwd() if args.subcmd == 'init': if args.server: from server import server_init server_init(root_path) else: assert len(args.remote) == 1 client_init(root_path, args.remote[0]) elif args.subcmd == 'sync': logging.basicConfig(level=logging.DEBUG, filename=path.join(root_path, '.mf', 'debug.log')) try: wt = WorkingTree(root_path) remote = pipe_to_remote(wt._get_remote_url()) ui = ColorfulUi() session = SyncClient(wt, remote, ui) session.sync_with_remote(use_cache=args.use_cache) except: log.exception("Exception while performing sync") raise else: raise ValueError('bad param')
async def on_ready(): print(_('로그인 되었습니다.')) print(_('------')) print(bot.user.name) print(bot.user.id) print(_('------')) server_init(bot) serverlist.reload() if args.test == True: sys.exit() bot.loop.create_task(splash_rotate())
def main(): options = options_parse() from twisted.internet import reactor try: if options.client: # The Client code import client client.client_init(options, reactor) elif options.server: # The Server code from twisted.internet.error import CannotListenError import server server.server_init(options, reactor) reactor.run() except KeyboardInterrupt: print "Interrupted by Control-C. Exiting."
def __init__(self): super(gpvdm_main_window, self).__init__() icon_init_db() #from scans_io import scans_io #from cal_path import get_sim_path #scans=scans_io(get_sim_path()) #sims=scans.get_scan_dirs() #print(sims) #asdsa self.splash = splash_window() self.scan_human_labels = get_scan_human_labels() self.splash.inc_value() process_events() process_events() #from wiz import wiz #a=wiz() #a.exec_() #sys.exit() do_import() if os.path.isdir(os.path.dirname(sys.argv[0])) == False: error_dlg(self, _("I can't run from inside a zip file!")) sys.exit() self.splash.inc_value() self.splash.inc_value() server_init() self.splash.inc_value() self.check_sim_exists = check_sim_exists() self.splash.inc_value() self.check_sim_exists.start_thread() self.splash.inc_value() self.check_sim_exists.sim_gone.connect(self.sim_gone) self.splash.inc_value() self.my_server = server_get() self.my_server.init(get_sim_path()) self.splash.inc_value() self.undo_list = undo_list_class() wpos_load() self.splash.inc_value() self.ribbon = ribbon() self.splash.inc_value() self.notebook_active_page = None self.setAcceptDrops(True) #self.setGeometry(200, 100, 1300, 600) self.setWindowTitle( "General-purpose Photovoltaic Device Model (https://www.gpvdm.com)" ) self.l = lock_gui() #self.l.disable_all.connect(self.disable_interface) #self.l.enable_all.connect(self.enable_disable_buttons) #super(gpvdm_main_window, self).__init__(parent, QtCore.Qt.FramelessWindowHint) #gobject.GObject.__init__(self) #self.my_server.setup_gui(self.gui_sim_start) self.my_server.sim_started.connect(self.gui_sim_start) self.splash.inc_value() self.my_server.sim_finished.connect(self.gui_sim_stop) self.splash.inc_value() help_init() self.splash.inc_value() #help_window().help_set_help(["star.png",_("<big><b>Update available!</b></big><br>")]) #self.show() if running_on_linux() == True: self.bus = dbus.SessionBus() self.bus.add_match_string_non_blocking( "type='signal',interface='org.my.gpvdm'") self.bus.add_message_filter(self.adbus) else: self.win_pipe = win_pipe() self.win_pipe.new_data.connect(self.win_dbus) self.win_pipe.start() self.notebook = gpvdm_notebook() vbox = QVBoxLayout() self.splash.inc_value() vbox.addWidget(self.ribbon) self.ribbon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.notebook.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) vbox.addWidget(self.notebook) wvbox = QWidget() self.splash.inc_value() wvbox.setLayout(vbox) self.setCentralWidget(wvbox) self.splash.inc_value() self.statusBar() temp_error = ver_error() #print(temp_error) if len(temp_error) > 0: error_dlg(self, temp_error) return self.setWindowIcon( QIcon(os.path.join(get_image_file_path(), "image.jpg"))) self.splash.inc_value() self.show_tabs = True self.show_border = True self.ribbon.file.home_new.clicked.connect(self.callback_new) self.ribbon.file.home_open.clicked.connect(self.callback_open) self.ribbon.file.used_files_click.connect(self.load_sim) self.ribbon.home.undo.triggered.connect(self.callback_undo) self.ribbon.home.run.start_sim.connect(self.callback_simulate) self.splash.inc_value() #self.ribbon.home.stop.setEnabled(False) self.ribbon.home.scan.setEnabled(False) self.ribbon.thermal.setEnabled(False) self.ribbon.home.help.triggered.connect(self.callback_on_line_help) update_init() resize_window_to_be_sane(self, 0.7, 0.75) self.change_dir_and_refresh_interface(get_sim_path()) self.splash.inc_value() #self.ribbon.home.sun.changed.connect(self.notebook.update) self.ribbon.setAutoFillBackground(True) self.splash.inc_value() self.show() help_window().show() self.enable_disable_buttons() val = inp_get_token_value(os.path.join(get_sim_path(), "config.inp"), "#use_gpvdm_local") if val != "false": if os.path.isdir(get_materials_path()) == False: clone_materials(get_materials_path(), get_base_material_path(), "material") if os.path.isdir(get_emission_path()) == False: clone_materials(get_emission_path(), get_base_emission_path(), "emission") if os.path.isdir(get_shape_path()) == False: clone_materials(get_shape_path(), get_base_shape_path(), "shape") if os.path.isdir(get_scripts_path()) == False: shutil.copytree(get_base_scripts_path(), get_scripts_path(), symlinks=True) if os.path.isdir(get_spectra_path()) == False: clone_spectras(get_spectra_path()) self.cache = cache(only_open_if_full=True) #from shape_editor import shape_editor #self.shape_window=shape_editor("/home/rod/gpvdm_local/shape/pedot") #self.shape_window.show() #from shape_import import shape_import #self.shape_import=shape_import("/home/rod/gpvdm_local/shape/pedot") #self.shape_import.show() check_lib_in_bash_rc()
from socket import * from threading import * import server import client print("(C)onnect\n(W)ait\n(Q)uit") choice = input("Please choose the role you want to play: ") while True: if choice == 'Q' or choice == 'q': exit() elif choice == 'W' or choice == 'w': server.server_init() contFlag = input("Are you sure to quit? (y/n): ") while contFlag == 'n' or contFlag == 'N': server.server_init() contFlag = input("Are you sure to quit? (y/n): ") break elif choice == 'C' or choice == 'c': client.client_init() contFlag = input("Are you sure to quit? (y/n): ") while contFlag == 'n' or contFlag == 'N': client.client_init() contFlag = input("Are you sure to quit? (y/n): ") break print("\n(C)onnect\n(W)ait\n(Q)uit") choice = input("Please input a valid choice again: ")
def __init__(self): self.undo_list=undo_list_class() super(gpvdm_main_window,self).__init__() self.setGeometry(200, 100, 1300, 600) self.setWindowTitle(_("General-purpose Photovoltaic Device Model (www.gpvdm.com)")) #super(gpvdm_main_window, self).__init__(parent, QtCore.Qt.FramelessWindowHint) #gobject.GObject.__init__(self) server_init() self.my_server=server_get() self.my_server.init(os.getcwd()) self.my_server.setup_gui(self.gui_sim_start) self.my_server.sim_finished.connect(self.gui_sim_stop) help_init() #help_window().help_set_help(["star.png",_("<big><b>Update available!</b></big><br>")]) self.win_list=windows() self.win_list.load() #self.show() if running_on_linux()==True: DBusQtMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.bus.add_match_string_non_blocking("type='signal',interface='org.my.gpvdm'") self.bus.add_message_filter(self.adbus) else: self.win_pipe=win_pipe() self.win_pipe.new_data.connect(self.win_dbus) self.win_pipe.start() self.notebook=gpvdm_notebook() self.setCentralWidget(self.notebook) self.show() self.statusBar() toolbar = self.addToolBar('Exit') toolbar.setIconSize(QSize(42, 42)) self.splash=splash_window() self.splash.init() temp_error=ver_error() print(temp_error) if len(temp_error)>0: msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Critical) msgBox.setText(self.tr("gpvdm")) msgBox.setInformativeText(temp_error) msgBox.setStandardButtons(QMessageBox.Ok ) msgBox.setDefaultButton(QMessageBox.Ok) reply = msgBox.exec_() return self.experiment_window=None self.fxexperiment_window=None self.jvexperiment_window=None self.fit_window=None self.config_window=None self.qe_window=None self.lasers_window=None self.sim_info_window=None self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"image.jpg"))) self.show_tabs = True self.show_border = True menubar = self.menuBar() file_menu = menubar.addMenu('&File') self.menu_new=file_menu.addAction(_("&New simulation")) self.menu_new.triggered.connect(self.callback_new) self.menu_new_optical_material=file_menu.addAction(_("New optical material")) self.menu_export_open=file_menu.addAction(_("&Open simulation")) self.menu_export_open.triggered.connect(self.callback_open) self.menu_export_data=file_menu.addAction(_("&Export data")) self.menu_export_data.triggered.connect(self.callback_export) self.menu_import_data=file_menu.addAction(_("&Import data")) self.menu_import_data.triggered.connect(self.callback_import) self.menu_import_lib=file_menu.addAction(_("Import from library")) self.menu_import_lib.triggered.connect(self.callback_import_from_lib) self.menu_quit=file_menu.addAction(_("&Quit")) self.menu_quit.triggered.connect(self.close_now) simulation_menu = menubar.addMenu('&Simulation') self.menu_run=simulation_menu.addAction(_("&Run")) self.menu_run.triggered.connect(self.callback_simulate) self.menu_stop=simulation_menu.addAction(_("&Stop")) self.menu_stop.triggered.connect(self.callback_simulate_stop) self.menu_scan=simulation_menu.addAction(_("&Parameter scan")) self.menu_scan.triggered.connect(self.callback_scan) self.menu_configure=simulation_menu.addAction(_("&Configure")) self.menu_configure.triggered.connect(self.callback_config_window) view_menu = menubar.addMenu('&View') view_menu.addAction(_("&None")) plot_menu = menubar.addMenu('&Plot') self.plot_menu_plot=plot_menu.addAction(_("&Plot simulation result")) self.plot_menu_plot.triggered.connect(self.callback_plot_select) help_menu = menubar.addMenu('Help') help_web=help_menu.addAction(_("&Help window")) help_web.triggered.connect(self.callback_help) help_web=help_menu.addAction(_("&Online help")) help_web.triggered.connect(self.callback_on_line_help) help_web=help_menu.addAction(_("&License")) help_web.triggered.connect(self.callback_license) about=help_menu.addAction(_("&About")) about.triggered.connect(self.callback_about_dialog) if enable_webupdates()==False: self.help_menu_update=help_menu.addAction(_("&Check for updates")) self.help_menu_update.triggered.connect(self.callback_update) new_sim = QAction(QIcon(os.path.join(get_image_file_path(),"new.png")), _("Make a new simulation"), self) new_sim.triggered.connect(self.callback_new) toolbar.addAction(new_sim) open_sim = QAction(QIcon(os.path.join(get_image_file_path(),"open.png")), _("Open a simulation"), self) open_sim.triggered.connect(self.callback_open) toolbar.addAction(open_sim) toolbar.addSeparator() self.undo = QAction(QIcon(os.path.join(get_image_file_path(),"undo.png")), _("Undo"), self) self.undo.triggered.connect(self.callback_undo) toolbar.addAction(self.undo) #seperator self.run = QAction(QIcon(os.path.join(get_image_file_path(),"play.png")), _("Run the simulation"), self) self.run.triggered.connect(self.callback_simulate) toolbar.addAction(self.run) self.tb_run_scan = QAction(QIcon(os.path.join(get_image_file_path(),"forward.png")), _("Run parameter scan"), self) self.tb_run_scan.triggered.connect(self.callback_run_scan) self.tb_run_scan.setEnabled(False) toolbar.addAction(self.tb_run_scan) self.stop = QAction(QIcon(os.path.join(get_image_file_path(),"pause.png")), _("Stop the simulation"), self) self.stop.triggered.connect(self.callback_simulate_stop) toolbar.addAction(self.stop) self.stop.setEnabled(False) toolbar.addSeparator() self.param_scan = QAction(QIcon(os.path.join(get_image_file_path(),"scan.png")), _("Parameter scan"), self) self.param_scan.triggered.connect(self.callback_scan) toolbar.addAction(self.param_scan) self.param_scan.setEnabled(False) if enable_betafeatures()==True: self.tb_run_fit = QAction(QIcon(os.path.join(get_image_file_path(),"fit.png")), _("Run a fit command"), self) self.tb_run_fit.triggered.connect(self.callback_run_fit) toolbar.addAction(self.tb_run_fit) self.tb_run_fit.setEnabled(True) toolbar.addSeparator() self.plot_select = QAction(QIcon(os.path.join(get_image_file_path(),"plot.png")), _("Find a file to plot"), self) self.plot_select.triggered.connect(self.callback_plot_select) toolbar.addAction(self.plot_select) self.examine = QAction(QIcon(os.path.join(get_image_file_path(),"plot_time.png")), _("Examine results in time domain"), self) self.examine.triggered.connect(self.callback_examine) toolbar.addAction(self.examine) toolbar.addSeparator() self.tb_time_domain = QAction(QIcon(os.path.join(get_image_file_path(),"time.png")), _("Time domain simulation editor."), self) self.tb_time_domain.triggered.connect(self.callback_edit_experiment_window) toolbar.addAction(self.tb_time_domain) self.experiment_window_button = QAction(QIcon(os.path.join(get_image_file_path(),"spectrum.png")), _("Frequency domain simulation editor"), self) self.experiment_window_button.triggered.connect(self.callback_fxexperiment_window) toolbar.addAction(self.experiment_window_button) self.jv_button = QAction(QIcon(os.path.join(get_image_file_path(),"jv.png")), _("Steady state simulation editor"), self) self.jv_button.triggered.connect(self.callback_jv_window) toolbar.addAction(self.jv_button) self.laser_button = QAction(QIcon(os.path.join(get_image_file_path(),"lasers.png")), _("Lasers editor"), self) self.laser_button.triggered.connect(self.callback_configure_lasers) toolbar.addAction(self.laser_button) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(spacer) self.help = QAction(QIcon(os.path.join(get_image_file_path(),"help.png")), _("Help"), self) self.help.triggered.connect(self.callback_on_line_help) toolbar.addAction(self.help) self.addToolBarBreak() toolbar1=self.make_tool_box1() self.addToolBar(toolbar1) if enable_betafeatures()==True: self.hpc_toolbar=hpc_class(self.my_server) #self.addToolBarBreak() toolbar_hpc = self.addToolBar(self.hpc_toolbar) self.win_list.set_window(self,"main_window") # self.menubar.show() # self.make_window2(main_vbox) #help_window().show() self.change_dir_and_refresh_interface(os.getcwd()) # self.window.show() # process_events() self.show() self.light_button.changed.connect(self.notebook.update)
def __init__(self): super(gpvdm_main_window, self).__init__() self.splash = splash_window() self.splash.inc_value() process_events() process_events() #from wiz import wiz #a=wiz() #a.exec_() #sys.exit() do_import() if os.path.isdir(os.path.dirname(sys.argv[0])) == False: error_dlg(self, _("I can't run from inside a zip file!")) sys.exit() self.splash.inc_value() self.splash.inc_value() server_init() self.splash.inc_value() self.check_sim_exists = check_sim_exists() self.splash.inc_value() self.check_sim_exists.start_thread() self.splash.inc_value() self.check_sim_exists.sim_gone.connect(self.sim_gone) self.splash.inc_value() self.my_server = server_get() self.my_server.init(get_sim_path()) self.splash.inc_value() self.undo_list = undo_list_class() wpos_load() self.splash.inc_value() self.ribbon = ribbon() self.splash.inc_value() self.notebook_active_page = None self.setAcceptDrops(True) #self.setGeometry(200, 100, 1300, 600) self.setWindowTitle( "General-purpose Photovoltaic Device Model (https://www.gpvdm.com)" ) #super(gpvdm_main_window, self).__init__(parent, QtCore.Qt.FramelessWindowHint) #gobject.GObject.__init__(self) self.my_server.setup_gui(self.gui_sim_start) self.splash.inc_value() self.my_server.sim_finished.connect(self.gui_sim_stop) self.splash.inc_value() help_init() self.splash.inc_value() #help_window().help_set_help(["star.png",_("<big><b>Update available!</b></big><br>")]) #self.show() if running_on_linux() == True: DBusQtMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.bus.add_match_string_non_blocking( "type='signal',interface='org.my.gpvdm'") self.bus.add_message_filter(self.adbus) else: self.win_pipe = win_pipe() self.win_pipe.new_data.connect(self.win_dbus) self.win_pipe.start() self.notebook = gpvdm_notebook() vbox = QVBoxLayout() self.splash.inc_value() vbox.addWidget(self.ribbon) vbox.addWidget(self.notebook) wvbox = QWidget() self.splash.inc_value() wvbox.setLayout(vbox) self.setCentralWidget(wvbox) self.splash.inc_value() self.statusBar() temp_error = ver_error() #print(temp_error) if len(temp_error) > 0: error_dlg(self, temp_error) return self.setWindowIcon( QIcon(os.path.join(get_image_file_path(), "image.jpg"))) self.splash.inc_value() self.show_tabs = True self.show_border = True self.ribbon.home_export.triggered.connect(self.callback_export) #if enable_webupdates()==False: # self.help_menu_update=help_menu.addAction("&"+_("Check for updates")) # self.help_menu_update.triggered.connect(self.callback_update) self.ribbon.home_new.triggered.connect(self.callback_new) self.ribbon.home_open.triggered.connect(self.callback_open) self.ribbon.home.undo.triggered.connect(self.callback_undo) self.ribbon.home.run.triggered.connect(self.callback_simulate) self.splash.inc_value() self.ribbon.home.stop.setEnabled(False) self.ribbon.home.scan.setEnabled(False) self.ribbon.home.help.triggered.connect(self.callback_on_line_help) resize_window_to_be_sane(self, 0.7, 0.75) self.change_dir_and_refresh_interface(get_sim_path()) self.splash.inc_value() self.ribbon.home.sun.changed.connect(self.notebook.update) self.ribbon.setAutoFillBackground(True) self.splash.inc_value() self.show() help_window().show() from update import update_window self.a = update_window() self.a.show()
trigger_alarm("sensor on %s:%s" % addr) def disconnect(addr): trigger_alarm("disconnect from %s:%s" % addr) def submit(pin): print("Entered pin: " + pin) if pin == "1234": toggle_alarm("pin code") else: trigger_alarm("incorrect pin") server.server_init(8080, message, disconnect) keypad.register(submit) GPIO.setup(alarm_light, GPIO.OUT) GPIO.output(alarm_light, 0) try: while True: uid = rfid.scan() if uid is not None: print("Card read UID: %s,%s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3], uid[4])) if uid == [112, 189, 195, 87, 89]: toggle_alarm("rfid tag") else: trigger_alarm("incorrect tag") server.event_loop()
from aiohttp import web from server import init as server_init import logging app = web.Application() server_init(app) logging.info("Сервер запущен") web.run_app(app) logging.error("Сервер остановлен")