rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def registerTimerCbFun(self, timerCbFun): self.__timerCbFuns.append(timerCbFun) | def registerTimerCbFun(self, timerCbFun, tickInterval=1.0): self.__timerCallables.append(TimerCallable(timerCbFun, tickInterval)) | def registerTimerCbFun(self, timerCbFun): self.__timerCbFuns.append(timerCbFun) |
self.__timerCbFuns = [] | self.__timerCallables = [] | def unregisterTimerCbFun(self, timerCbFun=None): if timerCbFun is None: self.__timerCbFuns = [] else: self.__timerCbFuns.remove(timerCbFun) |
self.__timerCbFuns.remove(timerCbFun) | self.__timerCallables.remove(timerCbFun) | def unregisterTimerCbFun(self, timerCbFun=None): if timerCbFun is None: self.__timerCbFuns = [] else: self.__timerCbFuns.remove(timerCbFun) |
if self.__timerCbFuns and self.__timeToGo < timeNow: for timerCbFun in self.__timerCbFuns: timerCbFun(timeNow) self.__timeToGo = timeNow + 1 | for timerCallable in self.__timerCallables: timerCallable(timeNow) | def handleTimerTick(self, timeNow): if self.__timerCbFuns and self.__timeToGo < timeNow: for timerCbFun in self.__timerCbFuns: timerCbFun(timeNow) self.__timeToGo = timeNow + 1 |
salt = string.join(map(lambda x: chr(x), salt), '') | salt = string.join(map(chr, salt), '') | def __getEncryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime): salt = [ self._localInt>>56&0xff, self._localInt>>48&0xff, self._localInt>>40&0xff, self._localInt>>32&0xff, self._localInt>>24&0xff, self._localInt>>16&0xff, self._localInt>>8&0xff, self._localInt&0xff ] if self._localInt == 0xffffffffffffffffL: self._localInt = 0 else: self._localInt = self._localInt + 1 |
ord(salt[7]), | ord(salt[0]), ord(salt[1]), ord(salt[2]), ord(salt[3]), ord(salt[4]), ord(salt[5]), | def __getDecryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime, salt): snmpEngineBoots, snmpEngineTime, salt = ( long(snmpEngineBoots), long(snmpEngineTime), str(salt) ) |
ord(salt[5]), ord(salt[4]), ord(salt[3]), ord(salt[2]), ord(salt[1]), ord(salt[0]) | ord(salt[7]) | def __getDecryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime, salt): snmpEngineBoots, snmpEngineTime, salt = ( long(snmpEngineBoots), long(snmpEngineTime), str(salt) ) |
return privKey[:16], string.join(map(lambda x: chr(x), iv), '') | return privKey[:16], string.join(map(chr, iv), '') | def __getDecryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime, salt): snmpEngineBoots, snmpEngineTime, salt = ( long(snmpEngineBoots), long(snmpEngineTime), str(salt) ) |
snmpEngineBoots, snmpEngineTime, salt = privParameters | def encryptData(self, encryptKey, privParameters, dataToEncrypt): if AES is None: raise error.StatusInformation( errorIndication='encryptionError' ) | |
aesObj = AES.new(aesKey, AES.MODE_CFB, iv) | aesObj = AES.new(aesKey, AES.MODE_CFB, iv, segment_size=128) dataToEncrypt = dataToEncrypt + '\0' * (16-len(dataToEncrypt)%16) | def encryptData(self, encryptKey, privParameters, dataToEncrypt): if AES is None: raise error.StatusInformation( errorIndication='encryptionError' ) |
return univ.OctetString(ciphertext), salt | return univ.OctetString(ciphertext), univ.OctetString(salt) | def encryptData(self, encryptKey, privParameters, dataToEncrypt): if AES is None: raise error.StatusInformation( errorIndication='encryptionError' ) |
aesObj = AES.new(aesKey, AES.MODE_CFB, iv) | aesObj = AES.new(aesKey, AES.MODE_CFB, iv, segment_size=128) encryptedData = encryptedData + '\0' * (16-len(encryptedData)%16) | def decryptData(self, decryptKey, privParameters, encryptedData): if AES is None: raise error.StatusInformation( errorIndication='decryptionError' ) |
try: maxSizeResponseScopedPDU = maxMessageSize - len(securityParameters) - 48 except PyAsn1Error: maxSizeResponseScopedPDU = 0 | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) | |
securityEngineID = securityParameters.getComponentByPosition(0) | msgAuthoritativeEngineID = securityParameters.getComponentByPosition(0) | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
if not self.__timeline.has_key(securityEngineID): debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unknown securityEngineID %s' % repr(securityEngineID)) if securityEngineID: self.__timeline[securityEngineID] = ( securityParameters.getComponentByPosition(1), securityParameters.getComponentByPosition(2), securityParameters.getComponentByPosition(2), int(time.time()) ) expireAt = self.__expirationTimer + 300 if not self.__timelineExpQueue.has_key(expireAt): self.__timelineExpQueue[expireAt] = [] self.__timelineExpQueue[expireAt].append(securityEngineID) debug.logger & debug.flagSM and debug.logger('processIncomingMsg: store timeline for securityEngineID %s' % repr(securityEngineID)) else: | if not self.__timeline.has_key(msgAuthoritativeEngineID): debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unknown securityEngineID %s' % repr(msgAuthoritativeEngineID)) if not msgAuthoritativeEngineID: | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
msgAuthoritativeEngineID = securityParameters.getComponentByPosition(0) | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) | |
securityEngineID, | msgAuthoritativeEngineID, | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unknown securityEngineID %s msgUserName %s' % (repr(securityEngineID), msgUserName)) | debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unknown securityEngineID %s msgUserName %s' % (repr(msgAuthoritativeEngineID), msgUserName)) | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
if self.__timeline.has_key(securityEngineID): | if self.__timeline.has_key(msgAuthoritativeEngineID): | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
if not msgUserName and not securityEngineID: | if not msgUserName and not msgAuthoritativeEngineID: | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
securityEngineID=securityEngineID, | securityEngineID=msgAuthoritativeEngineID, | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
return ( securityEngineID, | return ( msgAuthoritativeEngineID, | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
k = transportTarget, tagList | k = paramsName, transportTarget, tagList | def cfgCmdGen(self, authData, transportTarget, tagList=''): if self.__knownAuths.has_key(authData): paramsName = self.__knownAuths[authData] else: paramsName = 'p%s' % nextID() if isinstance(authData, CommunityData): config.addV1System( self.snmpEngine, authData.securityName, authData.communityName ) config.addTargetParams( self.snmpEngine, paramsName, authData.securityName, authData.securityLevel, authData.mpModel ) elif isinstance(authData, UsmUserData): config.addV3User( self.snmpEngine, authData.securityName, authData.authProtocol, authData.authKey, authData.privProtocol, authData.privKey ) config.addTargetParams( self.snmpEngine, paramsName, authData.securityName, authData.securityLevel ) else: raise error.PySnmpError('Unsupported SNMP version') self.__knownAuths[authData] = paramsName |
N = min(nonRepeaters, len(reqVarBinds)) | N = min(int(nonRepeaters), len(reqVarBinds)) | def _handleManagementOperation(self, snmpEngine, contextMibInstrumCtl, PDU, (acFun, acCtx)): nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(PDU) if nonRepeaters < 0: nonRepeaters = 0 maxRepetitions = v2c.apiBulkPDU.getMaxRepetitions(PDU) if maxRepetitions < 0: maxRepetitions = 0 reqVarBinds = v2c.apiPDU.getVarBinds(PDU) |
if nonRepeaters: | if N: | def _handleManagementOperation(self, snmpEngine, contextMibInstrumCtl, PDU, (acFun, acCtx)): nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(PDU) if nonRepeaters < 0: nonRepeaters = 0 maxRepetitions = v2c.apiBulkPDU.getMaxRepetitions(PDU) if maxRepetitions < 0: maxRepetitions = 0 reqVarBinds = v2c.apiPDU.getVarBinds(PDU) |
reqVarBinds[:int(nonRepeaters)], (acFun, acCtx) | reqVarBinds[:N], (acFun, acCtx) | def _handleManagementOperation(self, snmpEngine, contextMibInstrumCtl, PDU, (acFun, acCtx)): nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(PDU) if nonRepeaters < 0: nonRepeaters = 0 maxRepetitions = v2c.apiBulkPDU.getMaxRepetitions(PDU) if maxRepetitions < 0: maxRepetitions = 0 reqVarBinds = v2c.apiPDU.getVarBinds(PDU) |
if M and R: for i in range(N, R): varBind = reqVarBinds[i] for r in range(1, M): rspVarBinds.extend(contextMibInstrumCtl.readNextVars( (varBind,), (acFun, acCtx) )) varBind = rspVarBinds[-1] if len(rspVarBinds) > self.maxVarBinds: rspVarBinds = rspVarBinds[:self.maxVarBinds] return 0, 0, rspVarBinds | varBinds = reqVarBinds[-R:] while M and R: rspVarBinds.extend( contextMibInstrumCtl.readNextVars(varBinds, (acFun, acCtx)) ) varBinds = rspVarBinds[-R:] M = M - 1 if len(rspVarBinds): return 0, 0, rspVarBinds else: raise pysnmp.smi.error.SmiError() | def _handleManagementOperation(self, snmpEngine, contextMibInstrumCtl, PDU, (acFun, acCtx)): nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(PDU) if nonRepeaters < 0: nonRepeaters = 0 maxRepetitions = v2c.apiBulkPDU.getMaxRepetitions(PDU) if maxRepetitions < 0: maxRepetitions = 0 reqVarBinds = v2c.apiPDU.getVarBinds(PDU) |
errorStatus, errorIndex = 'genErr', errorIndication.get('idx',-1)+1 | errorStatus, errorIndex = 'genErr', len(varBinds) and 1 or 0 | def processPdu( self, snmpEngine, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, maxSizeResponseScopedPDU, stateReference ): |
debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: local user usmUserName %s usmUserAuthProtocol %s usmUserPrivProtocol %s by securityEngineID %s securityName %s' % (usmUserName, usmUserAuthProtocol, usmUserPrivProtocol, repr(securityEngineID), securityName)) | debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: local user usmUserName %s usmUserAuthProtocol %s usmUserPrivProtocol %s securityEngineID %s securityName %s' % (usmUserName, usmUserAuthProtocol, usmUserPrivProtocol, repr(securityEngineID), securityName)) | def __generateRequestOrResponseMsg( self, snmpEngine, messageProcessingModel, globalData, maxMessageSize, securityModel, securityEngineID, securityName, securityLevel, scopedPDU, securityStateReference ): snmpEngineID = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax # 3.1.1 if securityStateReference is not None: # 3.1.1a cachedSecurityData = self._cachePop(securityStateReference) usmUserName = cachedSecurityData['msgUserName'] usmUserAuthProtocol = cachedSecurityData.get('usmUserAuthProtocol') usmUserAuthKeyLocalized = cachedSecurityData.get( 'usmUserAuthKeyLocalized' ) usmUserPrivProtocol = cachedSecurityData.get('usmUserPrivProtocol') usmUserPrivKeyLocalized = cachedSecurityData.get( 'usmUserPrivKeyLocalized' ) securityEngineID = snmpEngineID debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: user info read from cache') elif securityName: # 3.1.1b try: ( usmUserName, usmUserAuthProtocol, usmUserAuthKeyLocalized, usmUserPrivProtocol, usmUserPrivKeyLocalized ) = self.__getUserInfo( snmpEngine.msgAndPduDsp.mibInstrumController, securityEngineID, securityName ) debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: read user info') except NoSuchInstanceError: pysnmpUsmDiscovery, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__PYSNMP-USM-MIB', 'pysnmpUsmDiscovery') __reportUnknownName = not pysnmpUsmDiscovery.syntax if not __reportUnknownName: try: ( usmUserName, usmUserAuthProtocol, usmUserAuthKeyLocalized, usmUserPrivProtocol, usmUserPrivKeyLocalized ) = self.__cloneUserInfo( snmpEngine.msgAndPduDsp.mibInstrumController, securityEngineID, securityName ) except NoSuchInstanceError: __reportUnknownName = 1 |
debug.logger & debug.flagSM and debug.logger('processIncomingMsg: cache read securityStateReference %s by msgUserName %s' % (securityStateReference, securityParameters.getComponentByPosition(3))) | debug.logger & debug.flagSM and debug.logger('processIncomingMsg: cache write securityStateReference %s by msgUserName %s' % (securityStateReference, securityParameters.getComponentByPosition(3))) | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) |
self._cachePop(securityStateReference) securityStateReference = self._cachePush( msgUserName=securityParameters.getComponentByPosition(3), usmUserAuthProtocol=usmUserAuthProtocol, usmUserAuthKeyLocalized=usmUserAuthKeyLocalized, usmUserPrivProtocol=usmUserPrivProtocol, usmUserPrivKeyLocalized=usmUserPrivKeyLocalized ) | def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' ) | |
errorStatus, errorIndex = 'genErr', 1 | errorStatus, errorIndex = 'genErr', errorIndication.get('idx',-1)+1 | def processPdu( self, snmpEngine, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, maxSizeResponseScopedPDU, stateReference ): |
else: v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) | v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) | def v1ToV2(v1Pdu, origV2Pdu=None): pduType = v1Pdu.tagSet v2Pdu = __v1ToV2PduMap[pduType].clone() v2c.apiPDU.setDefaults(v2Pdu) debug.logger & debug.flagPrx and debug.logger('v1ToV2: v1Pdu %s' % v1Pdu.prettyPrint()) v2VarBinds = [] # 3.1 if rfc3411.notificationClassPDUs.has_key(pduType): # 3.1.1 sysUpTime = v1.apiTrapPDU.getTimeStamp(v1Pdu) # 3.1.2 genericTrap = v1.apiTrapPDU.getGenericTrap(v1Pdu) if genericTrap == 6: snmpTrapOIDParam = v1.apiTrapPDU.getEnterprise(v1Pdu) + (0,) + \ (v1.apiTrapPDU.getSpecificTrap(v1Pdu),) # 3.1.3 else: snmpTrapOIDParam = v2c.ObjectIdentifier( __v1ToV2TrapMap[genericTrap] ) v2VarBinds.append((v2c.apiTrapPDU.sysUpTime, sysUpTime)) v2VarBinds.append((v2c.apiTrapPDU.snmpTrapOID, snmpTrapOIDParam)) v2VarBinds.append((v2c.apiTrapPDU.snmpTrapEnterprise, v1.apiTrapPDU.getEnterprise(v1Pdu))) # 3.1.4 v2VarBinds.append( (v2c.apiTrapPDU.snmpTrapAddress, v1.apiTrapPDU.getAgentAddr(v1Pdu)) ) varBinds = v1.apiTrapPDU.getVarBinds(v1Pdu) else: varBinds = v1.apiPDU.getVarBinds(v1Pdu) # Translate Var-Binds for oid, v1Val in varBinds: # 2.1.1.11 if v1Val.tagSet == v1.NetworkAddress.tagSet: v1Val = v1Val.getComponent() v2VarBinds.append( (oid, __v1ToV2ValueMap[v1Val.tagSet].clone(v1Val)) ) if rfc3411.responseClassPDUs.has_key(pduType): # 4.1.2.2.1&2 errorStatus = int(v1.apiPDU.getErrorStatus(v1Pdu)) errorIndex = int(v1.apiPDU.getErrorIndex(v1Pdu)) if errorStatus == 2: # noSuchName if origV2Pdu.tagSet == v2c.GetNextRequestPDU.tagSet: v2VarBinds[errorIndex-1] = ( v2VarBinds[errorIndex-1][0], exval.endOfMib ) else: v2VarBinds[errorIndex-1] = ( v2VarBinds[errorIndex-1][0], exval.noSuchObject ) else: # one-to-one mapping v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) # 4.1.2.1 --> no-op if not rfc3411.notificationClassPDUs.has_key(pduType): v2c.apiPDU.setRequestID(v2Pdu, long(v1.apiPDU.getRequestID(v1Pdu))) v2c.apiPDU.setVarBinds(v2Pdu, v2VarBinds) debug.logger & debug.flagPrx and debug.logger('v1ToV2: v2Pdu %s' % v2Pdu.prettyPrint()) return v2Pdu |
ringBuffer = passphrase * (64/len(passphrase)+1) | ringBuffer = passphrase * (passphrase and (64/len(passphrase)+1) or 1) | def hashPassphraseMD5(passphrase): md = md5() ringBuffer = passphrase * (64/len(passphrase)+1) ringBufferLen = len(ringBuffer) count = 0 mark = 0 while count < 16384: e = mark + 64 if e < ringBufferLen: md.update(ringBuffer[mark:e]) mark = e else: md.update( ringBuffer[mark:ringBufferLen] + ringBuffer[0:e-ringBufferLen] ) mark = e-ringBufferLen count = count + 1 return md.digest() |
contextMibInstrumCtl = self.snmpContext.getMibInstrum(contextName) | def processPdu( self, snmpEngine, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, maxSizeResponseScopedPDU, stateReference ): | |
snmpEngine, contextMibInstrumCtl, PDU, | snmpEngine, self.snmpContext.getMibInstrum(contextName), PDU, | def processPdu( self, snmpEngine, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, maxSizeResponseScopedPDU, stateReference ): |
errorIndication = self.asyncSendNotification( | self.asyncSendNotification( | def __cbFun(sendRequestHandle, errorIndication, appReturn): appReturn['errorIndication'] = errorIndication |
if errorIndication: return errorIndication | def __cbFun(sendRequestHandle, errorIndication, appReturn): appReturn['errorIndication'] = errorIndication | |
testExample(id='1',path="FiniteElasticity/CylinderInflation",nodes='2',input='\n',ndiffDir="expected_results/2proc",outputDir="./outputs") | testExample(id='2',path="FiniteElasticity/CylinderInflation",nodes='2',ndiffDir="expected_results/2proc",outputDir="./outputs") | def htmlWrapper(infile, outfile) : stext1 = "<"; stext2 = ">"; rtext1 = "<"; rtext2 = ">"; input = sys.stdin output = sys.stdout input = open(infile) output = open(outfile, 'w') insertTag("<pre>",output) for s in input.xreadlines(): output.write(s.replace(stext1, rtext1).replace(stext2,rtext2)) insertTag("</pre>",output) output.close() |
elif err==0 : | else : | def add_history(historyPath,err) : global hostname if os.path.exists(historyPath) : history = open(historyPath,"a") else : history = open(historyPath,"w") history.write("<pre>Completed Time\t\tStatus\tHostname\n") if err==0 : history.write(strftime("%Y-%m-%d %H:%M:%S")+'\tsuccess\t'+hostname+'\n') elif err==0 : history.write(strftime("%Y-%m-%d %H:%M:%S")+'\tfail\t'+hostname+'\n') history.close() |
testExample(id='1',path="FluidMechanics/Darcy/QuasistaticMaterial",nodes='1',input='\n',expectedFile="expected_results/TIME_STEP_0003.exnode",actualFile="output/TIME_STEP_0003.exnode") | testExample(id='1',path="FluidMechanics/Darcy/QuasistaticMaterial",nodes='1',input='\n',ndiffDir="expected_results",outputDir="output") | def testExample(id, path, nodes, input=None, args=None, ndiffDir=None,outputDir=None) : global compiler,logDir,successbuilds,f; index = successbuilds.find(compiler+'_'+path) index = successbuilds.find('|',index) if (successbuilds.startswith('success',index+1)) : newDir = logDir for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(path) if os.path.exists(newDir + "/test"+id+"-" + compiler) : os.remove(newDir + "/test"+id+"-" + compiler) execPath='bin/x86_64-linux/mpich2/'+compiler+'/'+path.rpartition('/')[2]+'Example-debug' if nodes == '1' : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f1,stderr=f1) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system(execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system(execPath + ' ' + args +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen(["mpiexec","-n",nodes,execPath], stdin=inputPipe.stdout, stdout=f1,stderr=subprocess.PIPE) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + ' ' + execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + " " + execPath + ' ' + args+" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") if err==0 and ndiffDir != None and outputDir != None : for outputFile in os.listdir(ndiffDir) : if outputFile!='.svn' : error=os.system(ndiff + ' --tolerance=1e-10 ' + ndiffDir +'/'+outputFile + ' ' + outputDir +'/'+outputFile + ' >> ' + newDir + "/test" + id + "-" + compiler + " 2>&1") if err==0 : err=error if not os.path.exists(execPath) : err=-1 if err==0 : f.write(compiler+'_'+path+'_test|success|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='success' href='%slogs_x86_64-linux/%s/test%s-%s'>success</a><br>" %(path,id,rootUrl,path,id,compiler) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail' href='%slogs_x86_64-linux/%s/test%s-%s'>failed</a><br>" %(path,id,rootUrl,path,id,compiler) os.chdir(cwd) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail'>failed</a> due to build failure<br>" %(path,id) return; |
testExample(id='1',path="FluidMechanics/NavierStokes/Statici_FieldML",nodes='1',input='\n') | testExample(id='1',path="FluidMechanics/NavierStokes/Static_FieldML",nodes='1',input='\n') | def testExample(id, path, nodes, input=None, args=None, ndiffDir=None,outputDir=None) : global compiler,logDir,successbuilds,f; index = successbuilds.find(compiler+'_'+path) index = successbuilds.find('|',index) if (successbuilds.startswith('success',index+1)) : newDir = logDir for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(path) if os.path.exists(newDir + "/test"+id+"-" + compiler) : os.remove(newDir + "/test"+id+"-" + compiler) execPath='bin/x86_64-linux/mpich2/'+compiler+'/'+path.rpartition('/')[2]+'Example-debug' if nodes == '1' : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execArgs = [execPath] if args != None : execArgs.extend(args.split(' ')) execCommand = subprocess.Popen(args=execArgs, stdin=inputPipe.stdout, stdout=f1,stderr=f1) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system(execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system(execPath + ' ' + args +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execArgs = ["mpiexec","-n",nodes,execPath] if args != None : execArgs.extend(args.split(' ')) execCommand = subprocess.Popen(args=execArgs, stdin=inputPipe.stdout, stdout=f1,stderr=subprocess.PIPE) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + ' ' + execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + " " + execPath + ' ' + args+" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") if err==0 and ndiffDir != None and outputDir != None : for outputFile in os.listdir(ndiffDir) : if outputFile!='.svn' : error=os.system(ndiff + ' --tolerance=1e-10 ' + ndiffDir +'/'+outputFile + ' ' + outputDir +'/'+outputFile + ' >> ' + newDir + "/test" + id + "-" + compiler + " 2>&1") if err==0 : err=error if not os.path.exists(execPath) : err=-1 outputfile = open(newDir + "/test" + id + "-" + compiler, 'r') if "ERROR:" in outputfile.read() : err=-1 if err==0 : f.write(compiler+'_'+path+'_test|success|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='success' href='%slogs_x86_64-linux/%s/test%s-%s'>success</a><br>" %(path,id,rootUrl,path,id,compiler) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail' href='%slogs_x86_64-linux/%s/test%s-%s'>failed</a><br>" %(path,id,rootUrl,path,id,compiler) os.chdir(cwd) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail'>failed</a> due to build failure<br>" %(path,id) return; |
buildExample("ClassicalField/Diffusion/LinearConvergenceTest") buildExample("ClassicalField/Diffusion/QuadraticConvergenceTest") buildExample("ClassicalField/Diffusion/CubicConvergenceTest") | logExample(path="ClassicalField/Diffusion/LinearConvergenceTest") logExample(path="ClassicalField/Diffusion/QuadraticConvergenceTest") logExample(path="ClassicalField/Diffusion/CubicConvergenceTest") | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; |
execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f1,stderr=f) | execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f1,stderr=f1) | def testExample(id, path, nodes, input=None, args=None) : global compiler,logDir,successbuilds,f; index = successbuilds.find(compiler+'_'+path) index = successbuilds.find('|',index) if (successbuilds.startswith('success',index+1)) : newDir = logDir for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(path) if os.path.exists(newDir + "/test"+id+"-" + compiler) : os.remove(newDir + "/test"+id+"-" + compiler) execPath='bin/x86_64-linux/mpich2/'+compiler+'/'+path.rpartition('/')[2]+'Example-debug' if nodes == '1' : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f1,stderr=f) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system(execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system(execPath + ' ' + args +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen(["mpiexec","-n",nodes,execPath], stdin=inputPipe.stdout, stdout=f1,stderr=subprocess.PIPE) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + ' ' + execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + " " + execPath + ' ' + args+" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") if not os.path.exists(execPath) : err=-1 if err==0 : f.write(compiler+'_'+path+'_test|success|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='success' href='%slogs_x86_64-linux/%s/test%s-%s'>success</a><br>" %(path,id,rootUrl,path,id,compiler) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail' href='%slogs_x86_64-linux/%s/test%s-%s'>failed</a><br>" %(path,id,rootUrl,path,id,compiler) os.chdir(cwd) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail'>failed</a> due to build failure<br>" %(path,id) return; |
if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; | |
if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; | |
f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; | |
if log.startswith('intel_') : | if log.startswith('gnu_') : | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; |
if(paths[0].endswith('_build') and (not log.startswith('intel_library_build'))) : logExample(path=paths[0].replace('intel_','').replace('_build','')); | if(paths[0].endswith('_build') and (not log.startswith('gnu_library_build'))) : logExample(path=paths[0].replace('gnu_','').replace('_build','')); | def logExample(path) : global logDir,logs; intellibrarylog=[] gnulibrarylog=[] intelexamplelog=[] gnuexamplelog=[] inteltestlog=[] gnutestlog=[] for log in logs : if log.startswith('intel_library_build') : intellibrarylog=log.split('|'); if log.startswith('gnu_library_build') : gnulibrarylog=log.split('|'); if log.startswith('intel_'+path+'_build') : intelexamplelog=log.split('|'); if log.startswith('gnu_'+path+'_build') : gnuexamplelog=log.split('|'); if log.startswith('intel_'+path+'_test') : inteltestlog=log.split('|'); if log.startswith('gnu_'+path+'_test') : gnutestlog=log.split('|'); newDir = logDir; for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(logDir+"/"+path) if os.path.exists(newDir + "/history.html") : os.remove(newDir + "/history.html") f = open(newDir + "/history.html","w") f.write("<h2>Testing Status:</h2>\n") f.write("<table><tr><td/><td>Status</td><td>Latest Execution Time</td></tr>\n") f.write("<tr><td><b>Intel Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-intel'>OpenCMISS Library</a></td>") if(intellibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intellibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-intel'>Example Build</a></td>") if(intelexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+intelexamplelog[2]+"</td></tr>") if(len(inteltestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-intel'>Example Test</a></td>") if(inteltestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+inteltestlog[2]+"</td></tr>") f.write("<tr><td><b>GNU Build</b></td><td/><td/></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/build-gnu'>OpenCMISS Library</a></td>") if(gnulibrarylog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnulibrarylog[2]+"</td></tr>") f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/build-gnu'>Example Build</a></td>") if(gnuexamplelog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnuexamplelog[2]+"</td></tr>") if(len(gnutestlog)>1) : f.write("<tr><td><a href='"+rootUrl+"logs_x86_64-linux/"+path+"/test1-gnu'>Example Test</a></td>") if(gnutestlog[1].startswith('success')) : f.write("<td><font color='green'>Success</font></td>") else : f.write("<td><font color='red'>Fail</font></td>") f.write("<td>"+gnutestlog[2]+"</td></tr>") f.write("</table>") f.close() return; |
ret = subprocess.call('/bin/bash run42.sh') | ret = subprocess.call('/bin/bash run42.sh', shell=True) | def leafFunc(self, sofar): print('Running %s' % '/'.join(sofar) + '/run42.sh') try: ret = subprocess.call('/bin/bash run42.sh') except Exception: print('Could not run subprocess') else: if not ret == 0: print('Bad return code %d, continuing...' % ret) else: subprocess.call('mv *.exnode *.exelem expected_results') |
testExample(id='1',path="SinglePhysics/LinearProblems/"+times+"/Stokes/"+dims+"/"+els+"/"+interp+"/"+level+"",master42=,master42="FluidMechanics/Stokes/42Master",nodes='1',ndiffDir='expected_results',outputDir='output') | testExample(id='1',path="SinglePhysics/LinearProblems/"+times+"/Stokes/"+dims+"/"+els+"/"+interp+"/"+level+"",master42="FluidMechanics/Stokes/42Master",nodes='1',ndiffDir='expected_results',outputDir='output') | def htmlWrapper(infile, outfile) : stext1 = "<"; stext2 = ">"; rtext1 = "<"; rtext2 = ">"; input = sys.stdin output = sys.stdout input = open(infile) output = open(outfile, 'w') insertTag("<pre>",output) for s in input.xreadlines(): output.write(s.replace(stext1, rtext1).replace(stext2,rtext2)) insertTag("</pre>",output) output.close() |
testExample(id='1',path="SinglePhysics/NonlinearProblems/"+times+"/NavierStokes/"+dims+"/"+els+"/"+interp+"/"+level+"",master42=,master42="FluidMechanics/NavierStokes/42Master",nodes='1',ndiffDir='expected_results',outputDir='output') | testExample(id='1',path="SinglePhysics/NonlinearProblems/"+times+"/NavierStokes/"+dims+"/"+els+"/"+interp+"/"+level+"",master42="FluidMechanics/NavierStokes/42Master",nodes='1',ndiffDir='expected_results',outputDir='output') | def htmlWrapper(infile, outfile) : stext1 = "<"; stext2 = ">"; rtext1 = "<"; rtext2 = ">"; input = sys.stdin output = sys.stdout input = open(infile) output = open(outfile, 'w') insertTag("<pre>",output) for s in input.xreadlines(): output.write(s.replace(stext1, rtext1).replace(stext2,rtext2)) insertTag("</pre>",output) output.close() |
f = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f,stderr=f) f.close() | f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f1,stderr=f) f1.close() | def testExample(id, path, nodes, input=None, args=None) : global compiler,logDir,successbuilds,f; index = successbuilds.find(compiler+'_'+path) index = successbuilds.find('|',index) if (successbuilds.startswith('success',index+1)) : newDir = logDir for folder in path.split('/') : newDir = newDir + '/' + folder if not os.path.isdir(newDir): os.mkdir(newDir) os.chdir(path) if os.path.exists(newDir + "/test"+id+"-" + compiler) : os.remove(newDir + "/test"+id+"-" + compiler) execPath='bin/x86_64-linux/mpich2/'+compiler+'/'+path.rpartition('/')[2]+'Example-debug' if nodes == '1' : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen([execPath], stdin=inputPipe.stdout, stdout=f,stderr=f) f.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system(execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system(execPath + ' ' + args +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : if input != None : inputPipe = subprocess.Popen(["echo", input], stdout=subprocess.PIPE) f1 = open(newDir + "/test" + id + "-" + compiler,"w") execCommand = subprocess.Popen(["mpiexec","-n",nodes,execPath], stdin=inputPipe.stdout, stdout=f1,stderr=subprocess.PIPE) f1.close() err = os.waitpid(execCommand.pid, 0)[1] elif args==None : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + ' ' + execPath +" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") else : err=os.system('python ' + mpidir + '/mpiexec.py -n ' + nodes + " " + execPath + ' ' + args+" > " + newDir + "/test" + id + "-" + compiler + " 2>&1") if not os.path.exists(execPath) : err=-1 if err==0 : f.write(compiler+'_'+path+'_test|success|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='success' href='%slogs_x86_64-linux/%s/test%s-%s'>success</a><br>" %(path,id,rootUrl,path,id,compiler) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail' href='%slogs_x86_64-linux/%s/test%s-%s'>failed</a><br>" %(path,id,rootUrl,path,id,compiler) os.chdir(cwd) else : f.write(compiler+'_'+path+'_test|fail|'+ strftime("%Y-%m-%d %H:%M:%S")+'\n') print "Testing %s%s: <a class='fail'>failed</a> due to build failure<br>" %(path,id) return; |
"pad image rows to multiples of 4 pixels" | def copy_padded(array): "pad image rows to multiples of 4 pixels" y,x,d = array.shape pad = 4-(x%4) if pad == 4: return array ret = np.zeros((y,x+pad,d), dtype=np.uint8) ret[:,:x] = array[:] return ret | |
pad = 4-(x%4) if pad == 4: | pad = lambda v: (4-(v%4))%4 nx = max(x+pad(x),12) ny = max(y,12) if x == nx and y == ny: | def copy_padded(array): "pad image rows to multiples of 4 pixels" y,x,d = array.shape pad = 4-(x%4) if pad == 4: return array ret = np.zeros((y,x+pad,d), dtype=np.uint8) ret[:,:x] = array[:] return ret |
ret = np.zeros((y,x+pad,d), dtype=np.uint8) ret[:,:x] = array[:] | ret = np.zeros((ny,nx,d), dtype=np.uint8) ret[:y,:x] = array[:] | def copy_padded(array): "pad image rows to multiples of 4 pixels" y,x,d = array.shape pad = 4-(x%4) if pad == 4: return array ret = np.zeros((y,x+pad,d), dtype=np.uint8) ret[:,:x] = array[:] return ret |
self.width = size[0] self.height = size[1] | self._width = size[0] self._height = size[1] | def __init__(self, size, pix_format="", parent=None, bottom_up=0): self.width = size[0] self.height = size[1] self.text_pos = [0.0, 0.0] # create some sort of device context if parent is None: self.qt_dc = QtGui.QPixmap(*size) else: self.qt_dc = parent self.gc = QtGui.QPainter(self.qt_dc) self.path = QtGui.QPainterPath() # flip y trans = QtGui.QTransform() trans.translate(0, size[1]) trans.scale(1.0, -1.0) self.gc.setWorldTransform(trans) # enable antialiasing self.gc.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.TextAntialiasing, True) # set the pen and brush to useful defaults self.gc.setPen(QtCore.Qt.black) self.gc.setBrush(QtGui.QBrush(QtCore.Qt.SolidPattern)) |
dest_rect = QtCore.QRectF(0.0, 0.0, self.width, self.height) | dest_rect = QtCore.QRectF(0.0, 0.0, self.width(), self.height()) | def copy_padded(array): "pad image rows to multiples of 4 pixels" y,x,d = array.shape pad = 4-(x%4) if pad == 4: return array ret = np.zeros((y,x+pad,d), dtype=np.uint8) ret[:,:x] = array[:] return ret |
r,g,b,a = clear_color | if len(clear_color) == 4: r,g,b,a = clear_color else: r,g,b = clear_color a = 1.0 | def clear(self, clear_color=(1.0,1.0,1.0,1.0)): r,g,b,a = clear_color self.gc.setBackground(QtGui.QBrush(QtGui.QColor.fromRgbF(r,g,b,a))) self.gc.eraseRect(QtCore.QRectF(0,0,self.width,self.height)) |
self.gc.eraseRect(QtCore.QRectF(0,0,self.width,self.height)) | self.gc.eraseRect(QtCore.QRectF(0,0,self.width(),self.height())) | def clear(self, clear_color=(1.0,1.0,1.0,1.0)): r,g,b,a = clear_color self.gc.setBackground(QtGui.QBrush(QtGui.QColor.fromRgbF(r,g,b,a))) self.gc.eraseRect(QtCore.QRectF(0,0,self.width,self.height)) |
return GraphicsContext((width, height), self) | return GraphicsContext((width, height), parent=self) | def new_gc(self, size): """ Creates a new GC of the requested size (or of the widget's current size if size is None) and stores it in self.gc. """ if size is None: width = self.width() height = self.height() else: width, height = size |
elif isinstance(value, str): return color_table[value] | def convert_from_wx_color(obj, name, value): if isinstance(value, ColourPtr) or isinstance(value, wx.Colour): return (value.Red()/255.0, value.Green()/255.0, value.Blue()/255.0, 1.0) elif isinstance(value, str): return color_table[value] elif type(value) is int: num = int( value ) return ((num >> 16)/255.0, ((num>>8) & 0xFF)/255.0, (num & 0xFF)/255.0, 1.0) elif type(value) in (list, tuple): if len(value) == 3: return (value[0]/255.0, value[1]/255.0, value[2]/255.0, 1.0) elif len(value) == 4: return value else: raise TraitError else: raise TraitError | |
elif isinstance(value, Str): return color_table.get(value, transparent_color) | def convert_from_pyqt_color(obj, name, value): if isinstance(value, QtGui.QColor): return value.getRgbF() elif isinstance(value, Str): return color_table.get(value, transparent_color) elif type(value) is int: num = int(value) return ((num >> 16)/255.0, ((num>>8) & 0xFF)/255.0, (num & 0xFF)/255.0, 1.0) elif type(value) in (list, tuple): if len(value) == 3: return (value[0]/255.0, value[1]/255.0, value[2]/255.0, 1.0) elif len(value) == 4: return value else: raise TraitError else: raise TraitError | |
ColorTrait = Trait("black", Tuple, List, Str, color_table, | ColorTrait = Trait("black", Tuple, List, color_table, | def str_color(self, color): if isinstance(color, QtGui.QColor): color = color.getRgbF() |
return color_table.get(value, transparent_color) | return color_table[value] | def convert_from_wx_color(obj, name, value): if isinstance(value, ColourPtr) or isinstance(value, wx.Colour): return (value.Red()/255.0, value.Green()/255.0, value.Blue()/255.0, 1.0) elif isinstance(value, str): return color_table.get(value, transparent_color) elif type(value) is int: num = int( value ) return ((num >> 16)/255.0, ((num>>8) & 0xFF)/255.0, (num & 0xFF)/255.0, 1.0) elif type(value) in (list, tuple): if len(value) == 3: return (value[0]/255.0, value[1]/255.0, value[2]/255.0, 1.0) elif len(value) == 4: return value else: raise TraitError else: raise TraitError |
ColorTrait = Trait("black", Tuple, List, Str, color_table, | ColorTrait = Trait("black", Tuple, List, color_table, | def str_color(self, color): if isinstance( color, ( wx.Colour, ColourPtr ) ): return "(%d,%d,%d)" % ( color.Red(), color.Green(), color.Blue() ) elif isinstance(color, tuple): fmt = "(" + ",".join(["%0.3f"]*len(color)) + ")" return fmt % color return color |
x_trans = x + self.view_position[0] y_trans = y + self.view_position[1] | x_trans, y_trans = self.viewport_to_component(x, y) | def components_at(self, x, y, add_containers = False): """ Returns the list of components inside the viewport at the given (x,y) in the viewport's native coordinate space (not in the space of the component it is viewing). |
def is_in(self, x, y): """ Return True if the (x,y) coordinates are within the viewport's native coordinate space. """ pos = [0.0, 0.0] bounds = self.view_bounds return (x >= pos[0]) and (x < pos[0] + bounds[0]) and \ (y >= pos[1]) and (y < pos[1] + bounds[1]) | def components_at(self, x, y, add_containers = False): """ Returns the list of components inside the viewport at the given (x,y) in the viewport's native coordinate space (not in the space of the component it is viewing). | |
def _enable_zoom_changed(self, old, new): """ Add or remove the zoom tool overlay depending whether or not zoom is enabled. """ if self.zoom_tool is None: return if self.enable_zoom: if not self.zoom_tool in self.tools: self.tools.append(self.zoom_tool) else: if self.zoom_tool in self.tools: self.tools.remove(self.zoom_tool) def _update_component_view_bounds(self): """ Updates the optional .view_bounds trait on our component; mostly used for Canvas objects. """ if isinstance(self.component, Canvas): llx, lly = self.view_position self.component.view_bounds = (llx, lly, llx + self.view_bounds[0]-1, lly + self.view_bounds[1]-1) return def _component_changed(self, old, new): if (old is not None) and (self in old.viewports): old.viewports.remove(self) if (new is not None) and (self not in new.viewports): new.viewports.append(self) self._update_component_view_bounds() return def _bounds_changed(self, old, new): Component._bounds_changed(self, old, new) self.set(view_bounds = [new[0]/self.zoom, new[1]/self.zoom], trait_change_notify=False) self._update_component_view_bounds() return def _bounds_items_changed(self, event): return self._bounds_changed(None, self.bounds) def _view_bounds_changed(self, old, new): self._update_component_view_bounds() return def _view_bounds_items_changed(self, event): return self._view_bounds_changed(None, self.bounds) def _view_position_changed(self): self._update_component_view_bounds() def _view_position_items_changed(self): self._view_position_changed() def _get_position(self): return self.view_position def _get_bounds(self): return self.view_bounds def get_event_transform(self, event=None, suffix=""): transform = affine.affine_identity() if isinstance(self.component, Component): if self.enable_zoom and self.zoom != 1.0: transform = affine.translate(transform, *self.view_position) transform = affine.scale(transform, 1.0/self.zoom, 1.0/self.zoom) transform = affine.translate(transform, -self.outer_position[0], -self.outer_position[1]) else: x_offset = self.view_position[0] - self.outer_position[0] y_offset = self.view_position[1] - self.outer_position[1] transform = affine.translate(transform, x_offset, y_offset) return transform | def _do_layout(self): if self.initiate_layout: self.component.bounds = list(self.component.get_preferred_size()) self.component.do_layout() else: super(Viewport, self)._do_layout() return | |
raise NotImplementedError, "GetGlobalMousePosition is not defined for" \ "toolkit '%s'." % ETSConfig.toolkit | def GetGlobalMousePosition(): raise NotImplementedError, "GetGlobalMousePosition is not defined for" \ "toolkit '%s'." % ETSConfig.toolkit | def GetGlobalMousePosition(): pos = QtGui.QCursor.pos() return (pos.x(), pos.y()) |
gcc_version = os.popen("g++ --version") gcc_version_head = gcc_version.readline().split() gcc_version.close() if int(gcc_version_head[2][0]) < 4: | f = os.popen("g++ --version") line0 = f.readline() f.close() m = re.match(r'.+?\s(\d)\.\d+', line0) if m and int(m.group(1)) < 4: | def get_ft2_sources((lib_name, build_info), build_dir): sources = [prefix + "/" + s for s in freetype2_sources] if sys.platform=='darwin': return sources[:] return sources[:-1] |
self.size = (size.GetWidth(), size.GetHeight()) | self._size = (size.GetWidth(), size.GetHeight()) | def __init__(self, parent, id = 01, size = wx.DefaultSize): # need to init self.memDC before calling BaseWxCanvas.__init__ self.memDC = wx.MemoryDC() self.size = (size.GetWidth(), size.GetHeight()) WidgetClass.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER | wx.WANTS_CHARS | \ wx.FULL_REPAINT_ON_RESIZE ) BaseWxCanvas.__init__(self) return |
self.size = size | self._size = size | def _create_kiva_gc(self, size): self.size = size self.bitmap = wx.EmptyBitmap(size[0], size[1]) self.memDC.SelectObject(self.bitmap) gc = gc_for_dc(self.memDC) #gc.begin() #print " **** gc is:", gc return gc |
paintdc.Blit(0, 0, self.size[0], self.size[1], | paintdc.Blit(0, 0, self._size[0], self._size[1], | def blit(self, event): t1 = now() paintdc = wx.PaintDC(self) paintdc.Blit(0, 0, self.size[0], self.size[1], self.memDC, 0, 0) t2 = now() self.blit_time = t2 - t1 self.dirty = 0 return |
if '64bit' in platform.architecture(): gcc_version = os.popen("g++ --version") gcc_version_head = gcc_version.readline().split() gcc_version.close() if int(gcc_version_head[2][0]) < 4: | if sys.platform == 'linux2' and '64bit' in platform.architecture(): f = os.popen("g++ --version") line0 = f.readline() f.close() m = re.match(r'.+?\s(3|4)\.\d+', line0) if int(m.group(1)) < 4: | def get_ft2_sources((lib_name, build_info), build_dir): sources = [prefix + "/" + s for s in freetype2_sources] if sys.platform=='darwin': return sources[:] return sources[:-1] |
def radial_gradient(self, cx, cy, r, stops, fx=None,fy=None, spreadMethod='pad', | def radial_gradient(self, cx, cy, r, fx, fy, stops, spreadMethod='pad', | def radial_gradient(self, cx, cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): |
gradient = cairo.RadialGradient(cx, cy, r, fx, fx, r) | gradient = cairo.RadialGradient(fx, fy, 0.0, cx, cy, r) for stop in stops: if stop.size == 10: start = tuple(stop[0:5]) end = tuple(stop[5:10]) gradient.add_color_stop_rgba(*start) gradient.add_color_stop_rgba(*end) else: start = tuple(stop[0:5]) gradient.add_color_stop_rgba(*start) self.state.has_gradient = True self._ctx.set_source(gradient) def linear_gradient(self, x1, y1, x2, y2, stops, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): gradient = cairo.LinearGradient(x1, y1, x2, y2) | def radial_gradient(self, cx, cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): |
return gradient def linear_gradient(self, x1, y1, x2, y2, stops, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): gradient = cairo.LinearGradient(x1, y1, x2, y2) for stop in stops: if stop.size == 10: start = tuple(stop[0:5]) end = tuple(stop[5:10]) gradient.add_color_stop_rgba(*start) gradient.add_color_stop_rgba(*end) else: start = tuple(stop[0:5]) gradient.add_color_stop_rgba(*start) return gradient | self.state.has_gradient = True self._ctx.set_source(gradient) | def radial_gradient(self, cx, cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): |
else: self._ctx.arc_negative( x, y, radius, start_angle, end_angle) | def arc(self, x, y, radius, start_angle, end_angle, cw=False): """ Draw a circular arc. | |
self._set_source_color(self.state.fill_color) | if not self.state.has_gradient: self._set_source_color(self.state.fill_color) | def draw_path(self, mode=constants.FILL_STROKE): """ Walks through all the drawing subpaths and draw each element. |
self._set_source_color(self.state.stroke_color) | if not self.state.has_gradient: self._set_source_color(self.state.stroke_color) | def draw_path(self, mode=constants.FILL_STROKE): """ Walks through all the drawing subpaths and draw each element. |
dash_patterns = outer_join(self.dash_values,self.dash_values) | dash_patterns = outer_join(self.dash_values[1:], self.dash_values) | def draw(self,gc): dash_patterns = outer_join(self.dash_values,self.dash_values) line_length = 120 gc.save_state() gc.set_line_cap(self.line_cap) gc.translate_ctm(10,20) gc.set_stroke_color((0,0,0,1)) gc.set_line_width(self.width) for dash in dash_patterns: gc.set_line_dash(dash) gc.begin_path() gc.move_to(0, 0) gc.line_to(line_length,0) gc.stroke_path() |
descent = (-descent) * fontsize / 1000.0 | aw,ah,ad,al = self._agg_gc.get_full_text_extent(textstring) descent = 0.0 if ad == 0.0 else descent * fontsize / 1000.0 | def get_full_text_extent(self,textstring): fontname=self.gc._fontname fontsize=self.gc._fontsize #this call does not seem to work. returns zero #ascent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.ascent) #this call does not seem to work. returns -1 #descent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.descent) |
height=ascent+descent width=self.gc.stringWidth(textstring,fontname,fontsize) | height = ascent + abs(descent) width = self.gc.stringWidth(textstring,fontname,fontsize) | def get_full_text_extent(self,textstring): fontname=self.gc._fontname fontsize=self.gc._fontsize #this call does not seem to work. returns zero #ascent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.ascent) #this call does not seem to work. returns -1 #descent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.descent) |
raise "Not Implemented" | raise NotImplementedError | def makePDFObject(self): # XXX Kiva specific change raise "Not Implemented" |
raise "Not Implemented" | raise NotImplementedError | def addObjects(self, doc): # XXX Kiva specific change raise "Not Implemented" |
raise "Not Implemented" | raise NotImplementedError | def addObjects(self, doc): # XXX Kiva specific changes raise "Not Implemented" |
view = Viewport(component=container, view_position=[10.0, 10.0], view_bounds=[50.0, 50.0]) | view = Viewport(component=container, view_position=[10.0, 10.0], view_bounds=[50.0, 50.0], position=[0,0], bounds=[50,50]) | def test_basic_viewport(self): container = Container(bounds=[100.0, 100.0]) component = Component(bounds=[50.0, 50.0], position=[5.0, 5.0]) container.add(component) view = Viewport(component=container, view_position=[10.0, 10.0], view_bounds=[50.0, 50.0]) self.assert_(view.components_at(0.0, 0.0)[0] == component) self.assert_(view.components_at(44.9, 0.0)[0] == component) self.assert_(view.components_at(0.0, 44.9)[0] == component) self.assert_(view.components_at(44.9, 44.9)[0] == component) self.assert_(view.components_at(46.0, 45.0) == []) self.assert_(view.components_at(46.0, 0.0) == []) self.assert_(view.components_at(45.0, 46.0) == []) self.assert_(view.components_at(0.0, 46.0) == []) return |
w = self._gc.width h = self._gc.height | w = self._gc.width() h = self._gc.height() | def _window_paint(self, event): if self.control is None: return |
self.control.SetFocus() | if self.control == self.control.GetCapture(): self.control.SetFocus() | def _set_focus ( self ): "Sets the keyboard focus to this window" self.control.SetFocus() return |
if numpy.__version__[:5] < '1.0.3': from numpy.distutils.command import build_ext old_run = build_ext.build_ext.run def new_run(self): if not self.extensions: return self.run_command('build_src') if self.distribution.has_c_libraries(): self.run_command('build_clib') build_clib = self.get_finalized_command('build_clib') self.library_dirs.append(build_clib.build_clib) else: build_clib = None old_run(self) build_ext.build_ext.run = new_run if numpy.__version__[:5] < '1.0.5': from setuptools.command import develop old_develop = develop.develop class develop(old_develop): __doc__ = old_develop.__doc__ def install_for_development(self): self.reinitialize_command('build_src', inplace=1) old_develop.install_for_development(self) develop.develop = develop from numpy.distutils import core core.numpy_cmdclass['develop'] = develop | def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration(None, parent_package, top_path) config.set_options( ignore_setup_xxx_py=True, assume_default_configuration=True, delegate_options_to_subpackages=True, quiet=True, ) config.add_subpackage('enthought.kiva') config.add_subpackage('enthought') return config | |
def create_texture(self, cls): | def create_texture(self, cls, rectangle): | def create_texture(self, cls): '''Create a texture containing this image. |
texture = cls.create_for_size( gl.GL_TEXTURE_2D, self.width, self.height) | _is_pow2 = lambda v: (v & (v - 1)) == 0 target = gl.GL_TEXTURE_2D if rectangle and not (_is_pow2(self.width) and _is_pow2(self.height)): if gl.gl_info.have_extension('GL_ARB_texture_rectangle'): target = gl.GL_TEXTURE_RECTANGLE_ARB elif gl.gl_info.have_extension('GL_NV_texture_rectangle'): target = gl.GL_TEXTURE_RECTANGLE_NV texture = cls.create_for_size(target, self.width, self.height) | def create_texture(self, cls): '''Create a texture containing this image. |
if gl._current_context._workaround_unpack_row_length: | if gl.current_context._workaround_unpack_row_length: | def component_column(component): try: pos = 'RGBA'.index(component) return [0] * pos + [1] + [0] * (3 - pos) except ValueError: return [0, 0, 0, 0] |
[(0,1,0,0,1),(1,1,1,1,1)], 'reflect') | array([start, end]), 'reflect') | def do_draw(self, gc): w = gc.width() h = gc.height() # Draw a red gradient filled box with green border gc.rect(w/4, h/4, w/2, h/2) gc.set_line_width(5.0) gc.set_stroke_color((0.0, 1.0, 0.0, 1.0)) gc.radial_gradient(w/4, h/4, 200, w/4+100, h/4+100, [(0,1,0,0,1),(1,1,1,1,1)], 'reflect') gc.draw_path() return |
raise RuntimeError, "Padding must be a 4-element sequence type or an int. Instead, got" + str(val) | raise RuntimeError("Padding must be a 4-element sequence " "type or an int. Instead, got" + str(val)) | def _set_padding(self, val): old_padding = self.padding |
width="100%%" height="100%%" | width="%(width)f" height="%(height)f" | def default_filter(kw1): kw = {} for (k,v) in kw1.items(): if type(v) == type(()): if v[0] != v[1]: kw[k] = v[0] else: kw[k] = v return kw |
def clear(self, size): | def clear(self): | def clear(self, size): # TODO: clear the contents pass |
height, width = self.size | width, height = self.size | def save(self, filename): f = open(filename, 'w') ext = os.path.splitext(filename)[1] if ext == '.svg': template = xmltemplate height, width = self.size contents = self.contents.getvalue().replace("<svg:", "<").replace("</svg:", "</") elif ext == '.html': height, width = self.size[0]*3, self.size[1]*3 contents = self.contents.getvalue() template = htmltemplate else: raise ValueError, "don't know how to write a %s file" % ext f.write(template % locals()) |
height, width = self.size[0]*3, self.size[1]*3 | width, height = self.size[0]*3, self.size[1]*3 | def save(self, filename): f = open(filename, 'w') ext = os.path.splitext(filename)[1] if ext == '.svg': template = xmltemplate height, width = self.size contents = self.contents.getvalue().replace("<svg:", "<").replace("</svg:", "</") elif ext == '.html': height, width = self.size[0]*3, self.size[1]*3 contents = self.contents.getvalue() template = htmltemplate else: raise ValueError, "don't know how to write a %s file" % ext f.write(template % locals()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.