Python main.main() Examples
The following are 22
code examples of main.main().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
main
, or try the search function
.
Example #1
Source File: convert_tool.py From Resource-Pack-Converter with MIT License | 6 votes |
def selectPack(): global pack pack = filedialog.askopenfilename(initialdir = "./",title = "Select Pack",filetypes = (("resource pack","*.zip"),("all files","*.*"))) if(pack): root.withdraw() convert = main(pack[:-4]) if(convert == -1): print ("this pack is already compatible with 1.13") root.deiconify() center_window(root, 270, 120) messagebox.showwarning(title='warning', message="This pack is already compatible with 1.13, please select other!") elif(convert == 0): print ("please set it manually") res_win.deiconify() center_window(res_win, 270, 80) messagebox.showwarning(title='warning', message="Fail to detect the pack's resolution, please set it manually!") else: print ("next one?") root.deiconify() center_window(root, 270, 120) messagebox.showinfo(title='success', message='Conversion is Done!') return False else: print ('select pack to start conversion')
Example #2
Source File: pipark_setup.py From PiPark with GNU General Public License v2.0 | 5 votes |
def rightClickHandler(self, event): """Handle RMB-click events to add/remove control points & spaces. """ # ensure focus is set to the display canvas self.display.focus_set() # perform correct operation, dependent on which toggle button is active if self.cps_button.getIsActive(): if self.__is_verbose: print "INFO: Remove Control Point" self.__is_saved = False self.__control_points.boxes[self.__control_points.getCurrentBox()].clear() self.__control_points.boxes[self.__control_points.getCurrentBox()].deleteRectangle(self.display) elif self.spaces_button.getIsActive(): if self.__is_verbose: print "INFO: Remove parking space" self.__is_saved = False self.__parking_spaces.boxes[self.__parking_spaces.getCurrentBox()].clear() self.__parking_spaces.boxes[self.__parking_spaces.getCurrentBox()].deleteRectangle(self.display) else: if self.__is_verbose: print "INFO: Just clicking RMB merrily =)" # return focus to the main frame for key-press events self.focus_set() # ============================================================================== # # Button Handlers # # ==============================================================================
Example #3
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def run_main(): "This main procedure is started by calling either wxglade.py or wxglade.pyw on windows." # check command line parameters first options = parse_command_line() # initialise wxGlade (first stage and second stage) init_stage1(options) init_stage2(options.start_gui) if options.start_gui: # late import of main (imported wx) for using wxversion in init_stage2() import main main.main(options.filename) else: command_line_code_generation( filename=options.filename, language=options.language, out_path=options.output )
Example #4
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def init_stage2(use_gui): """Initialise the remaining (non-path) parts of wxGlade (second stage) use_gui: Starting wxGlade GUI""" config.use_gui = use_gui if use_gui: # import proper wx-module using wxversion, which is only available in Classic if compat.IS_CLASSIC: if not hasattr(sys, "frozen") and 'wx' not in sys.modules: try: import wxversion wxversion.ensureMinimal('2.8') except ImportError: msg = _('Please install missing Python module "wxversion".') logging.error(msg) sys.exit(msg) try: import wx except ImportError: msg = _('Please install missing Python module "wxPython".') logging.error(msg) sys.exit(msg) # store current version and platform ('not_set' is default) config.platform = wx.Platform config.wx_version = wx.__version__ if sys.platform=="win32": # register ".wxg" extension try: import msw msw.register_extensions(["wxg"], "wxGlade") except ImportError: pass # codewrites, widgets and sizers are loaded in class main.wxGladeFrame else: # use_gui has to be set before importing config common.init_preferences() common.init_codegen()
Example #5
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def command_line_code_generation(filename, language, out_path=None): """Starts a code generator without starting the GUI. filename: Name of wxg file to generate code from language: Code generator language out_path: output file / output directory""" import application, tree # Instead of instantiating a main.wxGlade() object, that is # derived from wx.App, we must do the equivalent work. The # following lines are taken from main.wxGlade().OnInit() and # main.wxGladeFrame.__init__() common.init_preferences() common.root = app = application.Application() # Now we can load the file if filename is not None: b = _guiless_open_app(filename) if not b: sys.exit(1) try: if language not in common.code_writers: raise ValueError('Code writer for "%s" is not available.'%language) common.root.properties["language"].set(language) common.root.generate_code(out_path=out_path) #except errors.WxgBaseException as inst: #if config.debugging: raise #logging.error(inst) #sys.exit(inst) except Exception: if config.debugging: raise logging.error( _("An exception occurred while generating the code for the application.\n" "If you think this is a wxGlade bug, please report it.") ) logging.exception(_('Internal Error')) sys.exit(1) if not config.testing: sys.exit(0)
Example #6
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_reports_stream_is_user_configurable(mock_env_log_stream, vm_uri, event_id): log_entry = main.StructuredLog(vm_uri=vm_uri, event_id=event_id) expected = 'organizations/000000000000/logs/dns-vm-gc-report' assert expected == log_entry.log_name
Example #7
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_multiple_calls(app_cold, mock_http, mock_session, trigger_event_done): assert main.RuntimeState.app is None main.main(trigger_event_done, context=None, http=mock_http, session=mock_session) assert main.RuntimeState.app is not None app_memo = main.RuntimeState.app main.main(trigger_event_done, context=None, http=mock_http, session=mock_session) assert main.RuntimeState.app is app_memo main.main(trigger_event_done, context=None, http=mock_http, session=mock_session) assert main.RuntimeState.app is app_memo
Example #8
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_when_cold(app_cold, mock_http, mock_session, trigger_event_done): assert main.RuntimeState.app is None main.main(trigger_event_done, context=None, http=mock_http, session=mock_session) assert main.RuntimeState.app is not None
Example #9
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_when_warm(app_warm, mock_http, mock_session, trigger_event_done): assert main.RuntimeState.app is app_warm main.main(trigger_event_done, context=None, http=mock_http, session=mock_session) assert main.RuntimeState.app is app_warm
Example #10
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_debug_env_log_level(mock_env_debug, mock_http): """Log level is DEBUG when DEBUG=1""" app = main.DnsVmGcApp(mock_http) assert app.log.level == logging.DEBUG
Example #11
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def test_config_no_zones(mock_env_no_zones, app, trigger_event): with pytest.raises(EnvironmentError) as err: main.EventHandler(app=app, data=trigger_event) assert "Env var DNS_VM_GC_DNS_ZONES is required" in str(err.value)
Example #12
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def handler(app, trigger_event): return main.EventHandler(app=app, data=trigger_event)
Example #13
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def app_cold(monkeypatch, mock_env, mock_session, mock_http): """When the function executes from a cold start""" monkeypatch.setattr(main.RuntimeState, 'app', None) return None
Example #14
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def app_warm(app, monkeypatch): """When the function is warmed up from previous events""" monkeypatch.setattr(main.RuntimeState, 'app', app) return app
Example #15
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def app_debug(mock_env_debug, mock_http, mock_session): return main.DnsVmGcApp(http=mock_http, session=mock_session)
Example #16
Source File: main_test.py From professional-services with Apache License 2.0 | 5 votes |
def app(mock_env, mock_http, mock_session): return main.DnsVmGcApp(http=mock_http, session=mock_session)
Example #17
Source File: index.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def _reboot_control(self): p_bPartial = True if len(self.m_lSubMenus) == 1: p_bPartial = False # add submenu reboot control to the list try: p_bCheck = False p_lCtrl = self.m_lSubMenus[-1].m_lReboot for item in self.m_lReboot: if p_lCtrl[0] == item[0]: item[1] = p_lCtrl[1] p_bCheck = True # add to the list if not exist if not p_bCheck: self.m_lReboot.append(self.m_lSubMenus[-1].m_lReboot) except: pass # show sys reboot icon if needed in current submenu # if any submenu requires sys reboot, icon will appear on main page p_bCheck = False if p_bPartial: try: name = self.m_lSubMenus[-1].m_lReboot[0] for item in self.m_lReboot: if item[0] == name: if item[1] == True: p_bCheck = True except: p_bCheck = False else: for item in self.m_lReboot: if item[1] == True: p_bCheck = True self.m_bReboot = p_bCheck
Example #18
Source File: index.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def _restart_control(self): p_bPartial = True if len(self.m_lSubMenus) == 1: p_bPartial = False # add submenu restart control to the list try: p_bCheck = False p_lCtrl = self.m_lSubMenus[-1].m_lRestart for item in self.m_lRestart: if p_lCtrl[0] == item[0]: item[1] = p_lCtrl[1] p_bCheck = True # add to the list if not exist if not p_bCheck: self.m_lRestart.append(self.m_lSubMenus[-1].m_lRestart) except: pass # show es restart icon if needed in current submenu # if any submenu requires es restart, icon will appear on main page p_bCheck = False if p_bPartial: try: name = self.m_lSubMenus[-1].m_lRestart[0] for item in self.m_lRestart: if item[0] == name: if item[1] == True: p_bCheck = True except: p_bCheck = False else: for item in self.m_lRestart: if item[1] == True: p_bCheck = True self.m_bRestart = p_bCheck
Example #19
Source File: index.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def __init__(self): self._load_sub_menus(main())
Example #20
Source File: pipark_setup.py From PiPark with GNU General Public License v2.0 | 5 votes |
def leftClickHandler(self, event): """Handle LMB-click events to add/remove control points & spaces. """ # ensure focus on display canvas to recieve mouse clicks self.display.focus_set() # perform correct operation, dependent on which toggle button is active # add new control points (max = 3) if self.cps_button.getIsActive(): if self.__is_verbose: print "INFO: Add Control Point" self.__is_saved = False this_cp_id = self.__control_points.getCurrentBox() this_cp = self.__control_points.boxes[this_cp_id] this_cp.updatePoints(event.x, event.y) # add new parking space elif self.spaces_button.getIsActive(): if self.__is_verbose: print "INFO: Add Parking Space" self.__is_saved = False this_space_id = self.__parking_spaces.getCurrentBox() this_space = self.__parking_spaces.boxes[this_space_id] this_space.updatePoints(event.x, event.y) # do nothing -- ignore LMB clicks else: if self.__is_verbose: print "INFO: Just clicking LMB merrily =D" # return focus to the main frame for key-press events self.focus_set() # -------------------------------------------------------------------------- # RMB Event Handler # --------------------------------------------------------------------------
Example #21
Source File: pipark_setup.py From PiPark with GNU General Public License v2.0 | 4 votes |
def clickStart(self): """ Close the current setup application, then initiate the main PiPark program. """ if self.__is_verbose: print "ACTION: Clicked 'Start'" # turn off toggle buttons self.spaces_button.setOff() self.cps_button.setOff() # set initial responses response = False response1 = False response2 = False # if setup data has not been saved. Ask user if they would like to save # before continuing. if not self.__is_saved: response = tkMessageBox.askyesno( title = "Save Setup", type = tkMessageBox.YESNOCANCEL, message = "Most recent changes to setup have not been saved." + "Would you like to save before running PiPark?" ) if response: self.saveData() # data is saved, ask the user if they are sure they wish to quit. else: response = tkMessageBox.askyesno( title = "Save Setup", message = "Are you ready to leave setup and run PiPark?" ) # user wishes to quit setup and run pipark, so do it! if response: # ensure data is valid before continuing if not self.checkData(): # data invalid, so display message and return tkMessageBox.showinfo( title = "PiPark Setup", message = "Saved data is invalid. Please ensure that " + "there are 3 control points and at least 1 parking " + "space marked." ) return self.quit_button.invoke() if self.__is_verbose: print "INFO: Setup application terminated. " main.main()
Example #22
Source File: __init__.py From dreampower with GNU General Public License v3.0 | 4 votes |
def init_run_parser(subparsers): run_parser = subparsers.add_parser( 'run', description="Process image(s) with dreampower.", help="Process image(s) with dreampower.", add_help=False ) run_parser.set_defaults(func=main.main) # conflicts handler processing_mod = run_parser.add_mutually_exclusive_group() scale_mod = run_parser.add_mutually_exclusive_group() # add run arguments arg_input(run_parser) arg_output(run_parser) arg_auto_rescale(scale_mod) arg_auto_resize(scale_mod) arg_auto_resize_crop(scale_mod) arg_overlay(scale_mod) arg_ignore_size(scale_mod) arg_color_transfer(run_parser) arg_preferences(run_parser) arg_n_run(run_parser) arg_step(run_parser) arg_altered(run_parser) arg_export_step(run_parser) arg_export_step_path(run_parser) arg_cpu(processing_mod) arg_gpu(processing_mod) arg_checkpoints(run_parser) arg_n_core(run_parser) arg_gan_persistent(run_parser) arg_json_args(run_parser) arg_json_folder_name(run_parser) arg_help(run_parser) arg_debug(run_parser) arg_version(run_parser)