def _selectionChanged(self, command): """ Called when a command is selected in any category. Arguments: command (str): Command name. """ sender_view = self.sender() for view in self.panel.widgets(): if view != sender_view: view.clearSelection() if command: translation = translate_command(command) description = CATA.get_command_docstring(command) url = self.astergui().doc_url(command) if translation != command: text = italic(translation) + " ({})".format(bold(command)) else: text = bold(command) # add doc url if url: doc = href(image(CFG.rcfile("as_pic_help.png"), width=20, height=20), url) text += " " + doc text = preformat(text) if description: text = text + "<br/>" + description self.info.setText(text) else: self.info.setText("") self.updateButtonStatus()
def _updateState(self): """Update state and current title label.""" disabled = self.command() is None self.setDisabled(disabled) if not disabled: disabled = self.command().gettype(ConversionLevel.NoFail) is None self._name.setDisabled(disabled) txt = [] pview = self.currentParameterView() if pview is not None: txt = pview.path().names() ppath = None txt_list = [] tooltip = "" whats_this = "" while len(txt) > 0: name = txt.pop(0) if ppath is None: ppath = ParameterPath(self.command(), name=name) else: ppath = ppath.absolutePath(name) if ppath.isInSequence(): txt_list.append("[" + name + "]") elif get_cata_typeid(ppath.keyword()) in (IDS.simp, IDS.fact): # translate keyword kwtext = Options.translate_command(ppath.command().title, name) txt_list.append(kwtext) elif get_cata_typeid(ppath.keyword()) == IDS.command: # translate command translation = Options.translate_command(name) txt_list.append(translation) if translation != name: wttext = italic(translation) + " ({})".format(bold(name)) else: wttext = bold(name) tooltip = preformat(wttext) url = self.astergui().doc_url(name) if url: wttext += " " wttext += href( image(CFG.rcfile("as_pic_help.png"), width=20, height=20), url) wttext = preformat(wttext) docs = CATA.get_command_docstring(name) if docs: wttext += "<hr>" wttext += docs whats_this = wttext self.title.setTitle(txt_list) self.title.setToolTip(tooltip) self.title.setWhatsThis(whats_this)
def show_message(self): """Return the messages of each stage of the case. Returns: str: Rich text of the messages. """ # TODO: it's a job for a dedicated module! alltxt = [] header = [div("summary"), bold(translate("Result", "Summary"))] rtxt = [] for stage in self.stages: # pragma pylint: disable=no-member if not stage.state & StateOptions.Finished: break if stage.parent_case is not self: continue title = bold( translate("Result", "Output messages for stage {0}").format(stage.name)) # link rtxt.append(div(stage.name)) header.append(href(title, "#" + stage.name)) if stage.is_intermediate(): rtxt.append( translate("Result", "Execution grouped with the following " "stage.")) continue rtxt.append(title + " - [" \ + href(translate("Result", "top"), '#summary') + " / "\ + href(translate("Result", "bottom"), "#bottom") + "]") # show message file content mess = osp.join(stage.folder, 'message') if osp.exists(mess): with open(mess, 'rb') as fobj: text = fobj.read() text = cgi.escape(text.decode('utf-8', 'ignore')) rtxt.append(preformat(text)) else: rtxt.append( translate( "Result", "Full job output should be available" " in the directory {0!r}.").format( osp.join(stage.folder, 'logs'))) rtxt.extend([ div("bottom") + href(translate("Result", "back to top"), "#summary") ]) if len(header) > 2: alltxt.extend(header) else: alltxt = [header[0]] alltxt.extend(rtxt) txt = "\n".join(alltxt).strip() return "<br />".join(txt.splitlines())
def _typeInformation(self): """ Gets the information text about keyword type. """ inflist = [] kword = self.path().keyword() if kword is not None: kwtypelist = [] kwdef = kword.definition enum = kwdef.get('into') is not None if enum and sorted(kwdef.get('into')) == ["NON", "OUI"]: txt = "'%s'/'%s'" % (bold(translate("ParameterPanel", "Yes")), bold(translate("ParameterPanel", "No"))) inflist.append(txt) elif kwdef.get('typ') is not None: kwtypelist = to_list(kwdef.get('typ')) for kwtype in kwtypelist: if kwtype is None: continue if kwtype == 'I': txt = bold(translate("ParameterPanel", "integer")) lim = self._numberLimitsInfo(kwdef.get('val_min'), kwdef.get('val_max')) if len(lim): txt += " " + lim elif kwtype == 'R': txt = bold(translate("ParameterPanel", "float")) lim = self._numberLimitsInfo(kwdef.get('val_min'), kwdef.get('val_max')) if len(lim): txt += " " + lim elif kwtype == 'TXM': txt = bold(translate("ParameterPanel", "string")) elif is_subclass(kwtype, CATA.package('DataStructure').CO): txt = bold(translate("ParameterPanel", "macro name")) elif isinstance(kwtype, (types.TypeType, types.ClassType)): txt = translate("ParameterPanel", "object with type") txt += bold(" '%s'" % kwtype.__name__) else: txt = bold(str(kwtype)) if len(txt): if enum: txt += " (%s)" % italic(translate("ParameterPanel", "enumerated")) inflist.append(txt) info = "" if len(inflist): islist = self.path().isKeywordSequence() and \ not self.path().isInSequence() prefix = translate("ParameterPanel", "List with types") \ if islist else translate("ParameterPanel", "Value types") info = prefix + ": " + ", ".join(inflist) return info
def _defaultInformation(self): info = "" if not self.path().isKeywordSequence() or \ self.path().isInSequence(): kword = self.path().keyword() if kword is not None: if hasattr(kword, 'hasDefaultValue') \ and kword.hasDefaultValue(): info = translate("ParameterPanel", "Default value: ") + \ italic(bold(str(kword.defaultValue()))) return info
def _numberLimitsInfo(self, vmin, vmax, inclusive=True, allowrange=True): """ Format min, max limits information into human readable string. """ txt = "" if allowrange and vmin is not None and vmax is not None: txt += " " + translate("ParameterPanel", "in range") if inclusive: txt += " [%s, %s]" % (italic(bold(str(vmin))), italic(bold(str(vmax)))) else: txt += " (%s, %s)" % (italic(bold(str(vmin))), italic(bold(str(vmax)))) else: if vmin is not None: if inclusive: txt += " " + translate("ParameterPanel", "not less than") else: txt += " " + translate("ParameterPanel", "greater than") txt += " " + italic(bold(str(vmin))) if vmax is not None: if len(txt): txt += " " + translate("ParameterPanel", "and") if inclusive: txt += " " + translate("ParameterPanel", "not greater than") else: txt += " " + translate("ParameterPanel", "less than") txt += " " + italic(bold(str(vmax))) return txt
def _update(self): """Update action's state - tooltip and statustip.""" if self.menu().lastItem() and self._message: tip = self._message % self.menu().lastItem() self.setStatusTip(tip) if self._shortcut_hint: tip = "{0} ({1})".format(tip, bold(self._shortcut_hint)) tip = preformat(tip) self.setToolTip(tip) else: if self._tooltip: self.setToolTip(self._tooltip) if self._statustip: self.setStatusTip(self._statustip)
def get_object_info(obj, **kwargs): """ Get object info to be displayed in tooltip. Arguments: obj (Node): Data model node. **kwargs: Arbitrary keyword arguments: Returns: str: Object's info. """ node_type = get_node_type(obj) info = NodeType.value2str(node_type) if node_type == NodeType.Command: info += ": " if obj.type is None: name = translate("AsterStudy", "[noname]") else: name = obj.name info += bold(name) cata = obj.title title = translate_command(cata) tip = " ({title} / {name})" if title != cata else " ({name})" info += tip.format(title=italic(title), name=cata) if kwargs.get('with_parent_stage', False): info += "<br>" st_name = bold(obj.stage.name) info += translate("AsterStudy", "From stage: {}").format(st_name) elif node_type == NodeType.Comment: info += ":<br>" content = obj.content.split("\n") content = [" # " + i for i in content] info += italic("\n".join(content)) elif node_type == NodeType.Variable: info += ": " info += bold(obj.name) info += " ({})".format(italic(obj.expression)) elif node_type == NodeType.Case: info += ": " info += bold(obj.name) if obj.description: info += "\n\n" info += obj.description elif node_type != NodeType.History: info += ": " info += bold(obj.name) if node_type in [ NodeType.Case, NodeType.Stage, NodeType.Category, NodeType.Command ]: validity = Validity.value2str(obj.check()) if validity: info += "<br>" info += font("Invalid:", color="#ff0000") info += ", ".join([bold(i.strip()) for i in validity.split(",")]) info = preformat(info) return info
def __init__(self, hostsName, cmdlinesName, expName, kleeCmdName, coverableName, uid=None, uidprefix="test", debugcomm=False, duration=DEFAULT_EXP_DURATION, balancetout=None, strategy=None, subprocKill=True, basePort=DEFAULT_BASE_PORT): self.hosts, self.localhost = readHosts(hostsName) self.cmdlines = readCmdlines(cmdlinesName) self.exp = readExp(expName) self.kleeCmd = readKleeCmd(kleeCmdName) self.coverable = getCoverablePath(coverableName) self.uid = uid if uid else self._generateUID(uidprefix) self.debugcomm = debugcomm self.starttime = None self.duration = duration self.balancetout = balancetout self.strategy = strategy self.subprocKill = subprocKill self.basePort = basePort self._logMsg("Using experiment name: %s" % bold(self.uid)) self._logMsg("Using as localhost: %s" % self.localhost["host"])
cwd = os.getcwd() rel = lambda p: os.path.relpath(p, cwd) # NOQA root_ca_path = ca_storage.path(certs["root"]["pub_filename"]) child_ca_path = ca_storage.path(certs["child"]["pub_filename"]) root_cert_path = ca_storage.path(certs["root-cert"]["pub_filename"]) child_cert_path = ca_storage.path(certs["child-cert"]["pub_filename"]) ocsp_url = "%s%s" % ( args.base_url.rstrip("/"), reverse("django_ca:ocsp-cert-post", kwargs={"serial": certs["child"]["serial"]}), ) print("") print("* All certificates are in %s." % bold(ca_settings.CA_DIR)) ok("* Start webserver with the admin interface:") print(' * Run "%s"' % bold("python ca/manage.py runserver")) print(" * Visit %s" % bold("%sadmin/" % args.base_url)) print(" * User/Password: %s / %s" % (bold("user"), bold("nopass"))) ok("* Create CRLs with:") print(" * %s" % bold("python ca/manage.py dump_crl -f PEM --ca %s > root.crl" % loaded_cas["root"].serial[:11])) print(" * %s" % bold("python ca/manage.py dump_crl -f PEM --ca %s > child.crl" % loaded_cas["child"].serial[:11])) ok("* Verify with CRL:") print(" * %s" % bold("openssl verify -CAfile %s -CRLfile root.crl -crl_check %s" % (rel(root_ca_path), rel(root_cert_path))))
ca_storage.save('child-chain.pem', ContentFile(chain))) cwd = os.getcwd() rel = lambda p: os.path.relpath(p, cwd) # NOQA root_ca_path = ca_storage.path(certs['root']['pub_filename']) child_ca_path = ca_storage.path(certs['child']['pub_filename']) root_cert_path = ca_storage.path(certs['root-cert']['pub_filename']) child_cert_path = ca_storage.path(certs['child-cert']['pub_filename']) ocsp_url = '%s%s' % (args.base_url.rstrip('/'), reverse('django_ca:ocsp-cert-post', kwargs={'serial': certs['child']['serial']})) print("") print('* All certificates are in %s.' % bold(ca_settings.CA_DIR)) ok('* Start webserver with the admin interface:') print(' * Run "%s"' % bold('python ca/manage.py runserver')) print(' * Visit %s' % bold('%sadmin/' % args.base_url)) print(' * User/Password: %s / %s' % (bold('user'), bold('nopass'))) ok('* Create CRLs with:') print(' * %s' % bold('python ca/manage.py dump_crl -f PEM --ca %s > root.crl' % loaded_cas['root'].serial[:11])) print(' * %s' % bold('python ca/manage.py dump_crl -f PEM --ca %s > child.crl' % loaded_cas['child'].serial[:11])) ok('* Verify with CRL:') print(' * %s' % bold('openssl verify -CAfile %s -CRLfile root.crl -crl_check %s' % (rel(root_ca_path), rel(root_cert_path))))
def decorate_special(self, text): """Redefined from *ExportToCommVisitor*.""" return bold(text)
def decorate_keyword(self, text): """Redefined from *ExportToCommVisitor*.""" self._something[-1] = True return '<br>' + Visitor.Indent * self._level + bold(text)
def updateTranslations(self): """ Update translation. """ if not self.isVisible(): return path = self.path() name = path.name() command = path.command() # get business-oriented translation if present and set label's text if name.isdigit(): self._titlelabel.setText("[%s]" % name) name = path.parentPath().name() translation = Options.translate_command(command.title, name) else: translation = Options.translate_command(command.title, name) self._titlelabel.setText(translation) # compute tooltip / what's this base info if translation != name: wttext = italic(translation) + " ({})".format(bold(name)) else: wttext = bold(name) wttext = preformat(wttext) # set content contstr = "" if self.contentsMode() != "none" and \ self.contentsValue() is not None: contstr = self._contentsText(self.path()) self._contentslabel.setText(contstr) self._contentslabel.setVisible(len(self._contentslabel.text()) > 0) # set tooltip tooltip = wttext if debug_mode(): tooltip += "<br>" tooltip += path.path() contstr = "" if self.contentsValue() is not None: contstr = self._contentsText(self.path(), None, "parameters") if len(contstr) > 0: tooltip += "<hr>" + contstr self.setToolTip(tooltip) # set what's this # - add native doc string if present docs = path.keyword().udocstring if len(docs): wttext = wttext + "<hr>" + docs # - add value type and default value information if present typeinfo = self._typeInformation() if len(typeinfo): listinfo = self._listInformation() if len(listinfo): typeinfo += "<br>" + listinfo wttext = wttext + "<hr>" + typeinfo definfo = self._defaultInformation() if len(definfo): wttext = wttext + "<br>" + definfo # - add rules description if present rules = self.rules() if rules is not None and len(rules) > 0: rulelines = [] for rule in rules: # translate rule line = bold(translate_rule(rule.itemName())) kw_list = [] for kword in rule.ruleKeywords(): if name == kword: kw_list.append(font(kword, color="#0000ff")) else: kw_list.append(kword) line = line + ": " + ", ".join(kw_list) rulelines.append(line) wttext = wttext + "<hr>" + "<br>".join(rulelines) # - finally assign what's this info self.setWhatsThis(wttext)