def runUnitTestsAndOutputResults(): unit_test_suite = UnitTestSuite(include=options.module_list, exclude=options.module_ex_list, tests=options.test_list) result_data = unit_test_suite.run() # see refactored method above opt_string = _make_clean_opt_string() # ----------------------------------------------------------- # ------------------- Output Reporting ---------------------- output("") # make things easier to read output("%s - %s\n" % (time.asctime(), wx.GetOsDescription())) output("Platform Information") output("Platform [sys.platform]: %s" % sys.platform) output("Python Version [sys.version]: %s" % sys.version) output("wx Version [wx.version()]: %s" % wx.version()) output("OS [wx.GetOsDescription()]: %s" % wx.GetOsDescription()) output("wx Info [wx.PlatformInfo]: %s" % str(wx.PlatformInfo)) output("runUnitTests.py options: %s" % opt_string) output("\n----------------------\n") output("Summary") output("Run completed in %.2f seconds" % (result_data.elapsedTime)) output("%d classes tested" % (result_data.countSuites)) output("%d tests passed in total!" % (result_data.countSuccesses)) if result_data.countFailures > 0: output("%d tests failed in total!" % (result_data.countFailures)) if result_data.countErrors > 0: output("%d tests erred in total!" % (result_data.countErrors)) output("\n----------------------\n") data_items = result_data.rawData.items() data_items.sort() output("Module Data") for mod_name, results in data_items: messages = ["%d passed" % (results["successes"])] if results["failures"] > 0: messages.append("%d failed" % (results["failures"])) if results["errors"] > 0: messages.append("%d erred" % (results["errors"])) output("%s: %s" % (mod_name, ", ".join(messages))) output("\n----------------------\n") if result_data.countFailures + result_data.countErrors > 0: output("Failure Data") for mod_name, results in data_items: # report on it for failure in results["failure_data"] + results["error_data"]: type = None if failure in results["failure_data"]: type = "Fail: " elif failure in results["error_data"]: type = "Error: " output(" " + type + str(failure[0])) output(" " + str(failure[1]).replace("\n", "\n "))
def EnvironmentInfo(): """ Returns a string of the systems information. **Returns:** * System information string **Note:** * from Editra.dev_tool """ info = "---- Notes ----\n" info += "Please provide additional information about the crash here \n" info += "---- System Information ----\n" info += "Operating System: %s\n" % wx.GetOsDescription() if sys.platform == 'darwin': info += "Mac OSX: %s\n" % platform.mac_ver()[0] info += "Python Version: %s\n" % sys.version info += "wxPython Version: %s\n" % wx.version() info += "wxPython Info: (%s)\n" % ", ".join(wx.PlatformInfo) info += "Python Encoding: Default=%s File=%s\n" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding()) info += "wxPython Encoding: %s\n" % wx.GetDefaultPyEncoding( ) if wx.VERSION_STRING < '4.0' else str(wx.Font.GetDefaultEncoding()) info += "System Architecture: %s %s\n" % (platform.architecture()[0], \ platform.machine()) info += "Byte order: %s\n" % sys.byteorder info += "Frozen: %s\n" % str(getattr(sys, 'frozen', 'False')) info += "---- End System Information ----" return info
def GetEnvironmentInfo(self): """Get the environmental info / Header of error report @return: string """ info = list() info.append("#---- Notes ----#") info.append("Please provide additional information about the crash here") info.extend(["", ""]) info.append("#---- System Information ----#") info.append(self.GetProgramName()) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: (%s)" % ", ".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("wxPython Encoding: %s" % wx.GetDefaultPyEncoding()) info.append("System Architecture: %s %s" % (platform.architecture()[0], \ platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") info.append("") return os.linesep.join(info)
def _createControls(self): # A Statusbar in the bottom of the window self.CreateStatusBar(1) sMsg = 'wxPython ' + wx.version() self.SetStatusText(sMsg) # Add a panel to the frame (needed under Windows to have a nice background) wx.Panel(self, wx.ID_ANY) # Create the menu bar menuBar = wx.MenuBar() # File menu menuFile = wx.Menu() menuFile.Append(wx.ID_EXIT) menuBar.Append(menuFile, wx.GetStockLabel(wx.ID_FILE)) # Help menu menuHelp = wx.Menu() menuHelp.Append(wx.ID_ABOUT) menuBar.Append(menuHelp, wx.GetStockLabel(wx.ID_HELP)) # Assigne the menubar self.SetMenuBar(menuBar) # On OS X, delete the created menus # as the About and Exit items are handled by the OS specific menu if wx.GetOsDescription()[:8] == 'Mac OS X': menuBar.Remove(1) del menuHelp menuBar.Remove(0) del menuFile
def LogError(exception): global error if error: return error = True details = "".join(traceback.format_exception(*exception)) dialog = wx.MessageDialog(None, _("An error has occurred in the application."), _("Error"), wx.ICON_ERROR | wx.YES_NO | wx.CANCEL) ##dialog.SetExtendedMessage(details) ##dialog.SetYesNoCancelLabels(_("Report"), _("Ignore"), _("Abort")) button = dialog.ShowModal() if button == wx.ID_YES: mac = "" if sys.platform == "darwin": mac = "\n Mac version: " + platform.mac_ver()[0] message = text % ( "*" * 40, "*" * 40, details, "*" * 40, wx.GetOsDescription(), mac, platform.architecture()[0], platform.machine(), sys.byteorder, sys.version, sys.getdefaultencoding(), sys.getfilesystemencoding(), wx.VERSION_STRING, ", ".join(wx.PlatformInfo), wx.GetDefaultPyEncoding(), _version, hasattr(sys, "frozen")) if wx.Platform != "__WXMAC__": message = urllib.parse.quote(message) webbrowser.open( "mailto:[email protected]?subject=Write++ Error Report&body=%s" % message.replace("'", "")) elif button == wx.ID_CANCEL: sys.exit(1) dialog.Destroy() error = False
def FormatErrorMessage(task, err): """Returns a string of the systems information @return: System information string """ info = list() info.append("#---- System Information ----#") info.append("%s Version: %s" % (task.about_title, task.about_version)) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: (%s)" % ", ".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("System Architecture: %s %s" % (platform.architecture()[0], \ platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") info.extend(["", ""]) info.append("#---- Traceback Info ----#") info.append(err) info.append("#---- End Traceback Info ----#") info.extend(["", ""]) info.append("#---- Notes ----#") info.append("Please provide additional information about the crash here:") info.append("") return os.linesep.join(info)
def EnvironmentInfo(): """Returns a string of the systems information @return: System information string """ info = list() info.append("#---- Notes ----#") info.append("Please provide additional information about the crash here") info.extend(["", ""]) info.append("#---- System Information ----#") info.append("%s Version: %s" % (ed_glob.PROG_NAME, ed_glob.VERSION)) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: (%s)" % ", ".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("wxPython Encoding: %s" % wx.GetDefaultPyEncoding()) info.append("System Architecture: %s %s" % (platform.architecture()[0], \ platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") info.append("") return os.linesep.join(info)
def __init__(self, parent): wx.Dialog.__init__(self, parent, title="About bsmedit", style=wx.DEFAULT_DIALOG_STYLE) szAll = wx.BoxSizer(wx.VERTICAL) self.panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) self.panel.SetBackgroundColour(wx.WHITE) szPanel = wx.BoxSizer(wx.VERTICAL) self.header = wx.StaticBitmap(self.panel) self.header.SetBitmap(wx.Bitmap(to_byte(header_xpm))) szPanel.Add(self.header, 0, wx.EXPAND, 0) caption = 'bsmedit %s' % (__version__) self.stCaption = wx.StaticText(self.panel, wx.ID_ANY, caption) self.stCaption.SetFont(wx.Font(16, 74, 90, 92, False, "Arial")) szPanel.Add(self.stCaption, 0, wx.ALL | wx.EXPAND, 5) strCopyright = '(c) 2018 Tianzhu Qiao. All rights reserved.' self.stCopyright = wx.StaticText(self.panel, wx.ID_ANY, strCopyright) self.stCopyright.SetMaxSize((240, -1)) self.stCopyright.SetFont(wx.Font(8, 74, 90, 90, False, "Arial")) szPanel.Add(self.stCopyright, 0, wx.ALL | wx.EXPAND, 5) build = wx.GetOsDescription() + '; wxWidgets ' + wx.version() self.stBuild = wx.StaticText(self.panel, wx.ID_ANY, build) self.stBuild.SetMaxSize((240, -1)) self.stBuild.Wrap(240) self.stBuild.SetFont(wx.Font(8, 74, 90, 90, False, "Arial")) szPanel.Add(self.stBuild, 0, wx.ALL | wx.EXPAND, 5) stLine = wx.StaticLine(self.panel, style=wx.LI_HORIZONTAL) szPanel.Add(stLine, 1, wx.EXPAND | wx.ALL, 0) self.panel.SetSizer(szPanel) self.panel.Layout() szPanel.Fit(self.panel) szAll.Add(self.panel, 1, wx.EXPAND | wx.ALL, 0) szConfirm = wx.BoxSizer(wx.VERTICAL) self.btnOk = wx.Button(self, wx.ID_OK, u"Ok") szConfirm.Add(self.btnOk, 0, wx.ALIGN_RIGHT | wx.ALL, 5) szAll.Add(szConfirm, 0, wx.EXPAND, 5) self.SetSizer(szAll) self.Layout() szAll.Fit(self)
def test_utilsSomeOtherStuff(self): wx.GetBatteryState() wx.GetPowerType() wx.GetKeyState(wx.WXK_F1) wx.GetMousePosition() wx.GetMouseState() wx.EnableTopLevelWindows(True) wx.FindWindowAtPoint((1, 1)) wx.NewId() wx.RegisterId(12345) wx.GetUserName() wx.GetUserId() wx.GetOsDescription()
def OnInit(self): if wx.GetOsDescription().find("Windows") == -1: configname = ".metalink_editor" print "Not on win32. Using configuration file:", configname else: configname = "metalink_editor.ini" print "Running win32. Using configuration file:", configname config = wx.FileConfig("Metalink Editor", "Hampus Wessman", configname) wx.ConfigBase.Set(config) self.frame = MainFrame(None, "Metalink Editor") self.frame.Show(True) self.SetTopWindow(self.frame) return True
def OnPaint(self, e): self.count += 1 dc = PDC(self) gc = wx.GraphicsContext.Create(dc) gc.Scale(*([self.scale] * 2)) path = gc.CreatePath() path.AddRectangle(0, 0, *self.Rect[2:]) path2 = gc.CreatePath() for i in xrange(30): path2.AddRectangle( randint(0, 400), randint(0, 400), 50, 50, ) gc.SetPen(wx.Pen(wx.Colour(0, 0, 128), 3)) gc.SetBrush( gc.CreateLinearGradientBrush(0, 0, 100, 100, wx.GREEN, wx.BLUE)) gc.DrawPath(path) gc.SetBrush( gc.CreateLinearGradientBrush(0, 0, 100, 100, wx.RED, wx.BLUE)) gc.DrawPath(path2) for fs in xrange(30, 100, 10): font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) font.SetPointSize(fs) gc.SetFont( font, wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))) gc.DrawRotatedText('hello digsby', 40, 80, self.theta if fs % 20 == 0 else -self.theta) # font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) # font.SetPointSize(72) # gc.SetFont(font, wx.WHITE) # gc.DrawRotatedText('hello digsby', 40,80, self.theta)#, wx.TRANSPARENT_BRUSH) font.SetPointSize(15) gc.SetFont(font, wx.WHITE) gc.DrawText("FPS: " + str(self.FPS) + "/" + str(1000.0 / self.rr), 0, 0) gc.DrawText("Time: " + str(wx.GetLocalTime()), 0, 17) gc.DrawText("Process id: " + str(wx.GetProcessId()), 0, 34) gc.DrawText("OS: " + str(wx.GetOsDescription()), 0, 51)
def EnvironmentInfo(): """Returns a string of the systems information @return: System information string """ info = list() info.append("#---- Notes ----#") info.append("Please provide additional information about the crash here") info.extend(["", "", ""]) info.append("#---- System Information ----#") info.append("%s Version: %s" % (ed_glob.PROG_NAME, ed_glob.VERSION)) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: (%s)" % ", ".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("wxPython Encoding: %s" % wx.GetDefaultPyEncoding()) info.append("System Architecture: %s %s" % (platform.architecture()[0], \ platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") info.append("#---- Runtime Variables ----#") from profiler import Profile ftypes = list() for key in sorted(Profile().keys()): # Exclude "private" information val = Profile().Get(key) if key.startswith('FILE') or 'proxy' in key.lower(): continue elif key == 'LAST_SESSION' or key == 'FHIST': for fname in val: if '.' in fname: ext = fname.split('.')[-1] if ext not in ftypes: ftypes.append(ext) else: try: info.append(u"%s=%s" % (key, str(val))) except UnicodeDecodeError: continue info.append(u"FTYPES=%s" % str(ftypes)) info.append("#---- End Runtime Variables ----#") return os.linesep.join(info)
def buildAboutMenu(self, mainMenu): # Create menu menu = wx.Menu() itm = menu.Append(-1, item='OS: ' + wx.GetOsDescription()) itm.Enable(False) itm = menu.Append(-1, item='Python: ' + sys.version) itm.Enable(False) itm = menu.Append(-1, item='wxPython: ' + wx.version()) mainMenu.Bind(wx.EVT_MENU, lambda e: wx.InfoMessageBox(self), id=itm.GetId()) # Done return menu
def EnvironmentInfo(): """Returns a string of the systems information @return: System information string """ info = list() info.append("#---- System Information ----#") info.append("%s Version: %s" % (ed_glob.PROG_NAME, ed_glob.VERSION)) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: %s" % "\n\t\t".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % \ (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("wxPython Encoding: %s" % wx.GetDefaultPyEncoding()) info.append("System Architecture: %s %s" % (platform.architecture()[0], \ platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") info.append("#---- Runtime Variables ----#") from profiler import Profile ftypes = list() for key, val in Profile().iteritems(): # Exclude "private" information if key.startswith('FILE'): continue elif key == 'LAST_SESSION' or key == 'FHIST': for fname in val: if u'.' in fname: ext = fname.split('.')[-1] if ext not in ftypes: ftypes.append(ext) else: info.append(u"%s=%s" % (key, str(val))) info.append(u"FTYPES=%s" % str(ftypes)) info.append("#---- End Runtime Variables ----#") return u"\n".join(info)
def EnvironmentInfo(version): info = list() info.append("#---- Notas ----#") info.append("Porfavor informe de cualquier dato adicional del error:") info.extend(["", "", ""]) info.append("#---- System Information ----#") info.append("%s Version: %s" % (APLICACION, version)) info.append("Operating System: %s" % wx.GetOsDescription()) if sys.platform == 'darwin': info.append("Mac OSX: %s" % platform.mac_ver()[0]) info.append("Python Version: %s" % sys.version) info.append("wxPython Version: %s" % wx.version()) info.append("wxPython Info: (%s)" % ", ".join(wx.PlatformInfo)) info.append("Python Encoding: Default=%s File=%s" % (sys.getdefaultencoding(), sys.getfilesystemencoding())) info.append("wxPython Encoding: %s" % wx.GetDefaultPyEncoding()) info.append("System Architecture: %s %s" % (platform.architecture()[0], platform.machine())) info.append("Byte order: %s" % sys.byteorder) info.append("Frozen: %s" % str(getattr(sys, 'frozen', 'False'))) info.append("#---- End System Information ----#") return os.linesep.join(info)
def create_gui(self): p = wx.Panel(self, -1) self.p = p if wx.GetOsDescription().find("Windows") == -1: print "Not on win32. Using png-file for icon." icon = wx.Icon(os.path.join(data_path, "metalink_small.png"), wx.BITMAP_TYPE_PNG) else: print "Running win32. Using ico-file." icon = wx.Icon(os.path.join(data_path, "metalink_small.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) # Release Information txt_identity = wx.StaticText(p, -1, "Release name:") self.txtctrl_identity = wx.TextCtrl(p, -1) txt_version = wx.StaticText(p, -1, "Version:") self.txtctrl_version = wx.TextCtrl(p, -1) txt_pub_name = wx.StaticText(p, -1, "Publisher name:") self.txtctrl_pub_name = wx.TextCtrl(p, -1) txt_copy = wx.StaticText(p, -1, "Copyright:") self.txtctrl_copy = wx.TextCtrl(p, -1) txt_url = wx.StaticText(p, -1, "Web site URL:") self.txtctrl_pub_url = wx.TextCtrl(p, -1) txt_desc = wx.StaticText(p, -1, "Description:") self.txtctrl_desc = wx.TextCtrl(p, -1) self.license = { 'GNU GPL': 'http://www.gnu.org/licenses/gpl.html', 'GNU LGPL': 'http://www.gnu.org/licenses/lgpl.html', 'GNU FDL': 'http://www.gnu.org/licenses/fdl.html', 'CC GNU GPL': 'http://creativecommons.org/licenses/GPL/2.0/', 'CC GNU LGPL': 'http://creativecommons.org/licenses/LGPL/2.1/', 'CC Public Domain': 'http://creativecommons.org/licenses/publicdomain/', 'CC Music Sharing': 'http://creativecommons.org/licenses/by-nc-nd/2.0/deed-music', 'CC Dev Nations': 'http://creativecommons.org/licenses/devnations/2.0/', 'CC by-nc-nd': 'http://creativecommons.org/licenses/by-nc-nd/2.5/', 'CC by-nc-sa': 'http://creativecommons.org/licenses/by-nc-sa/3.0/', 'CC by-nc': 'http://creativecommons.org/licenses/by-nc/3.0/', 'CC by-nd': 'http://creativecommons.org/licenses/by-nd/2.5/', 'CC by-sa': 'http://creativecommons.org/licenses/by-sa/2.5/', 'CC by': 'http://creativecommons.org/licenses/by/2.5/', 'CC Sampling': 'http://creativecommons.org/licenses/sampling/1.0/', 'CC Sampling+': 'http://creativecommons.org/licenses/sampling+/1.0/', 'CC nc-sampling+': 'http://creativecommons.org/licenses/nc-sampling+/1.0/', 'BSD': 'http://opensource.org/licenses/bsd-license.php', 'MIT': 'http://opensource.org/licenses/mit-license.php', 'MPL 1.0': 'http://opensource.org/licenses/mozilla1.0.php', 'MPL 1.1': 'http://opensource.org/licenses/mozilla1.1.php', 'AFL 3.0': 'http://opensource.org/licenses/afl-3.0.php', 'OSL 3.0': 'http://opensource.org/licenses/osl-3.0.php', 'zlib/libpng': 'http://opensource.org/licenses/zlib-license.php', 'Artistic License': 'http://opensource.org/licenses/artistic-license.php' } choices_license = [ 'Unknown', 'Commercial', 'Shareware', 'Public Domain', 'GNU GPL', 'GNU LGPL', 'GNU FDL', 'CC GNU GPL', 'CC GNU LGPL', 'CC Public Domain', 'CC Music Sharing', 'CC Dev Nations', 'CC by-nc-nd', 'CC by-nc-sa', 'CC by-nc', 'CC by-nd', 'CC by-sa', 'CC by', 'CC Sampling', 'CC Sampling+', 'CC nc-sampling+', 'BSD', 'MIT', 'MPL 1.0', 'MPL 1.1', 'AFL 3.0', 'OSL 3.0', 'zlib/libpng', 'Artistic License' ] txt_license_name = wx.StaticText(p, -1, "License name:") self.combo_license_name = wx.ComboBox(p, -1, 'Unknown', wx.DefaultPosition, wx.Size(150, -1), choices_license, wx.CB_DROPDOWN) txt_license_url = wx.StaticText(p, -1, "License URL:") self.txtctrl_license_url = wx.TextCtrl(p, -1) # Sizers Release Information rel_sizer = wx.FlexGridSizer(0, 2) rel_sizer.AddGrowableCol(1) rel_sizer.Add(txt_identity, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_box = wx.BoxSizer(wx.HORIZONTAL) rel_box.Add(self.txtctrl_identity, 1, wx.ALL | wx.EXPAND, 2) rel_box.Add(txt_version, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 2) rel_box.Add(self.txtctrl_version, 0, wx.ALL, 2) rel_sizer.Add(rel_box, 1, wx.EXPAND) rel_sizer.Add(txt_pub_name, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_sizer.Add(self.txtctrl_pub_name, 1, wx.ALL | wx.EXPAND, 2) rel_sizer.Add(txt_copy, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_sizer.Add(self.txtctrl_copy, 1, wx.ALL | wx.EXPAND, 2) rel_sizer.Add(txt_url, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_sizer.Add(self.txtctrl_pub_url, 1, wx.ALL | wx.EXPAND, 2) rel_sizer.Add(txt_desc, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_sizer.Add(self.txtctrl_desc, 1, wx.ALL | wx.EXPAND, 2) rel_sizer.Add(txt_license_name, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) rel_box = wx.BoxSizer(wx.HORIZONTAL) rel_box.Add(self.combo_license_name, 0, wx.ALL, 2) rel_box.Add(txt_license_url, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 2) rel_box.Add(self.txtctrl_license_url, 1, wx.ALL | wx.EXPAND, 2) rel_sizer.Add(rel_box, 1, wx.EXPAND) rel_staticbox = wx.StaticBoxSizer( wx.StaticBox(p, -1, "Release Information (Recommended)"), wx.VERTICAL) rel_staticbox.Add(rel_sizer, 1, wx.ALL | wx.EXPAND, 2) # File Information txt_filename = wx.StaticText(p, -1, "File name:") self.txtctrl_filename = wx.TextCtrl(p, -1) txt_size = wx.StaticText(p, -1, "File size (bytes):") self.txtctrl_size = wx.TextCtrl(p, -1) txt_md5 = wx.StaticText(p, -1, "MD5 hash:") self.txtctrl_md5 = wx.TextCtrl(p, -1) txt_sha1 = wx.StaticText(p, -1, "SHA-1 hash:") self.txtctrl_sha1 = wx.TextCtrl(p, -1) txt_sha256 = wx.StaticText(p, -1, "SHA-256 hash:") self.txtctrl_sha256 = wx.TextCtrl(p, -1) txt_os = wx.StaticText(p, -1, "Platform:") choices_os = [ 'Unknown', 'Source', 'BSD-x86', 'BSD-x64', 'Linux-x86', 'Linux-x64', 'Linuxia64', 'Linux-alpha', 'Linux-arm', 'Linux-hppa', 'Linux-m68k', 'Linux-mips', 'Linux-mipsel', 'Linux-PPC', 'Linux-PPC64', 'Linux-s390', 'Linux-SPARC', 'MacOSX-PPC', 'MacOSX-Intel', 'MacOSX-UB', 'Solaris-SPARC', 'Solaris-x86', 'Windows-x86', 'Windows-x64', 'Windowsia64' ] self.combo_os = wx.ComboBox(p, -1, 'Unknown', wx.DefaultPosition, wx.Size(150, -1), choices_os, wx.CB_DROPDOWN) txt_lang = wx.StaticText(p, -1, "Language:") self.txtctrl_lang = wx.TextCtrl(p, -1, "", wx.DefaultPosition, wx.Size(50, -1)) txt_maxconn_total = wx.StaticText(p, -1, "Max connections for this file:") choices_maxconn = ['-', '1', '2', '3', '4', '5', '10'] self.combo_maxconn_total = wx.ComboBox(p, -1, '-', wx.DefaultPosition, wx.DefaultSize, choices_maxconn, wx.CB_DROPDOWN) self.btn_file_clear = wx.Button(p, -1, "Clear") self.btn_scan = wx.Button(p, -1, "Scan file...") # Sizers File Information file_sizer = wx.FlexGridSizer(0, 2) file_sizer.AddGrowableCol(1) file_sizer.Add(txt_filename, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) file_box = wx.BoxSizer(wx.HORIZONTAL) file_box.Add(self.txtctrl_filename, 1, wx.ALL | wx.EXPAND, 2) file_box.Add(txt_size, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 2) file_box.Add(self.txtctrl_size, 0, wx.ALL, 2) file_sizer.Add(file_box, 1, wx.EXPAND) file_sizer.Add(txt_md5, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) file_sizer.Add(self.txtctrl_md5, 0, wx.ALL | wx.EXPAND, 2) file_sizer.Add(txt_sha1, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) file_sizer.Add(self.txtctrl_sha1, 0, wx.ALL | wx.EXPAND, 2) file_sizer.Add(txt_sha256, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) file_sizer.Add(self.txtctrl_sha256, 0, wx.ALL | wx.EXPAND, 2) file_sizer.Add(txt_os, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) file_box = wx.BoxSizer(wx.HORIZONTAL) file_box.Add(self.combo_os, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) file_box.Add(txt_lang, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 2) file_box.Add(self.txtctrl_lang, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) file_box.Add(txt_maxconn_total, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 2) file_box.Add(self.combo_maxconn_total, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5) file_box.Add(wx.Size(0, 0), 1) file_box.Add(self.btn_file_clear, 0, wx.RIGHT, 2) file_box.Add(self.btn_scan, 0) file_sizer.Add(file_box, 0, wx.ALL | wx.EXPAND, 2) file_staticbox = wx.StaticBoxSizer( wx.StaticBox(p, -1, "File Information (Recommended)"), wx.VERTICAL) file_staticbox.Add(file_sizer, 1, wx.ALL | wx.EXPAND, 2) # Resources self.filelist_columns = False self.filelist = wx.ListCtrl(p, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT) self.init_filelist() txt_url = wx.StaticText(p, -1, "URL:") self.txtctrl_url = wx.TextCtrl(p, -1, "", wx.DefaultPosition, wx.Size(50, -1), wx.TE_PROCESS_ENTER) txt_loc = wx.StaticText(p, -1, "Location:") self.txtctrl_loc = wx.TextCtrl(p, -1, "", wx.DefaultPosition, wx.Size(50, -1), wx.TE_PROCESS_ENTER) txt_pref = wx.StaticText(p, -1, "Preference:") self.txtctrl_pref = wx.TextCtrl(p, -1, "", wx.DefaultPosition, wx.Size(50, -1), wx.TE_PROCESS_ENTER) txt_maxconn = wx.StaticText(p, -1, "Connections:") choices_maxconn = ['-', '1', '2', '3', '4', '5', '10'] self.combo_maxconn = wx.ComboBox(p, -1, '-', wx.DefaultPosition, wx.DefaultSize, choices_maxconn, wx.CB_DROPDOWN) self.btn_add = wx.Button(p, -1, "Add") self.btn_change = wx.Button(p, -1, "Change") self.btn_remove = wx.Button(p, -1, "Remove") # Sizers Resources res_editbox = wx.BoxSizer(wx.HORIZONTAL) res_editbox.Add( txt_url, 0, wx.RIGHT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(self.txtctrl_url, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(txt_loc, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(self.txtctrl_loc, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(txt_pref, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(self.txtctrl_pref, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add(txt_maxconn, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) res_editbox.Add( self.combo_maxconn, 0, wx.LEFT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, 2) res_btnbox = wx.BoxSizer(wx.HORIZONTAL) res_btnbox.Add(wx.Size(0, 0), 1) res_btnbox.Add(self.btn_add, 0) res_btnbox.Add(self.btn_change, 0, wx.LEFT | wx.RIGHT, 2) res_btnbox.Add(self.btn_remove, 0) res_staticbox = wx.StaticBoxSizer( wx.StaticBox(p, -1, "List of URLs (Required)"), wx.VERTICAL) res_staticbox.Add(self.filelist, 1, wx.ALL | wx.EXPAND, 2) res_staticbox.Add(res_editbox, 0, wx.ALL | wx.EXPAND, 2) res_staticbox.Add(res_btnbox, 0, wx.ALL | wx.EXPAND, 2) # Menu file = wx.Menu() self.menu_new = file.Append( -1, "New", "Create a new metalink. All unsaved data will be lost!") self.menu_open = file.Append(-1, "Open...", "Open a metalink file.") self.menu_save = file.Append(-1, "Save", "Save current file.") self.menu_save_as = file.Append(-1, "Save as...", "Save with a new file name.") self.menu_exit = file.Append( -1, "Exit", "Close the editor. All unsaved data will be lost!") opt = wx.Menu() id_settings = wx.NewId() self.menu_settings = opt.Append( id_settings, "Settings...", "Change the settings. Controls how chunk checksums are generated.") #opt.Enable(id_settings, False) help = wx.Menu() self.menu_about = help.Append(-1, "About...", "Show info about the application.") menu = wx.MenuBar() menu.Append(file, "File") menu.Append(opt, "Options") menu.Append(help, "Help") self.SetMenuBar(menu) self.CreateStatusBar(2) self.GetStatusBar().SetStatusWidths([-1, 200]) # Bind events self.Bind(wx.EVT_BUTTON, self.onBtnFileClear, self.btn_file_clear) self.Bind(wx.EVT_BUTTON, self.onBtnScan, self.btn_scan) self.Bind(wx.EVT_BUTTON, self.onAddURL, self.btn_add) self.Bind(wx.EVT_BUTTON, self.onBtnChange, self.btn_change) self.Bind(wx.EVT_BUTTON, self.onBtnRemove, self.btn_remove) self.Bind(wx.EVT_TEXT_ENTER, self.onAddURL, self.txtctrl_url) self.Bind(wx.EVT_TEXT_ENTER, self.onAddURL, self.txtctrl_loc) self.Bind(wx.EVT_TEXT_ENTER, self.onAddURL, self.txtctrl_pref) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onURLSelected, self.filelist) self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.onURLDeselect, self.filelist) self.Bind(wx.EVT_MENU, self.onMenuAbout, self.menu_about) self.Bind(wx.EVT_MENU, self.onMenuSettings, self.menu_settings) self.Bind(wx.EVT_MENU, self.onMenuNew, self.menu_new) self.Bind(wx.EVT_MENU, self.onMenuOpen, self.menu_open) self.Bind(wx.EVT_MENU, self.onMenuSave, self.menu_save) self.Bind(wx.EVT_MENU, self.onMenuSaveAs, self.menu_save_as) self.Bind(wx.EVT_MENU, self.onMenuExit, self.menu_exit) self.Bind(wx.EVT_COMBOBOX, self.onLicenseSelected, self.combo_license_name) # Frame topsizer = wx.BoxSizer(wx.VERTICAL) topsizer.Add(rel_staticbox, 0, wx.ALL | wx.EXPAND, 5) topsizer.Add(file_staticbox, 0, wx.RIGHT | wx.LEFT | wx.BOTTOM | wx.EXPAND, 5) topsizer.Add(res_staticbox, 1, wx.RIGHT | wx.LEFT | wx.BOTTOM | wx.EXPAND, 5) self.topsizer = topsizer p.SetSizer(topsizer) p.Layout() topsizer.SetSizeHints(self) self.SetSize(wx.Size(800, 700))
def 程序_取系统版本信息(): "返回示例: Windows 10 (build 18363),64位版" return wx.GetOsDescription()
print "Error opening output file, defaulting to original stdout" sys.stdout = origstdout unit_test_suite = UnitTestSuite(include=options.module_list, exclude=options.module_ex_list, tests=options.test_list) result_data = unit_test_suite.run() # see refactored method above opt_string = _make_clean_opt_string() # ----------------------------------------------------------- # ------------------- Output Reporting ---------------------- output(1, "") # make things easier to read wiki(wiki_title(3, "%s - %s" % (time.asctime(), wx.GetOsDescription())), level=2) output(2, wiki_title(4, "Platform Information")) output(2, wiki_summary_item("Platform [sys.platform]", sys.platform)) output(2, wiki_summary_item("Python Version [sys.version]", sys.version)) output(2, wiki_summary_item("wx Version [wx.version()]", wx.version())) output(2, wiki_summary_item("OS [wx.GetOsDescription()]", wx.GetOsDescription())) output(2, wiki_summary_item("wx Info [wx.PlatformInfo]", str(wx.PlatformInfo))) output(2, wiki_summary_item("runUnitTests.py options", opt_string)) wiki("\n----------------------\n", level=3, reverse=True) output(1, wiki_title(4, "Summary")) output( 2, wiki_bullet() + "Run completed in %.2f seconds" %
def runUnitTestsAndOutputResults(): unit_test_suite = UnitTestSuite(include=options.module_list, exclude=options.module_ex_list, tests=options.test_list) result_data = unit_test_suite.run() # see refactored method above opt_string = _make_clean_opt_string() # ----------------------------------------------------------- # ------------------- Output Reporting ---------------------- output(1, "") # make things easier to read wiki(wiki_title(3, "%s - %s" % (time.asctime(), wx.GetOsDescription())), level=2) output(2, wiki_title(4, "Platform Information")) output(2, wiki_summary_item("Platform [sys.platform]", sys.platform)) output(2, wiki_summary_item("Python Version [sys.version]", sys.version)) output(2, wiki_summary_item("wx Version [wx.version()]", wx.version())) output( 2, wiki_summary_item("OS [wx.GetOsDescription()]", wx.GetOsDescription())) output( 2, wiki_summary_item("wx Info [wx.PlatformInfo]", str(wx.PlatformInfo))) output(2, wiki_summary_item("runUnitTests.py options", opt_string)) wiki("\n----------------------\n", level=3, reverse=True) output(1, wiki_title(4, "Summary")) output( 2, wiki_bullet() + "Run completed in %.2f seconds" % (result_data.elapsedTime)) output(2, wiki_bullet() + "%d classes tested" % (result_data.countSuites)) output( 1, wiki_bullet() + "%d tests passed in total!" % (result_data.countSuccesses)) if result_data.countFailures > 0: output( 1, wiki_bullet() + "%d tests failed in total!" % (result_data.countFailures)) if result_data.countErrors > 0: output( 1, wiki_bullet() + "%d tests erred in total!" % (result_data.countErrors)) wiki("\n----------------------\n", level=3, reverse=True) data_items = result_data.rawData.items() data_items.sort() output(3, wiki_title(4, "Module Data")) for mod_name, results in data_items: messages = ["%d passed" % (results["successes"])] if results["failures"] > 0: messages.append("%d failed" % (results["failures"])) if results["errors"] > 0: messages.append("%d erred" % (results["errors"])) output(3, wiki_bullet() + "%s: %s" % (mod_name, ", ".join(messages))) wiki("\n----------------------\n", level=4, reverse=True) if result_data.countFailures + result_data.countErrors > 0: output(4, wiki_title(4, "Failure Data")) for mod_name, results in data_items: # report on it for failure in results["failure_data"] + results["error_data"]: type = None if failure in results["failure_data"]: type = "Fail: " elif failure in results["error_data"]: type = "Error: " if options.wiki: output( 4, wiki_bullet() + type + str(failure[0]).replace('.', '.!')) output(5, " {{{" + str(failure[1]) + "}}}") else: output(4, " " + type + str(failure[0])) output(5, " " + str(failure[1]).replace("\n", "\n "))
def init_config(self): home = os.getenv('USERPROFILE') or os.getenv('HOME') if os.path.exists(home + os.sep + ".nervatura" + os.sep + "nervatura.ini") == False: if os.path.exists(home + os.sep + ".nervatura") == False: os.makedirs(home + os.sep + ".nervatura") self.user_config = ConfigObj() self.user_config.filename = home + os.sep + ".nervatura" + os.sep + "nervatura.ini" self.user_config.write() else: self.user_config = ConfigObj(home + os.sep + ".nervatura" + os.sep + "nervatura.ini") if self.user_config.has_key("locale") == True: self.application.app_settings["locale"] = str( self.user_config["locale"]) else: self.application.app_settings["locale"] = str( self.application.app_config["default"]["locale"]) self.locale = ConfigObj("locale/" + self.application.app_settings["locale"] + "/" + self.__class__.__name__ + ".properties") self.application.app_settings["codepage"] = locale.getdefaultlocale( )[1] if self.user_config.has_key("url") == True: self.application.app_settings["url"] = str(self.user_config["url"]) else: self.application.app_settings["url"] = str( self.application.app_config["connection"]["default_url"]) if self.user_config.has_key("database") == True: self.application.app_settings["database"] = str( self.user_config["database"]) else: self.application.app_settings["database"] = "" if self.user_config.has_key("username") == True: self.application.app_settings["username"] = str( self.user_config["username"]) else: self.application.app_settings["username"] = "" self.application.app_settings["password"] = "" #self.application.app_settings["usergroup"] = str(self.application.app_config["default"]["usergroup"]) self.application.app_settings["transfilter"] = int( self.application.app_config["default"]["transfilter"]) self.application.app_settings["department"] = None self.application.app_settings["department_id"] = None self.application.app_settings["color"] = self.application.app_config[ "default"]["color"] self.application.app_settings[ "label_color"] = self.application.app_config["default"][ "label_color"] self.application.app_settings[ "panel_color"] = self.application.app_config["default"][ "panel_color"] self.application.app_settings[ "help_color"] = self.application.app_config["default"][ "help_color"] self.application.app_settings[ "close_color"] = self.application.app_config["default"][ "close_color"] self.application.app_settings["os"] = str( wx.GetOsDescription()).split(" ")[0] self.application.app_settings["engine"] = "sqlite"
def _createControls(self): # A Statusbar in the bottom of the window self.CreateStatusBar(1) sMsg = 'wxPython ' + wx.version() self.SetStatusText(sMsg) # Add a panel to the frame (needed under Windows to have a nice background) pnl = wx.Panel(self, wx.ID_ANY) szrMain = wx.BoxSizer(wx.VERTICAL) stbSzr = wx.StaticBoxSizer(wx.VERTICAL, pnl, 'Informations to show in the "About" box:') self._optInfos[Options.MINIMAL] = wx.RadioButton(pnl, wx.ID_ANY, 'Application\'s name only (minimal "About" box)', style=wx.RB_GROUP) stbSzr.Add(self._optInfos[Options.MINIMAL], 0, wx.ALL, 5) self._optInfos[Options.MAXIMAL] = wx.RadioButton(pnl, wx.ID_ANY, 'All available informations') stbSzr.Add(self._optInfos[Options.MAXIMAL], 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) self._optInfos[Options.CUSTOM] = wx.RadioButton(pnl, wx.ID_ANY, 'Let me select the informations I want to see') stbSzr.Add(self._optInfos[Options.CUSTOM], 0, wx.LEFT|wx.RIGHT, 5) lnSzr = wx.BoxSizer(wx.HORIZONTAL) lnSzr.AddSpacer(10) flxSzr = wx.FlexGridSizer(2, 5, 5) self._chkInfos[Details.APP_NAME] = wx.CheckBox(pnl, wx.ID_ANY, 'Application\'s name') self._chkInfos[Details.APP_NAME].Disable() flxSzr.Add(self._chkInfos[Details.APP_NAME]) self._chkInfos[Details.APP_VERSION] = wx.CheckBox(pnl, wx.ID_ANY, 'Application\'s version') flxSzr.Add(self._chkInfos[Details.APP_VERSION]) self._chkInfos[Details.APP_DESCRIPTION] = wx.CheckBox(pnl, wx.ID_ANY, 'Description') flxSzr.Add(self._chkInfos[Details.APP_DESCRIPTION]) self._chkInfos[Details.COPYRIGHT] = wx.CheckBox(pnl, wx.ID_ANY, 'Copyright') flxSzr.Add(self._chkInfos[Details.COPYRIGHT]) self._chkInfos[Details.ICON] = wx.CheckBox(pnl, wx.ID_ANY, 'Icon') flxSzr.Add(self._chkInfos[Details.ICON]) self._chkInfos[Details.LICENCE] = wx.CheckBox(pnl, wx.ID_ANY, 'Licence text') flxSzr.Add(self._chkInfos[Details.LICENCE]) self._chkInfos[Details.DEVELOPPER] = wx.CheckBox(pnl, wx.ID_ANY, 'Main developper') flxSzr.Add(self._chkInfos[Details.DEVELOPPER]) self._chkInfos[Details.DEVELOPPERS] = wx.CheckBox(pnl, wx.ID_ANY, 'Multiple developpers') flxSzr.Add(self._chkInfos[Details.DEVELOPPERS]) self._chkInfos[Details.WEBSITE] = wx.CheckBox(pnl, wx.ID_ANY, 'Website url') flxSzr.Add(self._chkInfos[Details.WEBSITE]) self._chkInfos[Details.TRANSLATORS] = wx.CheckBox(pnl, wx.ID_ANY, 'Translators') flxSzr.Add(self._chkInfos[Details.TRANSLATORS]) lnSzr.Add(flxSzr, 0, wx.ALL, 0) stbSzr.Add(lnSzr, 0, wx.ALL, 5) szrMain.Add(stbSzr, 1, wx.ALL|wx.EXPAND, 5) pnl.SetSizer(szrMain) # At startup, select the "All available infos" option self._optInfos[Options.MAXIMAL].SetValue(True) # Check the wxCheckBoxes depending on the defined array (see on top of this file) for i in iCheckedBoxes: self._chkInfos[i].SetValue(True) # Create the menu bar menuBar = wx.MenuBar() # File menu menuFile = wx.Menu() menuFile.Append(wx.ID_EXIT) menuBar.Append(menuFile, wx.GetStockLabel(wx.ID_FILE)) # Help menu menuHelp = wx.Menu() menuHelp.Append(wx.ID_ABOUT) menuBar.Append(menuHelp, wx.GetStockLabel(wx.ID_HELP)) # Assigne the menubar self.SetMenuBar(menuBar) # On OS X, delete the created menus # as the About and Exit items are handled by the OS specific menu if wx.GetOsDescription()[:8] == 'Mac OS X': menuBar.Remove(1) del menuHelp menuBar.Remove(0) del menuFile # Adjust window size szrMain.SetSizeHints(self)