def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] if checkPermission('org.ict_ok.admin_utils.esx_vim.Admin', self.context) and\ zapi.queryMultiAdapter((self.context, self.request), name='shutdown.html') is not None: tmpDict = {} tmpDict['oid'] = u"c%sshutdown" % objId tmpDict['title'] = _(u"shutdown") tmpDict['href'] = u"%s/@@shutdown.html" % \ zapi.getPath(self.context) tmpDict['tooltip'] = _(u"shutdow the virtual machine") retList.append(tmpDict) if checkPermission('org.ict_ok.admin_utils.esx_vim.Admin', self.context) and\ zapi.queryMultiAdapter((self.context, self.request), name='convertobj.html') is not None: tmpDict = {} tmpDict['oid'] = u"c%sconvertobj" % objId tmpDict['title'] = _(u"convert to intern") tmpDict['href'] = u"%s/@@convertobj.html" % \ zapi.getPath(self.context) tmpDict['tooltip'] = _(u"convert to internal object") retList.append(tmpDict) return retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except: objId = 1000 retList = [] if appsetup.getConfigContext().hasFeature('devmode') and \ checkPermission('org.ict_ok.components.host.Edit', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%strigger_online" % objId tmpDict['title'] = _(u"Trigger online") tmpDict['href'] = u"%s/@@trigger_online?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c%strigger_offline" % objId tmpDict['title'] = _(u"Trigger offline") tmpDict['href'] = u"%s/@@trigger_offline?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c%strigger_not1" % objId tmpDict['title'] = _(u"Trigger notification1") tmpDict['href'] = u"%s/@@trigger_not1?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) return retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] if checkPermission('org.ict_ok.admin_utils.compliance.generate.pdf', self.context): tmpDict = {} tmpDict['oid'] = u"c%sgenerate_all_pdf" % objId tmpDict['title'] = _(u"generate all pdf") tmpDict['href'] = u"%s/@@generate_all_pdf" % \ (zapi.getPath(self.context)) tmpDict['tooltip'] = _(u"will generate a all pdf file") retList.append(tmpDict) if checkPermission('org.ict_ok.admin_utils.compliance.Import', self.context): tmpDict = {} tmpDict['oid'] = u"c%simport requirements" % objId tmpDict['title'] = _(u"import requirements") tmpDict['href'] = u"%s/@@import_requirements" % \ (zapi.getPath(self.context)) tmpDict['tooltip'] = _(u"will import requirements") retList.append(tmpDict) return retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except: objId = 1000 retList = [] if appsetup.getConfigContext().hasFeature('devmode') and \ checkPermission('org.ict_ok.components.host.Edit', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%sshutdownHost" % objId tmpDict['title'] = _(u"shutdown host") tmpDict['href'] = u"%s/@@shutdownHost.html?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c%senterMaintenanceMode" % objId tmpDict['title'] = _(u"enter maintenance mode") tmpDict['href'] = u"%s/@@enterMaintenanceMode.html?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) return SuperHostDetails.actions(self) + retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] adapSize = ISized(self.context) if checkPermission('org.ict_ok.admin_utils.supervisor.ReindexDB', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%sreindex_db" % objId tmpDict['title'] = _(u"reindex database") tmpDict['href'] = u"%s/@@reindex_db?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) tmpDict['tooltip'] = _(u"will reindex the catalogs of all "\ u"tables in database") retList.append(tmpDict) if checkPermission('org.ict_ok.admin_utils.supervisor.PackDB', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%spack_db" % objId tmpDict['title'] = _(u"pack database") tmpDict['href'] = u"%s/@@pack_db?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) tmpDict['tooltip'] = _(u"will pack the database and delete "\ u"all backups") retList.append(tmpDict) return retList
def sendPing(self): """ send ping request """ mq_utility = zapi.getUtility(IAdmUtilObjMQ) my_data = {'cmd': 'ping', 'nodename': unicode(self.getNodeName())} if self.isMaster() and not self.isSlave(): my_data['header'] = {'from_oid': self.objectID, 'from_ip': self.ipv4My, 'from_path': getPath(self), 'to_oid': self.oidSlave, 'to_ip': self.ipv4Slave, 'to_path': u"/++etc++site/default"+\ "/AdmUtilSupervisor" } print "sendPing: %s" % my_data mq_utility.sendPerMq(my_data) if self.isSlave() and not self.isMaster(): my_data['header'] = {'from_oid': self.objectID, 'from_ip': self.ipv4My, 'from_path': getPath(self), 'to_oid': self.oidMaster, 'to_ip': self.ipv4Master, 'to_path': u"/++etc++site/default"+\ "/AdmUtilSupervisor" } print "sendPing: %s" % my_data mq_utility.sendPerMq(my_data)
def cmd(self): """ commnds for objmq """ #obj = removeAllProxies(self.context) obj = self.context print "cmd/objmq" print "path: %s" % (zapi.getPath(obj)) action = self.request.get('cmd', default=None) if action: if action == 'start': obj.status2Master = u"connecting" #print "start" #print "obj.oidSlave: %s" % (obj.oidSlave) #obj.appendSlaveUid(u"bc6ae87821e43509dc3a5152a030951b0") #print "dir(obj.oidSlave): %s" % dir(obj.oidSlave) #print "obj.oidSlave: %s" % (obj.oidSlave) mq_utility = zapi.getUtility(IAdmUtilObjMQ) my_data = { 'cmd': 'connect', 'nodename': unicode(obj.getNodeName()) } my_data['header'] = {'from_oid': obj.objectID, 'from_ip': obj.ipv4My, 'from_path': getPath(obj), 'to_oid': obj.oidMaster, 'to_ip': obj.ipv4Master, 'to_path': u"/++etc++site/default"+\ "/AdmUtilSupervisor" } mq_utility.sendPerMq(my_data) #python_pickle = pickle.dumps(my_data) ##print "toxml: %s" % toxml(python_pickle) #mq_utility.sendPerMq(toxml(python_pickle)) #mq_utility = zapi.getUtility(IMailDelivery, 'ikObjTransportQueue') #from_adr = u"http://%s@%s:8080%s" % \ #(obj.objectID, obj.ipv4My, zapi.getPath(obj)) #to_adr = u"http://%s@%s:8080/++etc++site/default/AdmUtilSupervisor" % \ #(str(obj.oidMaster), str(obj.ipv4Master)) #mq_utility.send(from_adr, [to_adr], "msg_start") elif action == 'stop': print "stop" mq_utility = zapi.getUtility(IMailDelivery, 'ikObjTransportQueue') from_adr = u"http://%s@%s:8080%s" % \ (obj.objectID, obj.ipv4My, zapi.getPath(obj)) to_adr = u"http://%s@%s:8080/++etc++site/"+\ "default/AdmUtilSupervisor" % \ (str(obj.oidMaster), str(obj.ipv4Master)) mq_utility.send(from_adr, [to_adr], "msg_stop") elif action == 'ping': obj.sendPing() else: pass return self.request.response.redirect('./@@objmq')
def actions(self): """ gives us the action dict of the object """ retList = [] if checkPermission('org.ict_ok.admin_utils.notifier.Edit', self.context): quoter = URLQuote(self.request.getURL()) if self.context.enableConnector: tmpDict = {} #tmpDict['oid'] = u"c%s" % objId tmpDict['oid'] = u"c000stop_connector" tmpDict['title'] = _(u"stop jabber-connector") tmpDict['href'] = u"%s/@@stop_connector?nextURL=%s" % \ (zapi.getPath(self.context), quoter.quote()) tmpDict['tooltip'] = _(u"stops the jabber-connector (as user:%s)"\ % self.request.principal.title) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c000get_isup" tmpDict['title'] = _(u"is jabber-connector up") tmpDict['href'] = u"%s/@@get_isup?nextURL=%s" % \ (zapi.getPath(self.context), quoter.quote()) tmpDict['tooltip'] = _( u"ask the jabber-connector for watchdog") retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c000send_test" tmpDict['title'] = _(u"send test message") tmpDict['href'] = u"%s/@@send_test?nextURL=%s" % \ (zapi.getPath(self.context), quoter.quote()) tmpDict['tooltip'] = _(u"send test message to im-server") retList.append(tmpDict) else: tmpDict = {} #tmpDict['oid'] = u"c%s" % objId tmpDict['oid'] = u"c000start_connector" tmpDict['title'] = _(u"start jabber-connector") tmpDict['href'] = u"%s/@@start_connector?nextURL=%s" % \ (zapi.getPath(self.context), quoter.quote()) tmpDict['tooltip'] = _(u"starts the jabber-connector (as user:%s)"\ % self.request.principal.title) retList.append(tmpDict) #tmpDict = {} #tmpDict['oid'] = u"a12345" #tmpDict['title'] = u"ich bin ein Titel" #tmpDict['href'] = u"http://www.essen.de" #tmpDict['tooltip'] = u"ich bin der \"aa\" 'bb' dazugehörige Tooltip Essen" #retList.append(tmpDict) return retList
def update(self): message = self.applyUpdates() self.configBase = zapi.absoluteURL(zapi.getSiteManager(), self.request) registrations = self.context.info() # This is OK because registrations is just a list of dicts registrations = removeSecurityProxy(registrations) inactive = 1 for info in registrations: if info['active']: inactive = None else: info['active'] = False reg = info['registration'] info['summary'] = reg.implementationSummary() info['id'] = zapi.getPath(reg) # Add a dummy registration since the stack removes trailing None. registrations.append({"active": False, "id": "disable", "summary": ""}) self.inactive = inactive self.registrations = registrations self.message = message
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] adapSize = ISized(self.context) # adapSize.sizeForSorting() returns ('item', n) if checkPermission('org.ict_ok.components.net.Add', self.context) and \ (adapSize.sizeForSorting()[1] < 1): tmpDict = {} tmpDict['oid'] = u"c%sstart_scanner" % objId tmpDict['title'] = _(u"start scanner") tmpDict['href'] = u"%s/@@start_scanner.html" % \ zapi.getPath(self.context) tmpDict['tooltip'] = _(u"starts the network scanner (as user:%s)"\ % self.request.principal.title) retList.append(tmpDict) #tmpDict = {} #tmpDict['oid'] = u"a%s" % objId #tmpDict['title'] = u"ich bin ein Titel" #tmpDict['href'] = u"http://www.essen.de" #tmpDict['tooltip'] = u"ich bin der \"aa\" 'bb' dazugehörige T" #retList.append(tmpDict) return retList
def convertobj(self): """ converts this esx object to an internal object """ print("EsxVimVirtualMachineDetails.convertobj") r_obj = self.context.convertobj() return self.request.response.redirect(zapi.getPath(r_obj)+\ '/@@details.html')
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except: objId = 1000 retList = [] if appsetup.getConfigContext().hasFeature('devmode') and \ checkPermission('org.ict_ok.components.host.Edit', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%strigger_online" % objId tmpDict['title'] = _(u"Trigger online") tmpDict['href'] = u"%s/@@trigger_online?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c%strigger_offline" % objId tmpDict['title'] = _(u"Trigger offline") tmpDict['href'] = u"%s/@@trigger_offline?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) tmpDict = {} tmpDict['oid'] = u"c%strigger_not1" % objId tmpDict['title'] = _(u"Trigger notification1") tmpDict['href'] = u"%s/@@trigger_not1?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) retList.append(tmpDict) adapSize = ISized(self.context) if checkPermission('org.ict_ok.components.interface.Add', self.context) and \ (adapSize.sizeForSorting()[1] < 1): tmpDict = {} tmpDict['oid'] = u"c%sstart_snmp_if_scanner" % objId tmpDict['title'] = _(u"start snmp interface scanner") tmpDict['href'] = u"%s/@@start_snmp_if_scanner.html" % \ zapi.getPath(self.context) tmpDict['tooltip'] = _(u"starts the interface scanner with snmp scan (as user:%s)"\ % self.request.principal.title) retList.append(tmpDict) return retList
def ComponentRegistrationAddSubscriber(componentRegistration, event): """Receive notification of add event.""" component = componentRegistration.component try: dependents = IDependable(component) except TypeError: return objectpath = zapi.getPath(componentRegistration) dependents.addDependent(objectpath)
def CheckDependency(event): object = event.object dependency = IDependable(object, None) if dependency is not None: dependents = dependency.dependents() if dependents: mapping = { "object": zapi.getPath(object), "dependents": ", ".join(dependents) } raise DependencyError(Message(exception_msg, mapping=mapping))
def getNotifierObjs(self): """ get list of Notifier-Tupel (name, obj) """ retList = [] for name, notifier in self.context.getNotifierObjs(): retDict = {} retDict['name'] = name retDict['href'] = zapi.getPath(notifier) + '/@@status' retList.append(retDict) return retList
def isExpanded(self, topic): if topic.parentPath: path = zapi.joinPath(topic.parentPath, topic.id) else: path = topic.id try: if zapi.getPath(self.context).startswith('/' + path): return True except: # TODO: fix it, functional test doesn't like zapi.getPath? ri pass return False
def test_ensureUtilityForSubSite(self): self.createRFAndSM() db, connection, root, root_folder = getInformationFromEvent( EventStub(self.db)) sub_folder = root_folder['sub_folder'] ensureUtility(sub_folder, IErrorReportingUtility, 'ErrorReporting', ErrorReportingUtility, 'ErrorReporting') # Make sure it was created on the sub folder, not the root folder got_utility = zapi.getUtility(IErrorReportingUtility, name='ErrorReporting', context=sub_folder) got_path = zapi.getPath(got_utility) self.assertEquals("/sub_folder/++etc++site/default/ErrorReporting", got_path)
def SimpleRegistrationRemoveSubscriber(registration, event): """Receive notification of remove event.""" sm = zapi.getSiteManager(registration) removed = event.object if (sm == removed) or inside(sm, removed): # we don't really care if the registration is active, since the site # is going away. return objectstatus = registration.status if objectstatus == interfaces.ActiveStatus: try: objectpath = zapi.getPath(registration) except: # XXX objectpath = str(registration) raise DependencyError("Can't delete active registration (%s)" % objectpath)
def applyUpdates(self): message = '' if 'submit_update' in self.request.form: id = self.request.form.get(self.name) if id == "disable": active = self.context.active() if active is not None: self.context.activate(None) message = _("Disabled") else: for info in self.context.info(): infoid = zapi.getPath(info['registration']) if infoid == id and not info['active']: self.context.activate(info['registration']) message = _("Updated") break return message
def __call__(self): """See zope.app.browser.interfaces.form.IBrowserWidget""" # Render as a link to the component field = self.context context = field.context if interfaces.registration.IRegistration.providedBy(context): # It's a registration object. Just get the corresponding attr component = getattr(context, field.__name__) path = zapi.getPath(component) else: # It must be a component that is about to be configured. component = context # Always use a relative path (just the component name) path = zapi.name(context) url = zapi.absoluteURL(component, self.request) return ('<a href="%s/@@SelectedManagementView.html">%s</a>' % (url, path))
def SimpleRegistrationRemoveSubscriber(registration, event): """Receive notification of remove event.""" sm = zapi.getSiteManager(registration) removed = event.object if (sm == removed) or inside(sm, removed): # we don't really care if the registration is active, since the site # is going away. return objectstatus = registration.status if objectstatus == interfaces.ActiveStatus: try: objectpath = zapi.getPath(registration) except: # TODO decide if this is really the best fall-back plan objectpath = str(registration) msg = _("Can't delete active registration (${path})", mapping={u'path': objectpath}) raise DependencyError(msg)
def notifyModifiedEvent(instance, event): supervisor = queryUtility(IAdmUtilSupervisor, context=instance) if supervisor and supervisor.isSlave(): if hasattr(event.object, "getObjectId"): objectOid = event.object.getObjectId() else: objectOid = None mq_utility = queryUtility(IAdmUtilObjMQ) recPickle = IPickle(event.object) if mq_utility and supervisor and recPickle: my_data = {'cmd': 'obj_modified', 'obj': recPickle.exportAsDict()} my_data['header'] = {'from_oid': supervisor.objectID, 'from_ip': supervisor.ipv4My, 'from_path': getPath(supervisor), 'to_oid': supervisor.oidMaster, 'to_ip': supervisor.ipv4Master, 'to_path': u"/++etc++site/default"+\ "/AdmUtilSupervisor" } mq_utility.sendPerMq(my_data)
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] if checkPermission('org.ict_ok.admin_utils.event.Send', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%ssend_event" % objId tmpDict['title'] = _(u"send it") tmpDict['href'] = u"%s/@@send_event.html?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) tmpDict['tooltip'] = _( u"sends an the event to the list of receivers") retList.append(tmpDict) return retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] if checkPermission('org.ict_ok.admin_utils.notifier.Send', self.context): quoter = URLQuote(self.request.getURL()) tmpDict = {} tmpDict['oid'] = u"c%snotifier_send" % objId tmpDict['title'] = _(u"send test") tmpDict['href'] = u"%s/@@send_test?nextURL=%s" % \ (zapi.getPath( self.context), quoter.quote()) tmpDict['tooltip'] = _(u"will send a test message "\ u"by the selected notifier") retList.append(tmpDict) return retList
def actions(self): """ gives us the action dict of the object """ try: objId = getUtility(IIntIds).getId(self.context) except KeyError: objId = 1000 retList = [] if True: #if checkPermission('org.ict_ok.admin_utils.generators.nagios.View', #self.context) and\ #zapi.queryMultiAdapter((self.context, self.request), #name='shutdown.html') is not None: tmpDict = {} tmpDict['oid'] = u"c%sgenerate" % objId tmpDict['title'] = _(u"generate") tmpDict['href'] = u"%s/generate.html" % \ zapi.getPath(self.context) tmpDict['tooltip'] = _(u"generate nagios cfg") retList.append(tmpDict) return retList
def notifyAddedEvent(instance, event): """ Node was added """ #logger.info(u"supernode.objmq.notifyAddedEvent: event: %s" % event) supervisor = queryUtility(IAdmUtilSupervisor) if supervisor and supervisor.isSlave(): if hasattr(event.object, "getObjectId"): objectOid = event.object.getObjectId() else: objectOid = None if hasattr(event.oldParent, "getObjectId"): oldParentOid = event.oldParent.getObjectId() else: oldParentOid = None if hasattr(event.newParent, "getObjectId"): newParentOid = event.newParent.getObjectId() else: newParentOid = None mq_utility = queryUtility(IAdmUtilObjMQ) recPickle = IPickle(event.object) if mq_utility and supervisor and recPickle: my_data = { 'cmd': 'obj_added', 'oldparent': oldParentOid, 'newparent': newParentOid, 'obj': recPickle.exportAsDict() } my_data['header'] = {'from_oid': supervisor.objectID, 'from_ip': supervisor.ipv4My, 'from_path': getPath(supervisor), 'to_oid': supervisor.oidMaster, 'to_ip': supervisor.ipv4Master, 'to_path': u"/++etc++site/default"+\ "/AdmUtilSupervisor" } mq_utility.sendPerMq(my_data)
def cutObjects(self): """move objects specified in a list of object ids""" request = self.request ids = request.get('ids') if not ids: self.error = _("You didn't specify any ids to cut.") return container_path = zapi.getPath(self.context) # For each item, check that it can be moved; if so, save the # path of the object for later moving when a destination has # been selected; if not movable, provide an error message # explaining that the object can't be moved. items = [] for id in ids: ob = self.context[id] mover = IObjectMover(ob) if not mover.moveable(): m = {"name": id} title = getDCTitle(ob) if title: m["title"] = title self.error = _( "Object '${name}' (${title}) cannot be moved", mapping=m) else: self.error = _("Object '${name}' cannot be moved", mapping=m) return items.append(zapi.joinPath(container_path, id)) # store the requested operation in the principal annotations: clipboard = getPrincipalClipboard(self.request) clipboard.clearContents() clipboard.addItems('cut', items)
def version(self): utilSupervisor = getUtility(IAdmUtilSupervisor) return self.request.response.redirect(\ zapi.getPath(utilSupervisor)+\ '/@@version.html')
def _items(self): """return all items and their path (for testing only!)""" return [(uid, zapi.getPath(ref())) for uid, ref in self.context.items()]
def traverse4DotGeneratorBody(self, \ cfgFile, \ level=0, \ comments=True, signalsOutput=False, recursive=True): """Pre-Text in graphviz dot-file""" if comments: print >> cfgFile, "%s// Body (%s,%d) - SupernodeGenGraphvizDot" \ % ("\t" * level, self.context.__name__, level) print >> cfgFile, '%s"%s" [' % ("\t" * level, self.context.objectID) print >> cfgFile, '%sshape="plaintext",' % ("\t" * (level + 1)) print >> cfgFile, '%sstyle="filled,setlinewidth(0)",' \ % ("\t" * (level + 1)) print >> cfgFile, '%sfillcolor = chartreuse2,' % ("\t" * (level + 1)) print >> cfgFile, '%smargin = 0,' % ("\t" * (level + 1)) print >> cfgFile, '%shref = "%s/@@details.html",' \ % ("\t" * (level + 1), zapi.getPath(self.context)) #print >> cfgFile, '%slabel = <<TABLE BORDER = "0" CELLBORDER = "0" ' \ #'CELLPADDING = "0" CELLSPACING = "0"><TR><TD>' \ #'<IMG SRC = "/home/markus/Projekte/IKOMtrol-hp/apple-red.png"/>' \ #'</TD></TR><TR><TD><FONT FACE = "Arial" POINT-SIZE = "10">%s' \ #'</FONT></TD></TR></TABLE>>' \ #% ("\t" * (level + 1), self.context.ikName) print >> cfgFile, '%slabel = <' % ("\t" * (level + 1)) print >> cfgFile, '%s<TABLE BORDER="0" CELLBORDER="1" CELLPADDING = "2" CELLSPACING = "0">' % ( "\t" * (level + 1)) print >> cfgFile, '%s<TR><TD WIDTH="120px">%s</TD></TR>' % ( "\t" * (level + 1), self.context.ikName) if signalsOutput: allInpNamesDict = self.context.getAllInpEventNames() for inpName in allInpNamesDict.keys(): print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="%s" '\ 'BGCOLOR="yellow">%s</TD></TR>' % \ ("\t" * (level + 1), inpName, inpName) allOutNamesDict = self.context.getAllOutEventNames() for outName in allOutNamesDict.keys(): print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="%s" '\ 'BGCOLOR="orange">%s</TD></TR>' % \ ("\t" * (level + 1), outName, outName) #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp1" BGCOLOR="yellow">sig_inp1</TD></TR>' % ("\t" * (level + 1)) #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp2" BGCOLOR="yellow">sig_inp2</TD></TR>' % ("\t" * (level + 1)) #print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="sig_out1" BGCOLOR="orange">sig_out1</TD></TR>' % ("\t" * (level + 1)) print >> cfgFile, '%s</TABLE>>' % ("\t" * (level + 1)) print >> cfgFile, '%s]; // %s' % ("\t" * level, self.context.__name__) if recursive: its = self.context.items() else: its = [] for (dummy_name, oobj) in its: if ISuperclass.providedBy(oobj): try: adapterGenGraphvizDot = IGenGraphvizDot(oobj) if adapterGenGraphvizDot: adapterGenGraphvizDot.setParent(self.context) adapterGenGraphvizDot.traverse4DotGenerator(\ cfgFile, level + 1, comments, signalsOutput) except TypeError, err: logging.error("Error in AdmUtilGraphviz::getRootDot()"\ % err)
def usages(self): return [zapi.getPath(reg.component) for reg in self.registrations]
def preferences(self): utilUserMagagement = getUtility(IAdmUtilUserManagement) return self.request.response.redirect(\ zapi.getPath(utilUserMagagement)+\ '/@@edit.html')
def __BBB_getComponentPath(self): if self._BBB_componentPath is not None: return self._BBB_componentPath return '/' + '/'.join(zapi.getPath(self.component))
def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context) setUpWidgets(self, schema, IInputWidget, prefix=name + '.field') html = [] # add sub title for source search field html.append('<h4>%s</h4>' % sourcename) # start row for path display field html.append('<div class="row">') # for each source add path of source html.append(' <div class="label">') label = translate(source_label, context=self.request) title = translate(source_title, context=self.request) html.append(' <label for="%s" title="%s">' % (sourcename, title)) html.append(' %s' % label) html.append(' </label>') html.append(' </div>') html.append(' <div class="field">') html.append(' %s' % sourcepath) html.append(' </div>') html.append('</div>') # start row for search fields html.append('<div class="row">') for field_name, field in getFieldsInOrder(schema): widget = getattr(self, field_name + '_widget') # for each field add label... html.append(' <div class="label">') html.append(' <label for="%s" title="%s">' % (widget.name, widget.hint)) html.append(' %s' % widget.label) html.append(' </label>') html.append(' </div>') # ...and field widget html.append(' <div class="field">') html.append(' %s' % widget()) if widget.error(): html.append(' <div class="error">') html.append(' %s' % widget.error()) html.append(' </div>') html.append(' </div>') # end row html.append('</div>') # add search button for search fields html.append('<div class="row">') html.append(' <div class="field">') html.append( ' <input type="submit" name="%s" value="%s" />' % (name + '.search', translate(search_label, context=self.request))) html.append(' </div>') html.append('</div>') return '\n'.join(html)
def getValuePngHref(self): """Url to picture""" obj = removeAllProxies(self.context) return zapi.getPath(obj)
def pt_source_file(self): try: return zapi.getPath(self) except TypeError: return None
def getRrdFilename(self): """ rrd filename incl. path """ data_path = zapi.getPath(self) return "/opt/smokeping/data/%s.rrd" % data_path
def getValuePngHref(self): """get path of object as string """ return zapi.getPath(self.context)
def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context) setUpWidgets(self, schema, IInputWidget, prefix=name+'.field') html = [] # add sub title for source search field html.append('<h4>%s</h4>' % sourcename) # start row for path display field html.append('<div class="row">') # for each source add path of source html.append(' <div class="label">') label = translate(source_label, context=self.request) title = translate(source_title, context=self.request) html.append(' <label for="%s" title="%s">' % (sourcename, title)) html.append(' %s' % label) html.append(' </label>') html.append(' </div>') html.append(' <div class="field">') html.append(' %s' % sourcepath) html.append(' </div>') html.append('</div>') # start row for search fields html.append('<div class="row">') for field_name, field in getFieldsInOrder(schema): widget = getattr(self, field_name+'_widget') # for each field add label... html.append(' <div class="label">') html.append(' <label for="%s" title="%s">' % (widget.name, widget.hint)) html.append(' %s' % widget.label) html.append(' </label>') html.append(' </div>') # ...and field widget html.append(' <div class="field">') html.append(' %s' % widget()) if widget.error(): html.append(' <div class="error">') html.append(' %s' % widget.error()) html.append(' </div>') html.append(' </div>') # end row html.append('</div>') # add search button for search fields html.append('<div class="row">') html.append(' <div class="field">') html.append(' <input type="submit" name="%s" value="%s" />' % (name+'.search', translate(search_label, context=self.request))) html.append(' </div>') html.append('</div>') return '\n'.join(html)
def getValuePngHref(self): """get path of object as string """ obj = removeAllProxies(self.context) return zapi.getPath(obj)
def getValuePngHref(self): """Url to picture""" obj = self.context return zapi.getPath(obj)
def getLocationForCache(obj): """Returns the location to be used for caching the object or ``None``.""" try: return zapi.getPath(obj) except (ComponentLookupError, TypeError): return None