def addContents(self): logoFile = os.path.join(plugins.installationDir("images"), "texttest-logo.gif") logoPixbuf = gtk.gdk.pixbuf_new_from_file(logoFile) logo = gtk.Image() logo.set_from_pixbuf(logoPixbuf) logoFrame = gtk.Alignment(0.5, 0.5, 0.0, 0.0) logoFrame.set_padding(10, 10, 10, 10) logoFrame.add(logo) mainLabel = gtk.Label() mainLabel.set_markup("<span size='xx-large'>TextTest " + texttest_version.version + "</span>\n") messageLabel = gtk.Label() message = "TextTest is an application-independent tool for text-based\nfunctional testing. This means running a batch-mode program\nin lots of different ways, and using the text output produced\nas a means of controlling the behaviour of that application." messageLabel.set_markup("<i>" + message + "</i>\n") messageLabel.set_justify(gtk.JUSTIFY_CENTER) # On Windows the default URI hook fails and causes trouble... # According to the docs you can set "None" here but that doesn't seem to work... gtk.link_button_set_uri_hook(lambda x, y : None) urlButton = gtk.LinkButton(self.website, self.website) urlButton.set_property("border-width", 0) urlButtonbox = gtk.HBox() urlButtonbox.pack_start(urlButton, expand=True, fill=False) urlButton.connect("clicked", self.urlClicked) licenseLabel = gtk.Label() licenseLabel.set_markup("<span size='small'>Copyright " + u'\xa9' + " The authors</span>\n") self.dialog.vbox.pack_start(logoFrame, expand=False, fill=False) self.dialog.vbox.pack_start(mainLabel, expand=True, fill=True) self.dialog.vbox.pack_start(messageLabel, expand=False, fill=False) self.dialog.vbox.pack_start(urlButtonbox, expand=False, fill=False) self.dialog.vbox.pack_start(licenseLabel, expand=False, fill=False) self.dialog.set_resizable(False)
def addContents(self): notebook = gtk.Notebook() notebook.set_scrollable(True) notebook.popup_enable() docDir = plugins.installationDir("doc") versionInfo = self.readVersionInfo(docDir) for version in reversed(sorted(versionInfo.keys())): buffer = gtk.TextBuffer() buffer.set_text(versionInfo[version]) textView = gtk.TextView(buffer) textView.set_editable(False) textView.set_cursor_visible(False) textView.set_left_margin(5) textView.set_right_margin(5) scrolledWindow = gtk.ScrolledWindow() scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolledWindow.add(textView) scrolledWindow.set_shadow_type(gtk.SHADOW_IN) versionStr = ".".join(map(str, version)) notebook.append_page(scrolledWindow, gtk.Label(self.labelPrefix() + versionStr)) if notebook.get_n_pages() == 0: #pragma : no cover - should never happen raise plugins.TextTestError, "\nNo " + self.getTitle() + " could be found in\n" + docDir + "\n" else: parentSize = self.topWindow.get_size() self.dialog.resize(int(parentSize[0] * 0.9), int(parentSize[1] * 0.7)) self.dialog.vbox.pack_start(notebook, expand=True, fill=True)
def createView(self): hbox = gtk.HBox() self.label = gtk.Label() self.label.set_name("GUI status") self.label.set_ellipsize(pango.ELLIPSIZE_END) # It seems difficult to say 'ellipsize when you'd otherwise need # to enlarge the window', so we'll have to settle for a fixed number # of max char's ... The current setting (90) is just a good choice # based on my preferred window size, on the test case I used to # develop this code. (since different chars have different widths, # the optimal number depends on the string to display) \ Mattias++ self.label.set_max_width_chars(90) self.label.set_use_markup(True) self.label.set_markup(plugins.convertForMarkup("TextTest started at " + plugins.localtime() + ".")) hbox.pack_start(self.label, expand=False, fill=False) imageDir = plugins.installationDir("images") try: staticIcon = os.path.join(imageDir, "throbber_inactive.png") temp = gtk.gdk.pixbuf_new_from_file(staticIcon) self.throbber = gtk.Image() self.throbber.set_from_pixbuf(temp) animationIcon = os.path.join(imageDir, "throbber_active.gif") self.animation = gtk.gdk.PixbufAnimation(animationIcon) hbox.pack_end(self.throbber, expand=False, fill=False) except Exception, e: plugins.printWarning("Failed to create icons for the status throbber:\n" + str(e) + \ "\nAs a result, the throbber will be disabled.", stdout=True) self.throbber = None
def getVirtualServerArgs(self, machine, app): binDir = plugins.installationDir("libexec") fullPath = os.path.join(binDir, "startXvfb.py") logDir = os.path.join(app.writeDirectory, "Xvfb") plugins.ensureDirectoryExists(logDir) python = self.findPython(machine) xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args")) cmdArgs = [ python, "-u", fullPath, logDir ] + xvfbExtraArgs return app.getCommandArgsOn(machine, cmdArgs)
def getVirtualServerArgs(self, machine, app): binDir = plugins.installationDir("libexec") fullPath = os.path.join(binDir, "startXvfb.py") appTmpDir = app.getRemoteTmpDirectory()[1] if appTmpDir: logDir = os.path.join(appTmpDir, "Xvfb") app.ensureRemoteDirExists(machine, logDir) remoteXvfb = os.path.join(appTmpDir, "startXvfb.py") app.copyFileRemotely(fullPath, "localhost", remoteXvfb, machine) fullPath = remoteXvfb pythonArgs = [ "python", "-u" ] else: logDir = os.path.join(app.writeDirectory, "Xvfb") plugins.ensureDirectoryExists(logDir) pythonArgs = self.findPythonArgs(machine) xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args")) cmdArgs = pythonArgs + [ fullPath, logDir ] + xvfbExtraArgs return app.getCommandArgsOn(machine, cmdArgs)
def __init__(self, record): self.record = record self.trafficServerProcess = None self.trafficFiles = self.findTrafficFiles() self.trafficPyModuleFile = os.path.join(plugins.installationDir("libexec"), "traffic_pymodule.py") self.trafficServerFile = os.path.join(plugins.installationDir("libexec"), "traffic_server.py")
def findTrafficFiles(self): libExecDir = plugins.installationDir("libexec") files = [ os.path.join(libExecDir, "traffic_cmd.py") ] if os.name == "nt": files.append(os.path.join(libExecDir, "traffic_cmd.exe")) return files
def getIcon(self): imageDir = plugins.installationDir("images") if self.dynamic: return os.path.join(imageDir, "texttest-icon-dynamic.jpg") else: return os.path.join(imageDir, "texttest-icon-static.jpg")
def __init__(self, recordSetting): self.recordSetting = recordSetting libexecDir = plugins.installationDir("libexec") self.siteCustomizeFile = os.path.join(libexecDir, "sitecustomize.py")