content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# # CLASS MEHTODS # class Employee: # company ="camel" # salary = 100 # location = "mumbai" # def ChangeSalary(self, sal): # self.__class__.salary = sal # # THE EASY METHOD FOR THE ABOVE STATEMENT AND FOR THE CLASS ATTRIBUTE IS # @classmethod # def ChangeSalary(cls, sal): # cls.salary = sal # e = Employee() # print("this is e.salary obj of employee************",e.salary) # print("this is of employee**********", Employee.salary) # e.ChangeSalary(455) # print("this is the e .salary obj after using e.changeSalary method so this is an instance*************", e.salary) # print("This is the same Employee that hasnt been changed even after we use e.chanegSalary************", Employee.salary) # PROPERTY DECORATOR class Employee: company = "Bharat Gas" salary =4500 salaryBonus= 500 # totalSalary = 5000 # ALSO CALLED AS GETTER METHOD @property def totalSalary(self): return self.salary +self.salaryBonus @totalSalary.setter def totalSalary(self, val): self.salaryBonus = val - self.salary e= Employee() print(e.totalSalary) e.totalSalary = 4900 print(e.totalSalary) print(e.salary) print(e.salaryBonus)
class Employee: company = 'Bharat Gas' salary = 4500 salary_bonus = 500 @property def total_salary(self): return self.salary + self.salaryBonus @totalSalary.setter def total_salary(self, val): self.salaryBonus = val - self.salary e = employee() print(e.totalSalary) e.totalSalary = 4900 print(e.totalSalary) print(e.salary) print(e.salaryBonus)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def bubble_sort(arr): for n in range(len(arr)-1, 0, -1): for k in range(n): if r[k] > r[k+1]: tmp = r[k] r[k] = r[k+1] r[k+1] = tmp if __name__ == '__main__': r = [5, 4, 2, 3, 1] bubble_sort(r) print(r)
def bubble_sort(arr): for n in range(len(arr) - 1, 0, -1): for k in range(n): if r[k] > r[k + 1]: tmp = r[k] r[k] = r[k + 1] r[k + 1] = tmp if __name__ == '__main__': r = [5, 4, 2, 3, 1] bubble_sort(r) print(r)
# Let's say you have a dictionary matchinhg your friends' names # with their favorite flowers: fav_flowers = {'Alex': 'field flowers', 'Kate': 'daffodil', 'Eva': 'artichoke flower', 'Daniel': 'tulip'} # Your new friend Alice likes orchid the most: add this info to the # fav_flowers dict and print the dict. # NB: Do not redefine the dictionary itself, just add the new # element to the existing one. fav_flowers['Alice'] = 'orchid' print(fav_flowers)
fav_flowers = {'Alex': 'field flowers', 'Kate': 'daffodil', 'Eva': 'artichoke flower', 'Daniel': 'tulip'} fav_flowers['Alice'] = 'orchid' print(fav_flowers)
num1 = float(input("Enter 1st number: ")) op = input("Enter operator: ") num2 = float(input("Enter 2nd number: ")) if op == "+": val = num1 + num2 elif op == "-": val = num1 - num2 elif op == "*" or op == "x": val = num1 * num2 elif op == "/": val = num1 / num2 print(val)
num1 = float(input('Enter 1st number: ')) op = input('Enter operator: ') num2 = float(input('Enter 2nd number: ')) if op == '+': val = num1 + num2 elif op == '-': val = num1 - num2 elif op == '*' or op == 'x': val = num1 * num2 elif op == '/': val = num1 / num2 print(val)
def count_substring(string, sub_string): times = 0 length = len(sub_string) for letter in range(0, len(string)): if string[letter:letter+length] == sub_string: times += 1 return times
def count_substring(string, sub_string): times = 0 length = len(sub_string) for letter in range(0, len(string)): if string[letter:letter + length] == sub_string: times += 1 return times
#!/usr/bin/pthon3 # Time complexity: O(N) def solution(A): count = {} size_A = len(A) leader = None for i, a in enumerate(A): count[a] = count.get(a, 0) + 1 if count[a] > size_A // 2: leader = a equi_leader = 0 before = 0 for i in range(size_A): if A[i] == leader: before += 1 if (before > (i + 1) // 2) and ((count[leader] - before) > (size_A - i - 1) // 2): equi_leader += 1 return equi_leader
def solution(A): count = {} size_a = len(A) leader = None for (i, a) in enumerate(A): count[a] = count.get(a, 0) + 1 if count[a] > size_A // 2: leader = a equi_leader = 0 before = 0 for i in range(size_A): if A[i] == leader: before += 1 if before > (i + 1) // 2 and count[leader] - before > (size_A - i - 1) // 2: equi_leader += 1 return equi_leader
n1 = int(input('digite um valor >>')) n2 = int(input('digite outro vaor >>')) n3 = int(input('digite outro valor >>')) #menor menor = n1 if n2 < n1 and n2 < n3: menor = n2 if n3 < n1 and n3 < n2: menor = n3 #maior maior = n1 if n2 > n1 and n2 > n3: maior = n2 if n3 > n1 and n3 > n2: maior = n3 print('o maior numero e {}'.format(maior)) print('o menor numero e {}'.format(menor))
n1 = int(input('digite um valor >>')) n2 = int(input('digite outro vaor >>')) n3 = int(input('digite outro valor >>')) menor = n1 if n2 < n1 and n2 < n3: menor = n2 if n3 < n1 and n3 < n2: menor = n3 maior = n1 if n2 > n1 and n2 > n3: maior = n2 if n3 > n1 and n3 > n2: maior = n3 print('o maior numero e {}'.format(maior)) print('o menor numero e {}'.format(menor))
class TypeFactory(object): def __init__(self, client): self.client = client def create(self, transport_type, *args, **kwargs): klass = self.classes[transport_type] cls = klass(*args, **kwargs) cls._client = self.client return cls
class Typefactory(object): def __init__(self, client): self.client = client def create(self, transport_type, *args, **kwargs): klass = self.classes[transport_type] cls = klass(*args, **kwargs) cls._client = self.client return cls
length = float(input("Enter the length of a side of the cube: ")) total_surface_area = 6 * length ** 2 volume = 3 * length ** 2 print("The surface area of the cube is", total_surface_area) print("The volume of the cube is", volume) close = input("Press X to exit") # The above code keeps the program open for the user to see the outcome of the problem.
length = float(input('Enter the length of a side of the cube: ')) total_surface_area = 6 * length ** 2 volume = 3 * length ** 2 print('The surface area of the cube is', total_surface_area) print('The volume of the cube is', volume) close = input('Press X to exit')
def generate(): class Spam: count = 1 def method(self): print(count) return Spam() generate().method()
def generate(): class Spam: count = 1 def method(self): print(count) return spam() generate().method()
# Title : Generators in python # Author : Kiran raj R. # Date : 31:10:2020 def printNum(): num = 0 while True: yield num num += 1 result = printNum() print(next(result)) print(next(result)) print(next(result)) result = (num for num in range(10000)) print(result) print(next(result)) print(next(result)) print(next(result))
def print_num(): num = 0 while True: yield num num += 1 result = print_num() print(next(result)) print(next(result)) print(next(result)) result = (num for num in range(10000)) print(result) print(next(result)) print(next(result)) print(next(result))
def funcion(nums,n): print(nums) res = [] for i in range(len(nums)): suma = 0 aux = [] suma += nums[i] for j in range(i+1,len(nums)): print(i,j) if suma + nums[j] == n: aux.append(nums[i]) aux.append(nums[j]) res.append(aux) else: pass return res def main(): print(funcion([1,2,3,4,5,6,7,-1],6)) main()
def funcion(nums, n): print(nums) res = [] for i in range(len(nums)): suma = 0 aux = [] suma += nums[i] for j in range(i + 1, len(nums)): print(i, j) if suma + nums[j] == n: aux.append(nums[i]) aux.append(nums[j]) res.append(aux) else: pass return res def main(): print(funcion([1, 2, 3, 4, 5, 6, 7, -1], 6)) main()
class TestHLD: # edges = [ # (0, 1), # (0, 6), # (0, 10), # (1, 2), # (1, 5), # (2, 3), # (2, 4), # (6, 7), # (7, 8), # (7, 9), # (10, 11), # ] # root = 0 # get_lca = lca_hld(edges, root) # print(get_lca(3, 5)) ...
class Testhld: ...
# # PySNMP MIB module OVERLAND-NEXTGEN (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OVERLAND-NEXTGEN # Produced by pysmi-0.3.4 at Wed May 1 14:35:46 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection") ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, ObjectIdentity, ModuleIdentity, NotificationType, iso, Gauge32, IpAddress, Bits, MibIdentifier, TimeTicks, Counter64, Counter32, Unsigned32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "ObjectIdentity", "ModuleIdentity", "NotificationType", "iso", "Gauge32", "IpAddress", "Bits", "MibIdentifier", "TimeTicks", "Counter64", "Counter32", "Unsigned32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") overlandGlobalRegModule = ModuleIdentity((1, 3, 6, 1, 4, 1, 3351, 1, 1, 1, 1)) if mibBuilder.loadTexts: overlandGlobalRegModule.setLastUpdated('9807090845Z') if mibBuilder.loadTexts: overlandGlobalRegModule.setOrganization('Overland Data, Inc.') if mibBuilder.loadTexts: overlandGlobalRegModule.setContactInfo('Robert Kingsley email: bkingsley@overlanddata.com') if mibBuilder.loadTexts: overlandGlobalRegModule.setDescription('The Overland Data central registration module.') overlandRoot = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1)) overlandReg = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 1)) overlandGeneric = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 2)) overlandProducts = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3)) overlandCaps = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 4)) overlandReqs = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 5)) overlandExpr = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 6)) overlandModules = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 1, 1)) overlandNextGen = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2)) overlandNextGenActions = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 1)) overlandNextGenStatistics = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 2)) overlandNextGenState = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3)) overlandNextGenComponents = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 4)) overlandNextGenAttributes = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5)) overlandNextGenEvents = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6)) overlandNextGenGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7)) overlandLoopback = MibScalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readwrite") if mibBuilder.loadTexts: overlandLoopback.setStatus('current') if mibBuilder.loadTexts: overlandLoopback.setDescription('Sends or retrieves a loopback string to the target.') overlandActionGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 1)).setObjects(("OVERLAND-NEXTGEN", "overlandLoopback")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overlandActionGroup = overlandActionGroup.setStatus('current') if mibBuilder.loadTexts: overlandActionGroup.setDescription('Current library status which may be queried.') driveStatusTable = MibTable((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1), ) if mibBuilder.loadTexts: driveStatusTable.setStatus('current') if mibBuilder.loadTexts: driveStatusTable.setDescription('Table containing various drive status.') driveStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1), ).setIndexNames((0, "OVERLAND-NEXTGEN", "dstIndex")) if mibBuilder.loadTexts: driveStatusEntry.setStatus('current') if mibBuilder.loadTexts: driveStatusEntry.setDescription('A row in the drive status table.') dstRowValid = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: dstRowValid.setStatus('current') if mibBuilder.loadTexts: dstRowValid.setDescription('Provides an INVALID indication if no drives are installed or if the drive type is unknown; otherwise, an indication of the drive type is provided.') dstIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 32))).setMaxAccess("readonly") if mibBuilder.loadTexts: dstIndex.setStatus('current') if mibBuilder.loadTexts: dstIndex.setDescription('Index to drive status fields.') dstState = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))).clone(namedValues=NamedValues(("initializedNoError", 0), ("initializedWithError", 1), ("notInitialized", 2), ("notInstalled", 3), ("notInserted", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: dstState.setStatus('current') if mibBuilder.loadTexts: dstState.setDescription('Current state of the drive.') dstMotion = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 4), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: dstMotion.setStatus('current') if mibBuilder.loadTexts: dstMotion.setDescription('ASCII msg describing current drive tape motion.') dstCodeRevDrive = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: dstCodeRevDrive.setStatus('current') if mibBuilder.loadTexts: dstCodeRevDrive.setDescription('Revision number of the drive code.') dstCodeRevController = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: dstCodeRevController.setStatus('current') if mibBuilder.loadTexts: dstCodeRevController.setDescription('Revision number of the drive controller code.') dstScsiId = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 15))).setMaxAccess("readonly") if mibBuilder.loadTexts: dstScsiId.setStatus('current') if mibBuilder.loadTexts: dstScsiId.setDescription('SCSI Id number of drive.') dstSerialNum = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 8), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: dstSerialNum.setStatus('current') if mibBuilder.loadTexts: dstSerialNum.setDescription('Serial number of this drive.') dstCleanRequested = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("cleanNotNeeded", 0), ("cleanNeeded", 1)))).setMaxAccess("readonly") if mibBuilder.loadTexts: dstCleanRequested.setStatus('current') if mibBuilder.loadTexts: dstCleanRequested.setDescription('The drive heads needs to be cleaned with a cleaning cartridge.') libraryStatusTable = MibTable((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2), ) if mibBuilder.loadTexts: libraryStatusTable.setStatus('current') if mibBuilder.loadTexts: libraryStatusTable.setDescription('Table containing fault code, severity and ACSII error messages displayed on front panel of library.') libraryStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1), ).setIndexNames((0, "OVERLAND-NEXTGEN", "lstIndex")) if mibBuilder.loadTexts: libraryStatusEntry.setStatus('current') if mibBuilder.loadTexts: libraryStatusEntry.setDescription('A row in the library status table.') lstIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1))).setMaxAccess("readonly") if mibBuilder.loadTexts: lstIndex.setStatus('current') if mibBuilder.loadTexts: lstIndex.setDescription('Index to table of library status.') lstConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("standalone", 0), ("multimodule", 1)))).setMaxAccess("readonly") if mibBuilder.loadTexts: lstConfig.setStatus('current') if mibBuilder.loadTexts: lstConfig.setDescription('Indicates if library is standalone or multi-module.') lstScsiId = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 15))).setMaxAccess("readonly") if mibBuilder.loadTexts: lstScsiId.setStatus('current') if mibBuilder.loadTexts: lstScsiId.setDescription('Indicates library SCSI bus ID.') lstStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 4), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: lstStatus.setStatus('current') if mibBuilder.loadTexts: lstStatus.setDescription('Indication of current library status.') lstChangerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: lstChangerStatus.setStatus('current') if mibBuilder.loadTexts: lstChangerStatus.setDescription('Bit-mapped indication of current changer status: bit 0 - cartridge map valid bit 1 - initializing bit 2 - door open bit 3 - front panel mode bit 4 - door closed bit 5 - browser mode bit 6 - master busy') lstLibraryState = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("initializing", 0), ("online", 1), ("offline", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: lstLibraryState.setStatus('current') if mibBuilder.loadTexts: lstLibraryState.setDescription('Indication of current library state.') errorTable = MibTable((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3), ) if mibBuilder.loadTexts: errorTable.setStatus('current') if mibBuilder.loadTexts: errorTable.setDescription('Table containing fault code, severity and ACSII error messages displayed on front panel of library.') errorEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1), ).setIndexNames((0, "OVERLAND-NEXTGEN", "errIndex")) if mibBuilder.loadTexts: errorEntry.setStatus('current') if mibBuilder.loadTexts: errorEntry.setDescription('A row in the error info table.') errIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1))).setMaxAccess("readonly") if mibBuilder.loadTexts: errIndex.setStatus('current') if mibBuilder.loadTexts: errIndex.setDescription('Index to table of library error information.') errCode = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: errCode.setStatus('current') if mibBuilder.loadTexts: errCode.setDescription('Hex code unique to the reported error.') errSeverity = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("informational", 0), ("mild", 1), ("hard", 2), ("severe", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: errSeverity.setStatus('current') if mibBuilder.loadTexts: errSeverity.setDescription('Indication of how serious the reported error is: 0 = informational error, not very severe 1 = mild error, operator intervention not necessary 2 = hard error, may be corrected remotely 3 = very severe, power cycle required to clear') errMsg = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 4), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: errMsg.setStatus('current') if mibBuilder.loadTexts: errMsg.setDescription('ASCII message naming the current error.') errActionMsg = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: errActionMsg.setStatus('current') if mibBuilder.loadTexts: errActionMsg.setDescription('ASCII message providing additional information about current error and possibly some suggestions for correcting it.') overlandStateGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 3)).setObjects(("OVERLAND-NEXTGEN", "errIndex"), ("OVERLAND-NEXTGEN", "errCode"), ("OVERLAND-NEXTGEN", "errSeverity"), ("OVERLAND-NEXTGEN", "errMsg"), ("OVERLAND-NEXTGEN", "errActionMsg"), ("OVERLAND-NEXTGEN", "dstRowValid"), ("OVERLAND-NEXTGEN", "dstIndex"), ("OVERLAND-NEXTGEN", "dstState"), ("OVERLAND-NEXTGEN", "dstMotion"), ("OVERLAND-NEXTGEN", "dstCodeRevDrive"), ("OVERLAND-NEXTGEN", "dstCodeRevController"), ("OVERLAND-NEXTGEN", "dstScsiId"), ("OVERLAND-NEXTGEN", "dstSerialNum"), ("OVERLAND-NEXTGEN", "dstCleanRequested"), ("OVERLAND-NEXTGEN", "lstIndex"), ("OVERLAND-NEXTGEN", "lstConfig"), ("OVERLAND-NEXTGEN", "lstScsiId"), ("OVERLAND-NEXTGEN", "lstStatus"), ("OVERLAND-NEXTGEN", "lstChangerStatus"), ("OVERLAND-NEXTGEN", "lstLibraryState")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overlandStateGroup = overlandStateGroup.setStatus('current') if mibBuilder.loadTexts: overlandStateGroup.setDescription('Current library states which may be queried.') numModules = MibScalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 256))).setMaxAccess("readonly") if mibBuilder.loadTexts: numModules.setStatus('current') if mibBuilder.loadTexts: numModules.setDescription('Reads the total number of modules available in the attached library.') numBins = MibScalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 256))).setMaxAccess("readonly") if mibBuilder.loadTexts: numBins.setStatus('current') if mibBuilder.loadTexts: numBins.setDescription('Reads the total number of cartridge storage slots available in the attached library.') numDrives = MibScalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 128))).setMaxAccess("readonly") if mibBuilder.loadTexts: numDrives.setStatus('current') if mibBuilder.loadTexts: numDrives.setDescription('Reads the total number of drives available in the attached library.') numMailSlots = MibScalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 15))).setMaxAccess("readonly") if mibBuilder.loadTexts: numMailSlots.setStatus('current') if mibBuilder.loadTexts: numMailSlots.setDescription('Returns the total number of mail slots available in the attached library.') moduleGeometryTable = MibTable((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5), ) if mibBuilder.loadTexts: moduleGeometryTable.setStatus('current') if mibBuilder.loadTexts: moduleGeometryTable.setDescription('Table containing library module geometry.') moduleGeometryEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1), ).setIndexNames((0, "OVERLAND-NEXTGEN", "modIndex")) if mibBuilder.loadTexts: moduleGeometryEntry.setStatus('current') if mibBuilder.loadTexts: moduleGeometryEntry.setDescription('A row in the library module geometry table.') modDesc = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: modDesc.setStatus('current') if mibBuilder.loadTexts: modDesc.setDescription('If library geometry is valid, an ASCII message desribing the module.') modIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0, 7), ValueRangeConstraint(8, 8), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: modIndex.setStatus('current') if mibBuilder.loadTexts: modIndex.setDescription('Index to table of library module geometry: 8 = Master or Standalone module 0-7 = Slave Module') modAttached = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("isNotAttached", 0), ("isAttached", 1)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modAttached.setStatus('current') if mibBuilder.loadTexts: modAttached.setDescription('Indication of whether or not module is attached.') modStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 4), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: modStatus.setStatus('current') if mibBuilder.loadTexts: modStatus.setDescription('ASCII message desribing the current status of the module.') modConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("unknown", 0), ("lightning", 1), ("thunder", 2), ("invalid", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modConfig.setStatus('current') if mibBuilder.loadTexts: modConfig.setDescription("Indication of this module's type.") modFwRev = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modFwRev.setStatus('current') if mibBuilder.loadTexts: modFwRev.setDescription("Indication of this module's firmware revision level.") modNumBins = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modNumBins.setStatus('current') if mibBuilder.loadTexts: modNumBins.setDescription('Indication of the number of bins within this module.') modNumDrives = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modNumDrives.setStatus('current') if mibBuilder.loadTexts: modNumDrives.setDescription('Indication of the number of drives within this module.') modNumMailSlots = MibTableColumn((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 9), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modNumMailSlots.setStatus('current') if mibBuilder.loadTexts: modNumMailSlots.setDescription('Indication of the number of mailslots within this module.') overlandAttributesGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 4)).setObjects(("OVERLAND-NEXTGEN", "numModules"), ("OVERLAND-NEXTGEN", "numBins"), ("OVERLAND-NEXTGEN", "numDrives"), ("OVERLAND-NEXTGEN", "numMailSlots"), ("OVERLAND-NEXTGEN", "modDesc"), ("OVERLAND-NEXTGEN", "modIndex"), ("OVERLAND-NEXTGEN", "modAttached"), ("OVERLAND-NEXTGEN", "modStatus"), ("OVERLAND-NEXTGEN", "modConfig"), ("OVERLAND-NEXTGEN", "modFwRev"), ("OVERLAND-NEXTGEN", "modNumBins"), ("OVERLAND-NEXTGEN", "modNumDrives"), ("OVERLAND-NEXTGEN", "modNumMailSlots")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overlandAttributesGroup = overlandAttributesGroup.setStatus('current') if mibBuilder.loadTexts: overlandAttributesGroup.setDescription('Current library info which may be queried.') eventDoorOpen = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 1)) if mibBuilder.loadTexts: eventDoorOpen.setStatus('current') if mibBuilder.loadTexts: eventDoorOpen.setDescription('A library door has been opened.') eventMailSlotAccessed = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 2)) if mibBuilder.loadTexts: eventMailSlotAccessed.setStatus('current') if mibBuilder.loadTexts: eventMailSlotAccessed.setDescription('A mail slot is being accessed.') eventHardFault = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 3)) if mibBuilder.loadTexts: eventHardFault.setStatus('current') if mibBuilder.loadTexts: eventHardFault.setDescription('The library has posted a hard fault.') eventSlaveFailed = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 4)) if mibBuilder.loadTexts: eventSlaveFailed.setStatus('current') if mibBuilder.loadTexts: eventSlaveFailed.setDescription('A slave module has faulted.') eventPowerSupplyFailed = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 5)) if mibBuilder.loadTexts: eventPowerSupplyFailed.setStatus('current') if mibBuilder.loadTexts: eventPowerSupplyFailed.setDescription('One of the redundant power supplies has failed.') eventRequestDriveClean = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 6)) if mibBuilder.loadTexts: eventRequestDriveClean.setStatus('current') if mibBuilder.loadTexts: eventRequestDriveClean.setDescription('One of the library tape drives has requested a cleaning cycle to ensure continued data reliability.') eventFanStalled = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 7)) if mibBuilder.loadTexts: eventFanStalled.setStatus('current') if mibBuilder.loadTexts: eventFanStalled.setDescription('A tape drive fan has stalled.') eventDriveError = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 8)) if mibBuilder.loadTexts: eventDriveError.setStatus('current') if mibBuilder.loadTexts: eventDriveError.setDescription('A tape drive error has occurred.') eventDriveRemoved = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 9)) if mibBuilder.loadTexts: eventDriveRemoved.setStatus('current') if mibBuilder.loadTexts: eventDriveRemoved.setDescription('A tape drive has been removed from the library.') eventSlaveRemoved = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 10)) if mibBuilder.loadTexts: eventSlaveRemoved.setStatus('current') if mibBuilder.loadTexts: eventSlaveRemoved.setDescription('A slave module has been removed from the library.') eventFailedOver = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 11)) if mibBuilder.loadTexts: eventFailedOver.setStatus('current') if mibBuilder.loadTexts: eventFailedOver.setDescription('The library is failed over to the Secondary Master.') eventLoaderRetriesExcessive = NotificationType((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 12)) if mibBuilder.loadTexts: eventLoaderRetriesExcessive.setStatus('current') if mibBuilder.loadTexts: eventLoaderRetriesExcessive.setDescription('The library has detected excessive loader retries.') overlandNotificationGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 7)).setObjects(("OVERLAND-NEXTGEN", "eventDoorOpen"), ("OVERLAND-NEXTGEN", "eventMailSlotAccessed"), ("OVERLAND-NEXTGEN", "eventHardFault"), ("OVERLAND-NEXTGEN", "eventSlaveFailed"), ("OVERLAND-NEXTGEN", "eventPowerSupplyFailed"), ("OVERLAND-NEXTGEN", "eventRequestDriveClean"), ("OVERLAND-NEXTGEN", "eventFanStalled"), ("OVERLAND-NEXTGEN", "eventDriveError"), ("OVERLAND-NEXTGEN", "eventDriveRemoved"), ("OVERLAND-NEXTGEN", "eventSlaveRemoved"), ("OVERLAND-NEXTGEN", "eventFailedOver"), ("OVERLAND-NEXTGEN", "eventLoaderRetriesExcessive")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overlandNotificationGroup = overlandNotificationGroup.setStatus('current') if mibBuilder.loadTexts: overlandNotificationGroup.setDescription('Trap events returned by the browser.') mibBuilder.exportSymbols("OVERLAND-NEXTGEN", modIndex=modIndex, eventSlaveFailed=eventSlaveFailed, driveStatusEntry=driveStatusEntry, dstState=dstState, eventRequestDriveClean=eventRequestDriveClean, modDesc=modDesc, modNumMailSlots=modNumMailSlots, overlandNotificationGroup=overlandNotificationGroup, eventMailSlotAccessed=eventMailSlotAccessed, overlandAttributesGroup=overlandAttributesGroup, dstCleanRequested=dstCleanRequested, overlandProducts=overlandProducts, dstIndex=dstIndex, overlandReqs=overlandReqs, dstCodeRevDrive=dstCodeRevDrive, moduleGeometryTable=moduleGeometryTable, dstScsiId=dstScsiId, numMailSlots=numMailSlots, dstMotion=dstMotion, overlandNextGenEvents=overlandNextGenEvents, overlandNextGenComponents=overlandNextGenComponents, lstScsiId=lstScsiId, overlandActionGroup=overlandActionGroup, overlandLoopback=overlandLoopback, overlandCaps=overlandCaps, lstIndex=lstIndex, errorTable=errorTable, modConfig=modConfig, lstChangerStatus=lstChangerStatus, numDrives=numDrives, errActionMsg=errActionMsg, overlandGeneric=overlandGeneric, errMsg=errMsg, overlandNextGenState=overlandNextGenState, lstConfig=lstConfig, modStatus=modStatus, eventPowerSupplyFailed=eventPowerSupplyFailed, overlandGlobalRegModule=overlandGlobalRegModule, errSeverity=errSeverity, driveStatusTable=driveStatusTable, overlandStateGroup=overlandStateGroup, errIndex=errIndex, moduleGeometryEntry=moduleGeometryEntry, modFwRev=modFwRev, eventFanStalled=eventFanStalled, errCode=errCode, eventDriveError=eventDriveError, eventDoorOpen=eventDoorOpen, dstRowValid=dstRowValid, eventSlaveRemoved=eventSlaveRemoved, eventFailedOver=eventFailedOver, numModules=numModules, overlandReg=overlandReg, lstLibraryState=lstLibraryState, modNumBins=modNumBins, overlandNextGen=overlandNextGen, libraryStatusTable=libraryStatusTable, overlandNextGenAttributes=overlandNextGenAttributes, numBins=numBins, overlandExpr=overlandExpr, dstCodeRevController=dstCodeRevController, dstSerialNum=dstSerialNum, libraryStatusEntry=libraryStatusEntry, errorEntry=errorEntry, modNumDrives=modNumDrives, overlandRoot=overlandRoot, eventLoaderRetriesExcessive=eventLoaderRetriesExcessive, overlandModules=overlandModules, eventDriveRemoved=eventDriveRemoved, PYSNMP_MODULE_ID=overlandGlobalRegModule, overlandNextGenStatistics=overlandNextGenStatistics, lstStatus=lstStatus, modAttached=modAttached, eventHardFault=eventHardFault, overlandNextGenActions=overlandNextGenActions, overlandNextGenGroups=overlandNextGenGroups)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection') (object_group, module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'ModuleCompliance', 'NotificationGroup') (mib_scalar, mib_table, mib_table_row, mib_table_column, integer32, object_identity, module_identity, notification_type, iso, gauge32, ip_address, bits, mib_identifier, time_ticks, counter64, counter32, unsigned32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32', 'ObjectIdentity', 'ModuleIdentity', 'NotificationType', 'iso', 'Gauge32', 'IpAddress', 'Bits', 'MibIdentifier', 'TimeTicks', 'Counter64', 'Counter32', 'Unsigned32') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') overland_global_reg_module = module_identity((1, 3, 6, 1, 4, 1, 3351, 1, 1, 1, 1)) if mibBuilder.loadTexts: overlandGlobalRegModule.setLastUpdated('9807090845Z') if mibBuilder.loadTexts: overlandGlobalRegModule.setOrganization('Overland Data, Inc.') if mibBuilder.loadTexts: overlandGlobalRegModule.setContactInfo('Robert Kingsley email: bkingsley@overlanddata.com') if mibBuilder.loadTexts: overlandGlobalRegModule.setDescription('The Overland Data central registration module.') overland_root = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1)) overland_reg = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 1)) overland_generic = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 2)) overland_products = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3)) overland_caps = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 4)) overland_reqs = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 5)) overland_expr = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 6)) overland_modules = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 1, 1)) overland_next_gen = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2)) overland_next_gen_actions = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 1)) overland_next_gen_statistics = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 2)) overland_next_gen_state = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3)) overland_next_gen_components = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 4)) overland_next_gen_attributes = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5)) overland_next_gen_events = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6)) overland_next_gen_groups = mib_identifier((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7)) overland_loopback = mib_scalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 1, 1), display_string().subtype(subtypeSpec=value_size_constraint(1, 32))).setMaxAccess('readwrite') if mibBuilder.loadTexts: overlandLoopback.setStatus('current') if mibBuilder.loadTexts: overlandLoopback.setDescription('Sends or retrieves a loopback string to the target.') overland_action_group = object_group((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 1)).setObjects(('OVERLAND-NEXTGEN', 'overlandLoopback')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overland_action_group = overlandActionGroup.setStatus('current') if mibBuilder.loadTexts: overlandActionGroup.setDescription('Current library status which may be queried.') drive_status_table = mib_table((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1)) if mibBuilder.loadTexts: driveStatusTable.setStatus('current') if mibBuilder.loadTexts: driveStatusTable.setDescription('Table containing various drive status.') drive_status_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1)).setIndexNames((0, 'OVERLAND-NEXTGEN', 'dstIndex')) if mibBuilder.loadTexts: driveStatusEntry.setStatus('current') if mibBuilder.loadTexts: driveStatusEntry.setDescription('A row in the drive status table.') dst_row_valid = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: dstRowValid.setStatus('current') if mibBuilder.loadTexts: dstRowValid.setDescription('Provides an INVALID indication if no drives are installed or if the drive type is unknown; otherwise, an indication of the drive type is provided.') dst_index = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 32))).setMaxAccess('readonly') if mibBuilder.loadTexts: dstIndex.setStatus('current') if mibBuilder.loadTexts: dstIndex.setDescription('Index to drive status fields.') dst_state = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4))).clone(namedValues=named_values(('initializedNoError', 0), ('initializedWithError', 1), ('notInitialized', 2), ('notInstalled', 3), ('notInserted', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: dstState.setStatus('current') if mibBuilder.loadTexts: dstState.setDescription('Current state of the drive.') dst_motion = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 4), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: dstMotion.setStatus('current') if mibBuilder.loadTexts: dstMotion.setDescription('ASCII msg describing current drive tape motion.') dst_code_rev_drive = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 5), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: dstCodeRevDrive.setStatus('current') if mibBuilder.loadTexts: dstCodeRevDrive.setDescription('Revision number of the drive code.') dst_code_rev_controller = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 6), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: dstCodeRevController.setStatus('current') if mibBuilder.loadTexts: dstCodeRevController.setDescription('Revision number of the drive controller code.') dst_scsi_id = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(0, 15))).setMaxAccess('readonly') if mibBuilder.loadTexts: dstScsiId.setStatus('current') if mibBuilder.loadTexts: dstScsiId.setDescription('SCSI Id number of drive.') dst_serial_num = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 8), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: dstSerialNum.setStatus('current') if mibBuilder.loadTexts: dstSerialNum.setDescription('Serial number of this drive.') dst_clean_requested = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('cleanNotNeeded', 0), ('cleanNeeded', 1)))).setMaxAccess('readonly') if mibBuilder.loadTexts: dstCleanRequested.setStatus('current') if mibBuilder.loadTexts: dstCleanRequested.setDescription('The drive heads needs to be cleaned with a cleaning cartridge.') library_status_table = mib_table((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2)) if mibBuilder.loadTexts: libraryStatusTable.setStatus('current') if mibBuilder.loadTexts: libraryStatusTable.setDescription('Table containing fault code, severity and ACSII error messages displayed on front panel of library.') library_status_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1)).setIndexNames((0, 'OVERLAND-NEXTGEN', 'lstIndex')) if mibBuilder.loadTexts: libraryStatusEntry.setStatus('current') if mibBuilder.loadTexts: libraryStatusEntry.setDescription('A row in the library status table.') lst_index = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1))).setMaxAccess('readonly') if mibBuilder.loadTexts: lstIndex.setStatus('current') if mibBuilder.loadTexts: lstIndex.setDescription('Index to table of library status.') lst_config = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('standalone', 0), ('multimodule', 1)))).setMaxAccess('readonly') if mibBuilder.loadTexts: lstConfig.setStatus('current') if mibBuilder.loadTexts: lstConfig.setDescription('Indicates if library is standalone or multi-module.') lst_scsi_id = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 15))).setMaxAccess('readonly') if mibBuilder.loadTexts: lstScsiId.setStatus('current') if mibBuilder.loadTexts: lstScsiId.setDescription('Indicates library SCSI bus ID.') lst_status = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 4), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: lstStatus.setStatus('current') if mibBuilder.loadTexts: lstStatus.setDescription('Indication of current library status.') lst_changer_status = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 5), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: lstChangerStatus.setStatus('current') if mibBuilder.loadTexts: lstChangerStatus.setDescription('Bit-mapped indication of current changer status: bit 0 - cartridge map valid bit 1 - initializing bit 2 - door open bit 3 - front panel mode bit 4 - door closed bit 5 - browser mode bit 6 - master busy') lst_library_state = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('initializing', 0), ('online', 1), ('offline', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: lstLibraryState.setStatus('current') if mibBuilder.loadTexts: lstLibraryState.setDescription('Indication of current library state.') error_table = mib_table((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3)) if mibBuilder.loadTexts: errorTable.setStatus('current') if mibBuilder.loadTexts: errorTable.setDescription('Table containing fault code, severity and ACSII error messages displayed on front panel of library.') error_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1)).setIndexNames((0, 'OVERLAND-NEXTGEN', 'errIndex')) if mibBuilder.loadTexts: errorEntry.setStatus('current') if mibBuilder.loadTexts: errorEntry.setDescription('A row in the error info table.') err_index = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1))).setMaxAccess('readonly') if mibBuilder.loadTexts: errIndex.setStatus('current') if mibBuilder.loadTexts: errIndex.setDescription('Index to table of library error information.') err_code = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: errCode.setStatus('current') if mibBuilder.loadTexts: errCode.setDescription('Hex code unique to the reported error.') err_severity = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('informational', 0), ('mild', 1), ('hard', 2), ('severe', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: errSeverity.setStatus('current') if mibBuilder.loadTexts: errSeverity.setDescription('Indication of how serious the reported error is: 0 = informational error, not very severe 1 = mild error, operator intervention not necessary 2 = hard error, may be corrected remotely 3 = very severe, power cycle required to clear') err_msg = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 4), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: errMsg.setStatus('current') if mibBuilder.loadTexts: errMsg.setDescription('ASCII message naming the current error.') err_action_msg = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 3, 3, 1, 5), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: errActionMsg.setStatus('current') if mibBuilder.loadTexts: errActionMsg.setDescription('ASCII message providing additional information about current error and possibly some suggestions for correcting it.') overland_state_group = object_group((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 3)).setObjects(('OVERLAND-NEXTGEN', 'errIndex'), ('OVERLAND-NEXTGEN', 'errCode'), ('OVERLAND-NEXTGEN', 'errSeverity'), ('OVERLAND-NEXTGEN', 'errMsg'), ('OVERLAND-NEXTGEN', 'errActionMsg'), ('OVERLAND-NEXTGEN', 'dstRowValid'), ('OVERLAND-NEXTGEN', 'dstIndex'), ('OVERLAND-NEXTGEN', 'dstState'), ('OVERLAND-NEXTGEN', 'dstMotion'), ('OVERLAND-NEXTGEN', 'dstCodeRevDrive'), ('OVERLAND-NEXTGEN', 'dstCodeRevController'), ('OVERLAND-NEXTGEN', 'dstScsiId'), ('OVERLAND-NEXTGEN', 'dstSerialNum'), ('OVERLAND-NEXTGEN', 'dstCleanRequested'), ('OVERLAND-NEXTGEN', 'lstIndex'), ('OVERLAND-NEXTGEN', 'lstConfig'), ('OVERLAND-NEXTGEN', 'lstScsiId'), ('OVERLAND-NEXTGEN', 'lstStatus'), ('OVERLAND-NEXTGEN', 'lstChangerStatus'), ('OVERLAND-NEXTGEN', 'lstLibraryState')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overland_state_group = overlandStateGroup.setStatus('current') if mibBuilder.loadTexts: overlandStateGroup.setDescription('Current library states which may be queried.') num_modules = mib_scalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 256))).setMaxAccess('readonly') if mibBuilder.loadTexts: numModules.setStatus('current') if mibBuilder.loadTexts: numModules.setDescription('Reads the total number of modules available in the attached library.') num_bins = mib_scalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 256))).setMaxAccess('readonly') if mibBuilder.loadTexts: numBins.setStatus('current') if mibBuilder.loadTexts: numBins.setDescription('Reads the total number of cartridge storage slots available in the attached library.') num_drives = mib_scalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 128))).setMaxAccess('readonly') if mibBuilder.loadTexts: numDrives.setStatus('current') if mibBuilder.loadTexts: numDrives.setDescription('Reads the total number of drives available in the attached library.') num_mail_slots = mib_scalar((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 4), integer32().subtype(subtypeSpec=value_range_constraint(0, 15))).setMaxAccess('readonly') if mibBuilder.loadTexts: numMailSlots.setStatus('current') if mibBuilder.loadTexts: numMailSlots.setDescription('Returns the total number of mail slots available in the attached library.') module_geometry_table = mib_table((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5)) if mibBuilder.loadTexts: moduleGeometryTable.setStatus('current') if mibBuilder.loadTexts: moduleGeometryTable.setDescription('Table containing library module geometry.') module_geometry_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1)).setIndexNames((0, 'OVERLAND-NEXTGEN', 'modIndex')) if mibBuilder.loadTexts: moduleGeometryEntry.setStatus('current') if mibBuilder.loadTexts: moduleGeometryEntry.setDescription('A row in the library module geometry table.') mod_desc = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: modDesc.setStatus('current') if mibBuilder.loadTexts: modDesc.setDescription('If library geometry is valid, an ASCII message desribing the module.') mod_index = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 2), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(0, 7), value_range_constraint(8, 8)))).setMaxAccess('readonly') if mibBuilder.loadTexts: modIndex.setStatus('current') if mibBuilder.loadTexts: modIndex.setDescription('Index to table of library module geometry: 8 = Master or Standalone module 0-7 = Slave Module') mod_attached = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('isNotAttached', 0), ('isAttached', 1)))).setMaxAccess('readonly') if mibBuilder.loadTexts: modAttached.setStatus('current') if mibBuilder.loadTexts: modAttached.setDescription('Indication of whether or not module is attached.') mod_status = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 4), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: modStatus.setStatus('current') if mibBuilder.loadTexts: modStatus.setDescription('ASCII message desribing the current status of the module.') mod_config = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('unknown', 0), ('lightning', 1), ('thunder', 2), ('invalid', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: modConfig.setStatus('current') if mibBuilder.loadTexts: modConfig.setDescription("Indication of this module's type.") mod_fw_rev = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 6), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: modFwRev.setStatus('current') if mibBuilder.loadTexts: modFwRev.setDescription("Indication of this module's firmware revision level.") mod_num_bins = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 7), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: modNumBins.setStatus('current') if mibBuilder.loadTexts: modNumBins.setDescription('Indication of the number of bins within this module.') mod_num_drives = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: modNumDrives.setStatus('current') if mibBuilder.loadTexts: modNumDrives.setDescription('Indication of the number of drives within this module.') mod_num_mail_slots = mib_table_column((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 5, 5, 1, 9), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: modNumMailSlots.setStatus('current') if mibBuilder.loadTexts: modNumMailSlots.setDescription('Indication of the number of mailslots within this module.') overland_attributes_group = object_group((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 4)).setObjects(('OVERLAND-NEXTGEN', 'numModules'), ('OVERLAND-NEXTGEN', 'numBins'), ('OVERLAND-NEXTGEN', 'numDrives'), ('OVERLAND-NEXTGEN', 'numMailSlots'), ('OVERLAND-NEXTGEN', 'modDesc'), ('OVERLAND-NEXTGEN', 'modIndex'), ('OVERLAND-NEXTGEN', 'modAttached'), ('OVERLAND-NEXTGEN', 'modStatus'), ('OVERLAND-NEXTGEN', 'modConfig'), ('OVERLAND-NEXTGEN', 'modFwRev'), ('OVERLAND-NEXTGEN', 'modNumBins'), ('OVERLAND-NEXTGEN', 'modNumDrives'), ('OVERLAND-NEXTGEN', 'modNumMailSlots')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overland_attributes_group = overlandAttributesGroup.setStatus('current') if mibBuilder.loadTexts: overlandAttributesGroup.setDescription('Current library info which may be queried.') event_door_open = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 1)) if mibBuilder.loadTexts: eventDoorOpen.setStatus('current') if mibBuilder.loadTexts: eventDoorOpen.setDescription('A library door has been opened.') event_mail_slot_accessed = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 2)) if mibBuilder.loadTexts: eventMailSlotAccessed.setStatus('current') if mibBuilder.loadTexts: eventMailSlotAccessed.setDescription('A mail slot is being accessed.') event_hard_fault = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 3)) if mibBuilder.loadTexts: eventHardFault.setStatus('current') if mibBuilder.loadTexts: eventHardFault.setDescription('The library has posted a hard fault.') event_slave_failed = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 4)) if mibBuilder.loadTexts: eventSlaveFailed.setStatus('current') if mibBuilder.loadTexts: eventSlaveFailed.setDescription('A slave module has faulted.') event_power_supply_failed = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 5)) if mibBuilder.loadTexts: eventPowerSupplyFailed.setStatus('current') if mibBuilder.loadTexts: eventPowerSupplyFailed.setDescription('One of the redundant power supplies has failed.') event_request_drive_clean = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 6)) if mibBuilder.loadTexts: eventRequestDriveClean.setStatus('current') if mibBuilder.loadTexts: eventRequestDriveClean.setDescription('One of the library tape drives has requested a cleaning cycle to ensure continued data reliability.') event_fan_stalled = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 7)) if mibBuilder.loadTexts: eventFanStalled.setStatus('current') if mibBuilder.loadTexts: eventFanStalled.setDescription('A tape drive fan has stalled.') event_drive_error = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 8)) if mibBuilder.loadTexts: eventDriveError.setStatus('current') if mibBuilder.loadTexts: eventDriveError.setDescription('A tape drive error has occurred.') event_drive_removed = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 9)) if mibBuilder.loadTexts: eventDriveRemoved.setStatus('current') if mibBuilder.loadTexts: eventDriveRemoved.setDescription('A tape drive has been removed from the library.') event_slave_removed = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 10)) if mibBuilder.loadTexts: eventSlaveRemoved.setStatus('current') if mibBuilder.loadTexts: eventSlaveRemoved.setDescription('A slave module has been removed from the library.') event_failed_over = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 11)) if mibBuilder.loadTexts: eventFailedOver.setStatus('current') if mibBuilder.loadTexts: eventFailedOver.setDescription('The library is failed over to the Secondary Master.') event_loader_retries_excessive = notification_type((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 6, 12)) if mibBuilder.loadTexts: eventLoaderRetriesExcessive.setStatus('current') if mibBuilder.loadTexts: eventLoaderRetriesExcessive.setDescription('The library has detected excessive loader retries.') overland_notification_group = notification_group((1, 3, 6, 1, 4, 1, 3351, 1, 3, 2, 7, 7)).setObjects(('OVERLAND-NEXTGEN', 'eventDoorOpen'), ('OVERLAND-NEXTGEN', 'eventMailSlotAccessed'), ('OVERLAND-NEXTGEN', 'eventHardFault'), ('OVERLAND-NEXTGEN', 'eventSlaveFailed'), ('OVERLAND-NEXTGEN', 'eventPowerSupplyFailed'), ('OVERLAND-NEXTGEN', 'eventRequestDriveClean'), ('OVERLAND-NEXTGEN', 'eventFanStalled'), ('OVERLAND-NEXTGEN', 'eventDriveError'), ('OVERLAND-NEXTGEN', 'eventDriveRemoved'), ('OVERLAND-NEXTGEN', 'eventSlaveRemoved'), ('OVERLAND-NEXTGEN', 'eventFailedOver'), ('OVERLAND-NEXTGEN', 'eventLoaderRetriesExcessive')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): overland_notification_group = overlandNotificationGroup.setStatus('current') if mibBuilder.loadTexts: overlandNotificationGroup.setDescription('Trap events returned by the browser.') mibBuilder.exportSymbols('OVERLAND-NEXTGEN', modIndex=modIndex, eventSlaveFailed=eventSlaveFailed, driveStatusEntry=driveStatusEntry, dstState=dstState, eventRequestDriveClean=eventRequestDriveClean, modDesc=modDesc, modNumMailSlots=modNumMailSlots, overlandNotificationGroup=overlandNotificationGroup, eventMailSlotAccessed=eventMailSlotAccessed, overlandAttributesGroup=overlandAttributesGroup, dstCleanRequested=dstCleanRequested, overlandProducts=overlandProducts, dstIndex=dstIndex, overlandReqs=overlandReqs, dstCodeRevDrive=dstCodeRevDrive, moduleGeometryTable=moduleGeometryTable, dstScsiId=dstScsiId, numMailSlots=numMailSlots, dstMotion=dstMotion, overlandNextGenEvents=overlandNextGenEvents, overlandNextGenComponents=overlandNextGenComponents, lstScsiId=lstScsiId, overlandActionGroup=overlandActionGroup, overlandLoopback=overlandLoopback, overlandCaps=overlandCaps, lstIndex=lstIndex, errorTable=errorTable, modConfig=modConfig, lstChangerStatus=lstChangerStatus, numDrives=numDrives, errActionMsg=errActionMsg, overlandGeneric=overlandGeneric, errMsg=errMsg, overlandNextGenState=overlandNextGenState, lstConfig=lstConfig, modStatus=modStatus, eventPowerSupplyFailed=eventPowerSupplyFailed, overlandGlobalRegModule=overlandGlobalRegModule, errSeverity=errSeverity, driveStatusTable=driveStatusTable, overlandStateGroup=overlandStateGroup, errIndex=errIndex, moduleGeometryEntry=moduleGeometryEntry, modFwRev=modFwRev, eventFanStalled=eventFanStalled, errCode=errCode, eventDriveError=eventDriveError, eventDoorOpen=eventDoorOpen, dstRowValid=dstRowValid, eventSlaveRemoved=eventSlaveRemoved, eventFailedOver=eventFailedOver, numModules=numModules, overlandReg=overlandReg, lstLibraryState=lstLibraryState, modNumBins=modNumBins, overlandNextGen=overlandNextGen, libraryStatusTable=libraryStatusTable, overlandNextGenAttributes=overlandNextGenAttributes, numBins=numBins, overlandExpr=overlandExpr, dstCodeRevController=dstCodeRevController, dstSerialNum=dstSerialNum, libraryStatusEntry=libraryStatusEntry, errorEntry=errorEntry, modNumDrives=modNumDrives, overlandRoot=overlandRoot, eventLoaderRetriesExcessive=eventLoaderRetriesExcessive, overlandModules=overlandModules, eventDriveRemoved=eventDriveRemoved, PYSNMP_MODULE_ID=overlandGlobalRegModule, overlandNextGenStatistics=overlandNextGenStatistics, lstStatus=lstStatus, modAttached=modAttached, eventHardFault=eventHardFault, overlandNextGenActions=overlandNextGenActions, overlandNextGenGroups=overlandNextGenGroups)
class Solution: def diStringMatch(self, S: str): l = 0 r = len(S) ret = [] for i in S: if i == "I": ret.append(l) l += 1 else: ret.append(r) r -= 1 ret.append(r) return ret slu = Solution() print(slu.diStringMatch("III"))
class Solution: def di_string_match(self, S: str): l = 0 r = len(S) ret = [] for i in S: if i == 'I': ret.append(l) l += 1 else: ret.append(r) r -= 1 ret.append(r) return ret slu = solution() print(slu.diStringMatch('III'))
#CONSIDER: composable authorizations class Authorization(object): ''' Base authorization class, defaults to full authorization ''' #CONSIDER: how is this notified about filtering, ids, etc def __init__(self, identity, endpoint): self.identity = identity self.endpoint = endpoint def process_queryset(self, queryset): return queryset def is_authorized(self): return True class AuthorizationMixin(object): def make_authorization(self, identity, endpoint): return Authorization(identity, endpoint) def get_identity(self): #TODO delegate return self.request.user def is_authenticated(self): return self.authorization.is_authorized() def handle(self, endpoint, *args, **kwargs): self.identity = self.get_identity() self.authorization = self.make_authorization(self.identity, endpoint) return super(AuthorizationMixin, self).handle(endpoint, *args, **kwargs) class DjangoModelAuthorization(Authorization): ''' Your basic django core permission based authorization ''' def __init__(self, identity, model, endpoint): super(DjangoModelAuthorization, self).__init__(identity, endpoint) self.model = model def is_authorized(self): #print("auth identity:", self.identity) if self.identity.is_superuser: return True #TODO proper lookup of label? if self.endpoint == 'list': return True #TODO in django fashion, you have list if you have add, change, or delete return self.identity.has_perm perm_name = self.model._meta.app_label + '.' if self.endpoint == 'create': perm_name += 'add' elif self.endpoint == 'update': perm_name += 'change' else: #TODO delete_list? update_list? others? perm_name += self.endpoint perm_name += '_' + self.model.__name__ return self.identity.has_perm(perm_name) class ModelAuthorizationMixin(AuthorizationMixin): def make_authorization(self, identity, endpoint): return DjangoModelAuthorization(identity, self.model, endpoint)
class Authorization(object): """ Base authorization class, defaults to full authorization """ def __init__(self, identity, endpoint): self.identity = identity self.endpoint = endpoint def process_queryset(self, queryset): return queryset def is_authorized(self): return True class Authorizationmixin(object): def make_authorization(self, identity, endpoint): return authorization(identity, endpoint) def get_identity(self): return self.request.user def is_authenticated(self): return self.authorization.is_authorized() def handle(self, endpoint, *args, **kwargs): self.identity = self.get_identity() self.authorization = self.make_authorization(self.identity, endpoint) return super(AuthorizationMixin, self).handle(endpoint, *args, **kwargs) class Djangomodelauthorization(Authorization): """ Your basic django core permission based authorization """ def __init__(self, identity, model, endpoint): super(DjangoModelAuthorization, self).__init__(identity, endpoint) self.model = model def is_authorized(self): if self.identity.is_superuser: return True if self.endpoint == 'list': return True return self.identity.has_perm perm_name = self.model._meta.app_label + '.' if self.endpoint == 'create': perm_name += 'add' elif self.endpoint == 'update': perm_name += 'change' else: perm_name += self.endpoint perm_name += '_' + self.model.__name__ return self.identity.has_perm(perm_name) class Modelauthorizationmixin(AuthorizationMixin): def make_authorization(self, identity, endpoint): return django_model_authorization(identity, self.model, endpoint)
# Len of signature in write signed packet SIGNATURE_LEN = 12 # Attribute Protocol Opcodes OP_ERROR = 0x01 OP_MTU_REQ = 0x02 OP_MTU_RESP = 0x03 OP_FIND_INFO_REQ = 0x04 OP_FIND_INFO_RESP = 0x05 OP_FIND_BY_TYPE_REQ = 0x06 OP_FIND_BY_TYPE_RESP= 0x07 OP_READ_BY_TYPE_REQ = 0x08 OP_READ_BY_TYPE_RESP = 0x09 OP_READ_REQ = 0x0A OP_READ_RESP = 0x0B OP_READ_BLOB_REQ = 0x0C OP_READ_BLOB_RESP = 0x0D OP_READ_MULTI_REQ = 0x0E OP_READ_MULTI_RESP = 0x0F OP_READ_BY_GROUP_REQ = 0x10 OP_READ_BY_GROUP_RESP = 0x11 OP_WRITE_REQ = 0x12 OP_WRITE_RESP = 0x13 OP_WRITE_CMD = 0x52 OP_PREP_WRITE_REQ = 0x16 OP_PREP_WRITE_RESP = 0x17 OP_EXEC_WRITE_REQ = 0x18 OP_EXEC_WRITE_RESP = 0x19 OP_HANDLE_NOTIFY = 0x1B OP_HANDLE_IND = 0x1D OP_HANDLE_CNF = 0x1E OP_SIGNED_WRITE_CMD = 0xD2 __STRING_TO_OPCODE = { "ERROR" : 0x01, "MTU_REQ" : 0x02, "MTU_RESP" : 0x03, "FIND_INFO_REQ" : 0x04, "FIND_INFO_RESP" : 0x05, "FIND_BY_TYPE_REQ" : 0x06, "FIND_BY_TYPE_RESP" : 0x07, "READ_BY_TYPE_REQ" : 0x08, "READ_BY_TYPE_RESP" : 0x09, "READ_REQ" : 0x0A, "READ_RESP" : 0x0B, "READ_BLOB_REQ" : 0x0C, "READ_BLOB_RESP" : 0x0D, "READ_MULTI_REQ" : 0x0E, "READ_MULTI_RESP" : 0x0F, "READ_BY_GROUP_REQ" : 0x10, "READ_BY_GROUP_RESP" : 0x11, "WRITE_REQ" : 0x12, "WRITE_RESP" : 0x13, "WRITE_CMD" : 0x52, "PREP_WRITE_REQ" : 0x16, "PREP_WRITE_RESP" : 0x17, "EXEC_WRITE_REQ" : 0x18, "EXEC_WRITE_RESP" : 0x19, "HANDLE_NOTIFY" : 0x1B, "HANDLE_IND" : 0x1D, "HANDLE_CNF" : 0x1E, "SIGNED_WRITE_CMD" : 0xD2, } __OPCODE_TO_STRING = { v: k for k, v in __STRING_TO_OPCODE.items() } def opcodeLookup(opcode): return __OPCODE_TO_STRING[opcode] if opcode in __OPCODE_TO_STRING \ else "unknown" __OP_COMMAND = frozenset((OP_WRITE_CMD, OP_SIGNED_WRITE_CMD)) def isCommand(opcode): return opcode in __OP_COMMAND __OP_REQUEST = frozenset(( OP_MTU_REQ, OP_FIND_INFO_REQ, OP_FIND_BY_TYPE_REQ, OP_READ_BY_TYPE_REQ, OP_READ_REQ, OP_READ_BLOB_REQ, OP_READ_MULTI_REQ, OP_READ_BY_GROUP_REQ, OP_WRITE_REQ, OP_PREP_WRITE_REQ, OP_EXEC_WRITE_REQ, )) def isRequest(opcode): return opcode in __OP_REQUEST __OP_RESPONSE = frozenset(( OP_MTU_RESP, OP_FIND_INFO_RESP, OP_FIND_BY_TYPE_RESP, OP_READ_BY_TYPE_RESP, OP_READ_RESP, OP_READ_BLOB_RESP, OP_READ_MULTI_RESP, OP_READ_BY_GROUP_RESP, OP_WRITE_RESP, OP_PREP_WRITE_RESP, OP_EXEC_WRITE_RESP, )) def isResponse(opcode): return opcode in __OP_RESPONSE # Error codes for Error response PDU ECODE_INVALID_HANDLE = 0x01 ECODE_READ_NOT_PERM = 0x02 ECODE_WRITE_NOT_PERM = 0x03 ECODE_INVALID_PDU = 0x04 ECODE_AUTHENTICATION = 0x05 ECODE_REQ_NOT_SUPP = 0x06 ECODE_INVALID_OFFSET = 0x07 ECODE_AUTHORIZATION = 0x08 ECODE_PREP_QUEUE_FULL = 0x09 ECODE_ATTR_NOT_FOUND = 0x0A ECODE_ATTR_NOT_LONG = 0x0B ECODE_INSUFF_ENCR_KEY_SIZE = 0x0C ECODE_INVAL_ATTR_VALUE_LEN = 0x0D ECODE_UNLIKELY = 0x0E ECODE_INSUFF_ENC = 0x0F ECODE_UNSUPP_GRP_TYPE = 0x10 ECODE_INSUFF_RESOURCES = 0x11 # Application error ECODE_IO = 0x80 ECODE_TIMEOUT = 0x81 ECODE_ABORTED = 0x82 __STRING_TO_ECODE = { "INVALID_HANDLE" : 0x01, "READ_NOT_PERM" : 0x02, "WRITE_NOT_PERM" : 0x03, "INVALID_PDU" : 0x04, "AUTHENTICATION" : 0x05, "REQ_NOT_SUPP" : 0x06, "INVALID_OFFSET" : 0x07, "AUTHORIZATION" : 0x08, "PREP_QUEUE_FULL" : 0x09, "ATTR_NOT_FOUND" : 0x0A, "ATTR_NOT_LONG" : 0x0B, "INSUFF_ENCR_KEY_SIZE" : 0x0C, "INVAL_ATTR_VALUE_LEN" : 0x0D, "UNLIKELY" : 0x0E, "INSUFF_ENC" : 0x0F, "UNSUPP_GRP_TYPE" : 0x10, "INSUFF_RESOURCES" : 0x11, "IO" : 0x80, "TIMEOUT" : 0x81, "ABORTED" : 0x82, } __ECODE_TO_STRING = { v: k for k, v in __STRING_TO_ECODE.items() } def ecodeLookup(ecode): return __ECODE_TO_STRING[ecode] if ecode in __ECODE_TO_STRING else "unknown" MAX_VALUE_LEN = 512 DEFAULT_L2CAP_MTU = 48 DEFAULT_LE_MTU = 23 CID = 4 PSM = 31 # Flags for Execute Write Request Operation CANCEL_ALL_PREP_WRITES = 0x00 WRITE_ALL_PREP_WRITES = 0x01 # Find Information Response Formats FIND_INFO_RESP_FMT_16BIT = 0x01 FIND_INFO_RESP_FMT_128BIT = 0x02
signature_len = 12 op_error = 1 op_mtu_req = 2 op_mtu_resp = 3 op_find_info_req = 4 op_find_info_resp = 5 op_find_by_type_req = 6 op_find_by_type_resp = 7 op_read_by_type_req = 8 op_read_by_type_resp = 9 op_read_req = 10 op_read_resp = 11 op_read_blob_req = 12 op_read_blob_resp = 13 op_read_multi_req = 14 op_read_multi_resp = 15 op_read_by_group_req = 16 op_read_by_group_resp = 17 op_write_req = 18 op_write_resp = 19 op_write_cmd = 82 op_prep_write_req = 22 op_prep_write_resp = 23 op_exec_write_req = 24 op_exec_write_resp = 25 op_handle_notify = 27 op_handle_ind = 29 op_handle_cnf = 30 op_signed_write_cmd = 210 __string_to_opcode = {'ERROR': 1, 'MTU_REQ': 2, 'MTU_RESP': 3, 'FIND_INFO_REQ': 4, 'FIND_INFO_RESP': 5, 'FIND_BY_TYPE_REQ': 6, 'FIND_BY_TYPE_RESP': 7, 'READ_BY_TYPE_REQ': 8, 'READ_BY_TYPE_RESP': 9, 'READ_REQ': 10, 'READ_RESP': 11, 'READ_BLOB_REQ': 12, 'READ_BLOB_RESP': 13, 'READ_MULTI_REQ': 14, 'READ_MULTI_RESP': 15, 'READ_BY_GROUP_REQ': 16, 'READ_BY_GROUP_RESP': 17, 'WRITE_REQ': 18, 'WRITE_RESP': 19, 'WRITE_CMD': 82, 'PREP_WRITE_REQ': 22, 'PREP_WRITE_RESP': 23, 'EXEC_WRITE_REQ': 24, 'EXEC_WRITE_RESP': 25, 'HANDLE_NOTIFY': 27, 'HANDLE_IND': 29, 'HANDLE_CNF': 30, 'SIGNED_WRITE_CMD': 210} __opcode_to_string = {v: k for (k, v) in __STRING_TO_OPCODE.items()} def opcode_lookup(opcode): return __OPCODE_TO_STRING[opcode] if opcode in __OPCODE_TO_STRING else 'unknown' __op_command = frozenset((OP_WRITE_CMD, OP_SIGNED_WRITE_CMD)) def is_command(opcode): return opcode in __OP_COMMAND __op_request = frozenset((OP_MTU_REQ, OP_FIND_INFO_REQ, OP_FIND_BY_TYPE_REQ, OP_READ_BY_TYPE_REQ, OP_READ_REQ, OP_READ_BLOB_REQ, OP_READ_MULTI_REQ, OP_READ_BY_GROUP_REQ, OP_WRITE_REQ, OP_PREP_WRITE_REQ, OP_EXEC_WRITE_REQ)) def is_request(opcode): return opcode in __OP_REQUEST __op_response = frozenset((OP_MTU_RESP, OP_FIND_INFO_RESP, OP_FIND_BY_TYPE_RESP, OP_READ_BY_TYPE_RESP, OP_READ_RESP, OP_READ_BLOB_RESP, OP_READ_MULTI_RESP, OP_READ_BY_GROUP_RESP, OP_WRITE_RESP, OP_PREP_WRITE_RESP, OP_EXEC_WRITE_RESP)) def is_response(opcode): return opcode in __OP_RESPONSE ecode_invalid_handle = 1 ecode_read_not_perm = 2 ecode_write_not_perm = 3 ecode_invalid_pdu = 4 ecode_authentication = 5 ecode_req_not_supp = 6 ecode_invalid_offset = 7 ecode_authorization = 8 ecode_prep_queue_full = 9 ecode_attr_not_found = 10 ecode_attr_not_long = 11 ecode_insuff_encr_key_size = 12 ecode_inval_attr_value_len = 13 ecode_unlikely = 14 ecode_insuff_enc = 15 ecode_unsupp_grp_type = 16 ecode_insuff_resources = 17 ecode_io = 128 ecode_timeout = 129 ecode_aborted = 130 __string_to_ecode = {'INVALID_HANDLE': 1, 'READ_NOT_PERM': 2, 'WRITE_NOT_PERM': 3, 'INVALID_PDU': 4, 'AUTHENTICATION': 5, 'REQ_NOT_SUPP': 6, 'INVALID_OFFSET': 7, 'AUTHORIZATION': 8, 'PREP_QUEUE_FULL': 9, 'ATTR_NOT_FOUND': 10, 'ATTR_NOT_LONG': 11, 'INSUFF_ENCR_KEY_SIZE': 12, 'INVAL_ATTR_VALUE_LEN': 13, 'UNLIKELY': 14, 'INSUFF_ENC': 15, 'UNSUPP_GRP_TYPE': 16, 'INSUFF_RESOURCES': 17, 'IO': 128, 'TIMEOUT': 129, 'ABORTED': 130} __ecode_to_string = {v: k for (k, v) in __STRING_TO_ECODE.items()} def ecode_lookup(ecode): return __ECODE_TO_STRING[ecode] if ecode in __ECODE_TO_STRING else 'unknown' max_value_len = 512 default_l2_cap_mtu = 48 default_le_mtu = 23 cid = 4 psm = 31 cancel_all_prep_writes = 0 write_all_prep_writes = 1 find_info_resp_fmt_16_bit = 1 find_info_resp_fmt_128_bit = 2
''' Description: ------------ When objects are instantiated, the object itself is passed into the self parameter. The Object is passed into the self parameter so that the object can keep hold of its own data. ''' print(__doc__) print('-'*25) class State(object): def __init__(self): global x x=self.field = 5.0 def add(self, x): self.field += x def mul(self, x): self.field *= x def div(self, x): self.field /= x def sub(self, x): self.field -= x n=int(input('Enter a valued: ')) s = State() print(f"\nAfter intializing the varaiable, the value of variable is: {s.field}") s.add(n) # Self is implicitly passed. print(f"\nAddition of the initalized variable {x} with {n} is: {s.field}") s.mul(n) # Self is implicitly passed. print(f"\nMultiplication of the initalized variable {x} with {n} is: {s.field}") s.div(n) # Self is implicitly passed. print(f"\nSubtraction of the initalized variable {x} with {n} is: {s.field}") s.sub(n) # Self is implicitly passed. print(f"\nDivision of the initalized variable {x} with {n} is: {s.field}")
""" Description: ------------ When objects are instantiated, the object itself is passed into the self parameter. The Object is passed into the self parameter so that the object can keep hold of its own data. """ print(__doc__) print('-' * 25) class State(object): def __init__(self): global x x = self.field = 5.0 def add(self, x): self.field += x def mul(self, x): self.field *= x def div(self, x): self.field /= x def sub(self, x): self.field -= x n = int(input('Enter a valued: ')) s = state() print(f'\nAfter intializing the varaiable, the value of variable is: {s.field}') s.add(n) print(f'\nAddition of the initalized variable {x} with {n} is: {s.field}') s.mul(n) print(f'\nMultiplication of the initalized variable {x} with {n} is: {s.field}') s.div(n) print(f'\nSubtraction of the initalized variable {x} with {n} is: {s.field}') s.sub(n) print(f'\nDivision of the initalized variable {x} with {n} is: {s.field}')
# # @lc app=leetcode id=611 lang=python3 # # [611] Valid Triangle Number # # https://leetcode.com/problems/valid-triangle-number/description/ # # algorithms # Medium (49.73%) # Likes: 1857 # Dislikes: 129 # Total Accepted: 109.5K # Total Submissions: 222.7K # Testcase Example: '[2,2,3,4]' # # Given an integer array nums, return the number of triplets chosen from the # array that can make triangles if we take them as side lengths of a # triangle. # # # Example 1: # # # Input: nums = [2,2,3,4] # Output: 3 # Explanation: Valid combinations are: # 2,3,4 (using the first 2) # 2,3,4 (using the second 2) # 2,2,3 # # # Example 2: # # # Input: nums = [4,2,3,4] # Output: 4 # # # # Constraints: # # # 1 <= nums.length <= 1000 # 0 <= nums[i] <= 1000 # # # # @lc code=start class Solution: def triangleNumber(self, nums: List[int]) -> int: if not nums or len(nums) <= 2: return 0 nums.sort() count = 0 for i in range(len(nums) - 1, 1, -1): delta = self.two_sum_greater(nums, 0, i - 1, nums[i]) count += delta return count def two_sum_greater(self, nums, start, end, target): delta = 0 while start <= end: if nums[start] + nums[end] > target: delta += end - start end -= 1 else: start += 1 return delta # solve using DFS, print out all possible combination def triangleNumber_DFS(self, nums: List[int]) -> int: if not nums or len(nums) < 3: return 0 self.ret = 0 self.tmp = [] self.used = [False for _ in range(len(nums))] nums.sort() self._dfs(nums, 0, []) # print(self.tmp) return self.ret def _dfs(self, nums, start, curr): if len(curr) > 3: return if len(curr) == 3: if curr[0] + curr[1] > curr[2]: self.ret += 1 self.tmp.append(curr[:]) return for i in range(start, len(nums)): self.used[i] = True curr.append(nums[i]) self._dfs(nums, i + 1, curr) curr.pop() self.used[i] = False # @lc code=end
class Solution: def triangle_number(self, nums: List[int]) -> int: if not nums or len(nums) <= 2: return 0 nums.sort() count = 0 for i in range(len(nums) - 1, 1, -1): delta = self.two_sum_greater(nums, 0, i - 1, nums[i]) count += delta return count def two_sum_greater(self, nums, start, end, target): delta = 0 while start <= end: if nums[start] + nums[end] > target: delta += end - start end -= 1 else: start += 1 return delta def triangle_number_dfs(self, nums: List[int]) -> int: if not nums or len(nums) < 3: return 0 self.ret = 0 self.tmp = [] self.used = [False for _ in range(len(nums))] nums.sort() self._dfs(nums, 0, []) return self.ret def _dfs(self, nums, start, curr): if len(curr) > 3: return if len(curr) == 3: if curr[0] + curr[1] > curr[2]: self.ret += 1 self.tmp.append(curr[:]) return for i in range(start, len(nums)): self.used[i] = True curr.append(nums[i]) self._dfs(nums, i + 1, curr) curr.pop() self.used[i] = False
# Computers are fast, so we can implement a brute-force search to directly solve the problem. def compute(): PERIMETER = 1000 for a in range(1, PERIMETER + 1): for b in range(a + 1, PERIMETER + 1): c = PERIMETER - a - b if a * a + b * b == c * c: # It is now implied that b < c, because we have a > 0 return str(a * b * c) if __name__ == "__main__": print(compute())
def compute(): perimeter = 1000 for a in range(1, PERIMETER + 1): for b in range(a + 1, PERIMETER + 1): c = PERIMETER - a - b if a * a + b * b == c * c: return str(a * b * c) if __name__ == '__main__': print(compute())
{ "targets": [ { "target_name": "yolo", "sources": [ "src/yolo.cc" ] } ] }
{'targets': [{'target_name': 'yolo', 'sources': ['src/yolo.cc']}]}
class Docs(object): def __init__(self, conn): self.client = conn.client def size(self): r = self.client.get('/docs/size') return int(r.text) def add(self, name, content): self.client.post('/docs', files={'upload': (name, content)}) def clear(self): self.client.delete('/docs') def get(self, name, stream=False, chunk_size=10240): with self.client.get('/docs/{}'.format(name), stream=stream) as r: yield r.iter_content( chunk_size=chunk_size) if stream else r.content def delete(self, name): self.client.delete('/docs/{}'.format(name))
class Docs(object): def __init__(self, conn): self.client = conn.client def size(self): r = self.client.get('/docs/size') return int(r.text) def add(self, name, content): self.client.post('/docs', files={'upload': (name, content)}) def clear(self): self.client.delete('/docs') def get(self, name, stream=False, chunk_size=10240): with self.client.get('/docs/{}'.format(name), stream=stream) as r: yield (r.iter_content(chunk_size=chunk_size) if stream else r.content) def delete(self, name): self.client.delete('/docs/{}'.format(name))
#!/bin/env python3 option = input("[E]ncryption, [D]ecryption, or [Q]uit -- ") def key_generation(a, b, a1, b1): M = a * b - 1 e = a1 * M + a d = b1 * M + b n = (e * d - 1) / M return int(e), int(d), int(n) def encryption(a, b, a1, b1): e, d, n = key_generation(a, b, a1, b1) print("You may publish your public key (n,e) = (", n, ", ", e, ")") print("and keep your private key (n,d) = (",n, ", ", d, ") secret.") plaintext = input("Plaintext - ") cipher = [] for i in range(len(plaintext)): cipher.append(str((ord(plaintext[i]) * e) % n)) ciphertext = " ".join(cipher) print(ciphertext) def decryption(): private = input("Your private key (n, d), separated by a space or comma -- ").replace(",", " ") n, d = list(map(int, private.split(" "))) ciphertext = input("Ciphertext (integers separated by spaces) -- ") cipher = list(map(int, ciphertext.split(" "))) plain = [] for i in range(len(cipher)): plain.append(str((cipher[i] * d) % n)) print(" ".join(plain)) plaintext = "" for i in range(len(plain)): plaintext += chr(int(plain[i])) print("Plaintext - ", plaintext) def main(): if option.upper() == "E": ints = input("Input 4 integers a, b, a', b' -- ") a, b, a1, b1 = list(map(int, ints.split(" "))) encryption(a, b, a1, b1) elif option.upper() == "D": decryption() else: return if __name__ == "__main__": main()
option = input('[E]ncryption, [D]ecryption, or [Q]uit -- ') def key_generation(a, b, a1, b1): m = a * b - 1 e = a1 * M + a d = b1 * M + b n = (e * d - 1) / M return (int(e), int(d), int(n)) def encryption(a, b, a1, b1): (e, d, n) = key_generation(a, b, a1, b1) print('You may publish your public key (n,e) = (', n, ', ', e, ')') print('and keep your private key (n,d) = (', n, ', ', d, ') secret.') plaintext = input('Plaintext - ') cipher = [] for i in range(len(plaintext)): cipher.append(str(ord(plaintext[i]) * e % n)) ciphertext = ' '.join(cipher) print(ciphertext) def decryption(): private = input('Your private key (n, d), separated by a space or comma -- ').replace(',', ' ') (n, d) = list(map(int, private.split(' '))) ciphertext = input('Ciphertext (integers separated by spaces) -- ') cipher = list(map(int, ciphertext.split(' '))) plain = [] for i in range(len(cipher)): plain.append(str(cipher[i] * d % n)) print(' '.join(plain)) plaintext = '' for i in range(len(plain)): plaintext += chr(int(plain[i])) print('Plaintext - ', plaintext) def main(): if option.upper() == 'E': ints = input("Input 4 integers a, b, a', b' -- ") (a, b, a1, b1) = list(map(int, ints.split(' '))) encryption(a, b, a1, b1) elif option.upper() == 'D': decryption() else: return if __name__ == '__main__': main()
#!/usr/bin/env python # coding: utf-8 # # Seldon Kafka Integration Example with CIFAR10 Model # # In this example we will run SeldonDeployments for a CIFAR10 Tensorflow model which take their inputs from a Kafka topic and push their outputs to a Kafka topic. We will experiment with both REST and gRPC Seldon graphs. For REST we will load our input topic with Tensorflow JSON requests and for gRPC we will load Tensorflow PredictRequest protoBuffers. # ## Requirements # # * [Install gsutil](https://cloud.google.com/storage/docs/gsutil_install) # # In[ ]: get_ipython().system('pip install -r requirements.txt') # ## Setup Kafka # Install Strimzi on cluster # In[ ]: get_ipython().system('helm repo add strimzi https://strimzi.io/charts/') # In[ ]: get_ipython().system('helm install my-release strimzi/strimzi-kafka-operator') # Set the following to whether you are running a local Kind cluster or a cloud based cluster. # In[ ]: clusterType = "kind" # clusterType="cloud" # In[ ]: if clusterType == "kind": get_ipython().system('kubectl apply -f cluster-kind.yaml') else: get_ipython().system('kubectl apply -f cluster-cloud.yaml') # Get broker endpoint. # In[ ]: if clusterType == "kind": res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -n default -o=jsonpath='{.spec.ports[0].nodePort}'") port = res[0] get_ipython().run_line_magic('env', 'BROKER=172.17.0.2:$port') else: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}'") if len(res) == 1: hostname = res[0] get_ipython().run_line_magic('env', 'BROKER=$h:9094') else: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER=$ip:9094') # In[ ]: get_ipython().run_cell_magic('writefile', 'topics.yaml', 'apiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-rest-input\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-rest-output\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-grpc-input\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-grpc-output\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1') # In[ ]: get_ipython().system('kubectl apply -f topics.yaml') # ## Install Seldon # # * [Install Seldon](https://docs.seldon.io/projects/seldon-core/en/latest/workflow/install.html) # * [Follow our docs to intstall the Grafana analytics](https://docs.seldon.io/projects/seldon-core/en/latest/analytics/analytics.html). # ## Download Test Request Data # We have two example datasets containing 50,000 requests in tensorflow serving format for CIFAR10. One in JSON format and one as length encoded proto buffers. # In[ ]: get_ipython().system('gsutil cp gs://seldon-datasets/cifar10/requests/tensorflow/cifar10_tensorflow.json.gz cifar10_tensorflow.json.gz') get_ipython().system('gunzip cifar10_tensorflow.json.gz') get_ipython().system('gsutil cp gs://seldon-datasets/cifar10/requests/tensorflow/cifar10_tensorflow.proto cifar10_tensorflow.proto') # ## Test CIFAR10 REST Model # Upload tensorflow serving rest requests to kafka. This may take some time dependent on your network connection. # In[ ]: get_ipython().system('python ../../../util/kafka/test-client.py produce $BROKER cifar10-rest-input --file cifar10_tensorflow.json') # In[ ]: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER_CIP=$ip') # In[ ]: get_ipython().run_cell_magic('writefile', 'cifar10_rest.yaml', 'apiVersion: machinelearning.seldon.io/v1\nkind: SeldonDeployment\nmetadata:\n name: tfserving-cifar10\nspec:\n protocol: tensorflow\n transport: rest\n serverType: kafka \n predictors:\n - componentSpecs:\n - spec:\n containers:\n - args: \n - --port=8500\n - --rest_api_port=8501\n - --model_name=resnet32\n - --model_base_path=gs://seldon-models/tfserving/cifar10/resnet32\n - --enable_batching\n image: tensorflow/serving\n name: resnet32\n ports:\n - containerPort: 8501\n name: http\n svcOrchSpec:\n env:\n - name: KAFKA_BROKER\n value: BROKER_IP\n - name: KAFKA_INPUT_TOPIC\n value: cifar10-rest-input\n - name: KAFKA_OUTPUT_TOPIC\n value: cifar10-rest-output\n graph:\n name: resnet32\n type: MODEL\n endpoint:\n service_port: 8501\n name: model\n replicas: 1') # In[ ]: get_ipython().system('cat cifar10_rest.yaml | sed s/BROKER_IP/$BROKER_CIP:9094/ | kubectl apply -f -') # Looking at the metrics dashboard for Seldon you should see throughput we are getting. For a single replica on GKE with n1-standard-4 nodes we can see roughly 150 requests per second being processed. # # ![rest](tensorflow-rest-kafka.png) # In[ ]: get_ipython().system('kubectl delete -f cifar10_rest.yaml') # ## Test CIFAR10 gRPC Model # Upload tensorflow serving rest requests to kafka. This is a file of protobuffer `tenserflow.serving.PredictRequest` ([defn](https://github.com/tensorflow/serving/blob/master/tensorflow_serving/apis/predict.proto)). Each binary protobuffer is prefixed by the numbre of bytes. Out test-client python script reads them and sends to our topic. This may take some time dependent on your network connection. # In[ ]: get_ipython().system('python ../../../util/kafka/test-client.py produce $BROKER cifar10-grpc-input --file cifar10_tensorflow.proto --proto_name tensorflow.serving.PredictRequest') # In[ ]: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER_CIP=$ip') # In[ ]: get_ipython().run_cell_magic('writefile', 'cifar10_grpc.yaml', 'apiVersion: machinelearning.seldon.io/v1\nkind: SeldonDeployment\nmetadata:\n name: tfserving-cifar10\nspec:\n protocol: tensorflow\n transport: grpc\n serverType: kafka \n predictors:\n - componentSpecs:\n - spec:\n containers:\n - args: \n - --port=8500\n - --rest_api_port=8501\n - --model_name=resnet32\n - --model_base_path=gs://seldon-models/tfserving/cifar10/resnet32\n - --enable_batching \n image: tensorflow/serving\n name: resnet32\n ports:\n - containerPort: 8500\n name: http\n svcOrchSpec:\n env:\n - name: KAFKA_BROKER\n value: BROKER_IP\n - name: KAFKA_INPUT_TOPIC\n value: cifar10-grpc-input\n - name: KAFKA_OUTPUT_TOPIC\n value: cifar10-grpc-output\n graph:\n name: resnet32\n type: MODEL\n endpoint:\n service_port: 8500\n name: model\n replicas: 2') # In[ ]: get_ipython().system('cat cifar10_grpc.yaml | sed s/BROKER_IP/$BROKER_CIP:9094/ | kubectl apply -f -') # Looking at the metrics dashboard for Seldon you should see throughput we are getting. For a single replica on GKE with n1-standard-4 nodes we can see around 220 requests per second being processed. # # ![grpc](tensorflow-grpc-kafka.png) # In[ ]: get_ipython().system('kubectl delete -f cifar10_grpc.yaml') # In[ ]:
get_ipython().system('pip install -r requirements.txt') get_ipython().system('helm repo add strimzi https://strimzi.io/charts/') get_ipython().system('helm install my-release strimzi/strimzi-kafka-operator') cluster_type = 'kind' if clusterType == 'kind': get_ipython().system('kubectl apply -f cluster-kind.yaml') else: get_ipython().system('kubectl apply -f cluster-cloud.yaml') if clusterType == 'kind': res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -n default -o=jsonpath='{.spec.ports[0].nodePort}'") port = res[0] get_ipython().run_line_magic('env', 'BROKER=172.17.0.2:$port') else: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}'") if len(res) == 1: hostname = res[0] get_ipython().run_line_magic('env', 'BROKER=$h:9094') else: res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER=$ip:9094') get_ipython().run_cell_magic('writefile', 'topics.yaml', 'apiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-rest-input\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-rest-output\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-grpc-input\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1\n---\napiVersion: kafka.strimzi.io/v1beta1\nkind: KafkaTopic\nmetadata:\n name: cifar10-grpc-output\n labels:\n strimzi.io/cluster: "my-cluster"\nspec:\n partitions: 2\n replicas: 1') get_ipython().system('kubectl apply -f topics.yaml') get_ipython().system('gsutil cp gs://seldon-datasets/cifar10/requests/tensorflow/cifar10_tensorflow.json.gz cifar10_tensorflow.json.gz') get_ipython().system('gunzip cifar10_tensorflow.json.gz') get_ipython().system('gsutil cp gs://seldon-datasets/cifar10/requests/tensorflow/cifar10_tensorflow.proto cifar10_tensorflow.proto') get_ipython().system('python ../../../util/kafka/test-client.py produce $BROKER cifar10-rest-input --file cifar10_tensorflow.json') res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER_CIP=$ip') get_ipython().run_cell_magic('writefile', 'cifar10_rest.yaml', 'apiVersion: machinelearning.seldon.io/v1\nkind: SeldonDeployment\nmetadata:\n name: tfserving-cifar10\nspec:\n protocol: tensorflow\n transport: rest\n serverType: kafka \n predictors:\n - componentSpecs:\n - spec:\n containers:\n - args: \n - --port=8500\n - --rest_api_port=8501\n - --model_name=resnet32\n - --model_base_path=gs://seldon-models/tfserving/cifar10/resnet32\n - --enable_batching\n image: tensorflow/serving\n name: resnet32\n ports:\n - containerPort: 8501\n name: http\n svcOrchSpec:\n env:\n - name: KAFKA_BROKER\n value: BROKER_IP\n - name: KAFKA_INPUT_TOPIC\n value: cifar10-rest-input\n - name: KAFKA_OUTPUT_TOPIC\n value: cifar10-rest-output\n graph:\n name: resnet32\n type: MODEL\n endpoint:\n service_port: 8501\n name: model\n replicas: 1') get_ipython().system('cat cifar10_rest.yaml | sed s/BROKER_IP/$BROKER_CIP:9094/ | kubectl apply -f -') get_ipython().system('kubectl delete -f cifar10_rest.yaml') get_ipython().system('python ../../../util/kafka/test-client.py produce $BROKER cifar10-grpc-input --file cifar10_tensorflow.proto --proto_name tensorflow.serving.PredictRequest') res = get_ipython().getoutput("kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'") ip = res[0] get_ipython().run_line_magic('env', 'BROKER_CIP=$ip') get_ipython().run_cell_magic('writefile', 'cifar10_grpc.yaml', 'apiVersion: machinelearning.seldon.io/v1\nkind: SeldonDeployment\nmetadata:\n name: tfserving-cifar10\nspec:\n protocol: tensorflow\n transport: grpc\n serverType: kafka \n predictors:\n - componentSpecs:\n - spec:\n containers:\n - args: \n - --port=8500\n - --rest_api_port=8501\n - --model_name=resnet32\n - --model_base_path=gs://seldon-models/tfserving/cifar10/resnet32\n - --enable_batching \n image: tensorflow/serving\n name: resnet32\n ports:\n - containerPort: 8500\n name: http\n svcOrchSpec:\n env:\n - name: KAFKA_BROKER\n value: BROKER_IP\n - name: KAFKA_INPUT_TOPIC\n value: cifar10-grpc-input\n - name: KAFKA_OUTPUT_TOPIC\n value: cifar10-grpc-output\n graph:\n name: resnet32\n type: MODEL\n endpoint:\n service_port: 8500\n name: model\n replicas: 2') get_ipython().system('cat cifar10_grpc.yaml | sed s/BROKER_IP/$BROKER_CIP:9094/ | kubectl apply -f -') get_ipython().system('kubectl delete -f cifar10_grpc.yaml')
# Creates the file nonsilence_phones.txt which contains # all the phonemes except sil. source = open("slp_lab2_data/lexicon.txt", 'r') phones = [] # Get all the separate phonemes from lexicon.txt. for line in source: line_phones = line.split(' ')[1:] for phone in line_phones: phone = phone.strip(' ') phone = phone.strip('\n') if phone not in phones and phone!='sil': phones.append(phone) source.close() phones.sort() # Write phonemes to the file. wf = open("data/local/dict/nonsilence_phones.txt", 'w') for x in phones: wf.write(x+'\n') wf.close()
source = open('slp_lab2_data/lexicon.txt', 'r') phones = [] for line in source: line_phones = line.split(' ')[1:] for phone in line_phones: phone = phone.strip(' ') phone = phone.strip('\n') if phone not in phones and phone != 'sil': phones.append(phone) source.close() phones.sort() wf = open('data/local/dict/nonsilence_phones.txt', 'w') for x in phones: wf.write(x + '\n') wf.close()
class Computer(): def __init__(self, model, memory): self.mo = model self.me = memory c = Computer('Dell', '500gb') print(c.mo,c.me)
class Computer: def __init__(self, model, memory): self.mo = model self.me = memory c = computer('Dell', '500gb') print(c.mo, c.me)
#!/usr/bin/env python files = [ "dpx_nuke_10bits_rgb.dpx", "dpx_nuke_16bits_rgba.dpx" ] for f in files: command += rw_command (OIIO_TESTSUITE_IMAGEDIR, f) # Additionally, test for regressions for endian issues with 16 bit DPX output # (related to issue #354) command += oiio_app("oiiotool") + " src/input_rgb_mattes.tif -o output_rgb_mattes.dpx >> out.txt;" command += oiio_app("idiff") + " src/input_rgb_mattes.tif output_rgb_mattes.dpx >> out.txt;" # Test reading and writing of stereo DPX (multi-image) #command += (oiio_app("oiiotool") + "--create 80x60 3 --text:x=10 Left " # + "--caption \"view angle: left\" -d uint10 -o L.dpx >> out.txt;") #command += (oiio_app("oiiotool") + "--create 80x60 3 --text:x=10 Right " # + "--caption \"view angle: right\" -d uint10 -o R.dpx >> out.txt;") command += (oiio_app("oiiotool") + "ref/L.dpx ref/R.dpx --siappend -o stereo.dpx >> out.txt;") command += info_command("stereo.dpx", safematch=True, hash=False, extraargs="--stats") command += oiio_app("idiff") + "-a stereo.dpx ref/stereo.dpx >> out.txt;" # Test read/write of 1-channel DPX -- take a color image, make it grey, # write it as 1-channel DPX, then read it again and compare to a reference. # The reference is stored as TIFF rather than DPX just because it has # fantastically better compression. command += oiiotool(OIIO_TESTSUITE_IMAGEDIR+"/dpx_nuke_16bits_rgba.dpx" " -chsum:weight=0.333,0.333,0.333 -chnames Y -ch Y -o grey.dpx") command += info_command("grey.dpx", safematch=True) command += diff_command("grey.dpx", "ref/grey.tif")
files = ['dpx_nuke_10bits_rgb.dpx', 'dpx_nuke_16bits_rgba.dpx'] for f in files: command += rw_command(OIIO_TESTSUITE_IMAGEDIR, f) command += oiio_app('oiiotool') + ' src/input_rgb_mattes.tif -o output_rgb_mattes.dpx >> out.txt;' command += oiio_app('idiff') + ' src/input_rgb_mattes.tif output_rgb_mattes.dpx >> out.txt;' command += oiio_app('oiiotool') + 'ref/L.dpx ref/R.dpx --siappend -o stereo.dpx >> out.txt;' command += info_command('stereo.dpx', safematch=True, hash=False, extraargs='--stats') command += oiio_app('idiff') + '-a stereo.dpx ref/stereo.dpx >> out.txt;' command += oiiotool(OIIO_TESTSUITE_IMAGEDIR + '/dpx_nuke_16bits_rgba.dpx -chsum:weight=0.333,0.333,0.333 -chnames Y -ch Y -o grey.dpx') command += info_command('grey.dpx', safematch=True) command += diff_command('grey.dpx', 'ref/grey.tif')
# https://leetcode.com/problems/remove-nth-node-from-end-of-list/ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param {ListNode} head # @param {integer} n # @return {ListNode} def removeNthFromEnd(self, head, n): def removeNthFromEnd_rec(head, n): if not head: return 0 my_pos = removeNthFromEnd_rec(head.next, n) + 1 if my_pos - 1 == n: head.next = head.next.next return my_pos pre_head = ListNode(0) pre_head.next = head first_pos = removeNthFromEnd_rec(pre_head, n) return pre_head.next
class Solution: def remove_nth_from_end(self, head, n): def remove_nth_from_end_rec(head, n): if not head: return 0 my_pos = remove_nth_from_end_rec(head.next, n) + 1 if my_pos - 1 == n: head.next = head.next.next return my_pos pre_head = list_node(0) pre_head.next = head first_pos = remove_nth_from_end_rec(pre_head, n) return pre_head.next
def get_url(): return None result = get_url().text print(result)
def get_url(): return None result = get_url().text print(result)
myStr = input("Enter a String: ") count = 0 for letter in myStr: count += 1 print (count)
my_str = input('Enter a String: ') count = 0 for letter in myStr: count += 1 print(count)
a = 1 b = 2 c = 3 def foo(): a = 1 b = 2 c = 3 foo() print('TEST SUCEEDED')
a = 1 b = 2 c = 3 def foo(): a = 1 b = 2 c = 3 foo() print('TEST SUCEEDED')
train = [[1,2],[2,3],[1,1],[2,2],[3,3],[4,2],[2,5],[5,5],[4,1],[4,4]] weights = [1,1,1] def perceptron_predict(inputs, weights): activation = weights[0] for i in range(len(inputs)-1): activation += weights[i+1] * inputs[i] return 1.0 if activation >= 0.0 else 0.0 for inputs in train: print(perceptron_predict(inputs,weights))
train = [[1, 2], [2, 3], [1, 1], [2, 2], [3, 3], [4, 2], [2, 5], [5, 5], [4, 1], [4, 4]] weights = [1, 1, 1] def perceptron_predict(inputs, weights): activation = weights[0] for i in range(len(inputs) - 1): activation += weights[i + 1] * inputs[i] return 1.0 if activation >= 0.0 else 0.0 for inputs in train: print(perceptron_predict(inputs, weights))
def msg_retry(self, buf): print("retry") return buf[1:] MESSAGES = {1: msg_retry}
def msg_retry(self, buf): print('retry') return buf[1:] messages = {1: msg_retry}
print("WELCOME!\nTHIS IS A NUMBER GUESSING QUIZ ") num = 30 num_of_guesses = 1 guess = input("ARE YOU A KID?\n") while(guess != num): guess = int(input("ENTER THE NUMBER TO GUESS\n")) if guess > num: print("NOT CORRECT") print("LOWER NUMBER PLEASE!") num_of_guesses += 1 elif guess < num: print("NOT CORRECT") print("HIGHER NUMBER PLEASE!") num_of_guesses += 1 else: print("CONGRATULATION! YOU GUESSED THE NUMBER ") print("THE NUMBER IS ", num) print(num_of_guesses, "ATTEMPTS YOU USED TO ARIVE AT THE NUMBER ")
print('WELCOME!\nTHIS IS A NUMBER GUESSING QUIZ ') num = 30 num_of_guesses = 1 guess = input('ARE YOU A KID?\n') while guess != num: guess = int(input('ENTER THE NUMBER TO GUESS\n')) if guess > num: print('NOT CORRECT') print('LOWER NUMBER PLEASE!') num_of_guesses += 1 elif guess < num: print('NOT CORRECT') print('HIGHER NUMBER PLEASE!') num_of_guesses += 1 else: print('CONGRATULATION! YOU GUESSED THE NUMBER ') print('THE NUMBER IS ', num) print(num_of_guesses, 'ATTEMPTS YOU USED TO ARIVE AT THE NUMBER ')
MAX_FOOD_ON_BOARD = 25 # Max food on board EAT_RATIO = 0.50 # Ammount of snake length absorbed FOOD_SPAWN_RATE = 3 # Number of turns per food spawn HUNGER_THRESHOLD = 100 # Turns of inactivity before snake starvation SNAKE_STARTING_LENGTH = 3 # Snake starting size TURNS_PER_GOLD = 20 # Turns between the spawn of each gold food GOLD_VICTORY = 5 # Gold needed to win the game TURNS_PER_WALL = 5 # Turns between the span of each random wall WALL_START_TURN = 50 # The turn at which random walls will begin to spawn HEALTH_DECAY_RATE = 1 # The amount of health you lose each turn FOOD_VALUE = 30 # You gain this much health when you eat food (Advanced mode only)
max_food_on_board = 25 eat_ratio = 0.5 food_spawn_rate = 3 hunger_threshold = 100 snake_starting_length = 3 turns_per_gold = 20 gold_victory = 5 turns_per_wall = 5 wall_start_turn = 50 health_decay_rate = 1 food_value = 30
# https://codeforces.com/problemset/problem/1399/A t = int(input()) for _ in range(t): length_a = int(input()) list_a = [int(x) for x in input().split()] list_a.sort() while True: if len(list_a) == 1: print('YES') break elif abs(list_a[0] - list_a[1]) <= 1: list_a.pop(0) else: print('NO') break
t = int(input()) for _ in range(t): length_a = int(input()) list_a = [int(x) for x in input().split()] list_a.sort() while True: if len(list_a) == 1: print('YES') break elif abs(list_a[0] - list_a[1]) <= 1: list_a.pop(0) else: print('NO') break
sentence = input().split() latin = "" for word in sentence: latin += word[1:] + word[0]+"ay " print(latin,end="")
sentence = input().split() latin = '' for word in sentence: latin += word[1:] + word[0] + 'ay ' print(latin, end='')
modulename = "Help" creator = "YtnomSnrub" sd_structure = {}
modulename = 'Help' creator = 'YtnomSnrub' sd_structure = {}
class DeBracketifyMiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): cleaned = request.GET.copy() for key in cleaned: if key.endswith('[]'): val = cleaned.pop(key) cleaned_key = key.replace('[]', '') cleaned.setlist(cleaned_key, val) request.GET = cleaned return self.get_response(request)
class Debracketifymiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): cleaned = request.GET.copy() for key in cleaned: if key.endswith('[]'): val = cleaned.pop(key) cleaned_key = key.replace('[]', '') cleaned.setlist(cleaned_key, val) request.GET = cleaned return self.get_response(request)
def trace_wire(wire_dirs): last_pos = [0, 0] grid_dict = {} length = 0 for direction in wire_dirs: way = direction[0] amount = int(direction[1:]) if way == 'R': for x in range(1,amount+1): grid_pos = '{}_{}'.format(last_pos[0]+x, last_pos[1]) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[0] += amount elif way == 'L': for x in range(1,amount+1): grid_pos = '{}_{}'.format(last_pos[0]-x, last_pos[1]) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[0] -= amount elif way == 'U': for y in range(1,amount+1): grid_pos = '{}_{}'.format(last_pos[0], last_pos[1]+y) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[1] += amount elif way == 'D': for y in range(1,amount+1): grid_pos = '{}_{}'.format(last_pos[0], last_pos[1]-y) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[1] -= amount return grid_dict def main(): with open('input.txt', 'r') as f: first, second = f.read().split('\n') first_grid = trace_wire(first.split(',')) second_grid = trace_wire(second.split(',')) intersection_grid = set(first_grid.keys()) & set(second_grid.keys()) # print(intersection_grid) part_1 = min([abs(int(i.split('_')[0])) + abs(int(i.split('_')[1])) for i in intersection_grid]) part_2 = min([second_grid[i] + first_grid[i] for i in intersection_grid]) print(part_1, part_2) if __name__ == '__main__': main()
def trace_wire(wire_dirs): last_pos = [0, 0] grid_dict = {} length = 0 for direction in wire_dirs: way = direction[0] amount = int(direction[1:]) if way == 'R': for x in range(1, amount + 1): grid_pos = '{}_{}'.format(last_pos[0] + x, last_pos[1]) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[0] += amount elif way == 'L': for x in range(1, amount + 1): grid_pos = '{}_{}'.format(last_pos[0] - x, last_pos[1]) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[0] -= amount elif way == 'U': for y in range(1, amount + 1): grid_pos = '{}_{}'.format(last_pos[0], last_pos[1] + y) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[1] += amount elif way == 'D': for y in range(1, amount + 1): grid_pos = '{}_{}'.format(last_pos[0], last_pos[1] - y) length += 1 if grid_pos not in grid_dict: grid_dict[grid_pos] = length last_pos[1] -= amount return grid_dict def main(): with open('input.txt', 'r') as f: (first, second) = f.read().split('\n') first_grid = trace_wire(first.split(',')) second_grid = trace_wire(second.split(',')) intersection_grid = set(first_grid.keys()) & set(second_grid.keys()) part_1 = min([abs(int(i.split('_')[0])) + abs(int(i.split('_')[1])) for i in intersection_grid]) part_2 = min([second_grid[i] + first_grid[i] for i in intersection_grid]) print(part_1, part_2) if __name__ == '__main__': main()
#Linear Seach Algorithm def linearSearch(data, number): found = False for index in range(0, len(data)): if (data[index] == number): found = True break if found: print("Element is present in the array", index) else: print("Element is not present in the array.")
def linear_search(data, number): found = False for index in range(0, len(data)): if data[index] == number: found = True break if found: print('Element is present in the array', index) else: print('Element is not present in the array.')
i = 1 # valor inicial de I j = aux = 7 # valor inicial de J while i < 10: # equanto for menor que 10: for x in range(3): # loop: mostra as linhas consecutivas print('I={} J={}' .format(i,j)) # mostra os valores j -= 1 # diminui 1 no J (7,6,5) i += 2 # altera I aux += 2 # altera a aux j = aux # novo J = aux
i = 1 j = aux = 7 while i < 10: for x in range(3): print('I={} J={}'.format(i, j)) j -= 1 i += 2 aux += 2 j = aux
IOSXE_TEST = { "host": "172.18.0.11", "username": "vrnetlab", "password": "VR-netlab9", "device_type": "cisco_xe", "test_commands": ["show run", "show version"], } NXOS_TEST = { "host": "172.18.0.12", "username": "vrnetlab", "password": "VR-netlab9", "device_type": "cisco_nxos", "test_commands": ["show run", "show version"], } IOSXR_TEST = { "host": "172.18.0.13", "username": "vrnetlab", "password": "VR-netlab9", "device_type": "cisco_iosxr", "test_commands": ["show run", "show version"], } # need to get arista_eos image in vrnetlab for testing + fix libssh2 keyboard interactive auth issue # EOS_TEST = { # "host": "172.18.0.14", # "username": "vrnetlab", # "password": "VR-netlab9", # "device_type": "arista_eos", # "test_commands": ["show run", "show version"], # } JUNOS_TEST = { "host": "172.18.0.15", "username": "vrnetlab", "password": "VR-netlab9", "device_type": "juniper_junos", "test_commands": ["show configuration", "show version"], }
iosxe_test = {'host': '172.18.0.11', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'cisco_xe', 'test_commands': ['show run', 'show version']} nxos_test = {'host': '172.18.0.12', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'cisco_nxos', 'test_commands': ['show run', 'show version']} iosxr_test = {'host': '172.18.0.13', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'cisco_iosxr', 'test_commands': ['show run', 'show version']} junos_test = {'host': '172.18.0.15', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'juniper_junos', 'test_commands': ['show configuration', 'show version']}
def rotate_left(list_f, step): for _ in range(step): list_f.append(list_f.pop(0)) list_s = list_f[:] return list_s
def rotate_left(list_f, step): for _ in range(step): list_f.append(list_f.pop(0)) list_s = list_f[:] return list_s
times = [{'writing_data': 6.627535581588745, 'ndvi_pc10': 27.36231303215027, 'loading_data': 109.62806057929993, 'ndvi_pc90': 21.421257734298706, 'ndvi_pc50': 27.33169937133789}, {'writing_data': 6.443411588668823, 'ndvi_pc10': 39.16243243217468, 'loading_data': 123.19368815422058, 'ndvi_pc90': 38.72961163520813, 'ndvi_pc50': 36.39958381652832}, {'writing_data': 6.733800649642944, 'ndvi_pc10': 32.248281955718994, 'loading_data': 56.15437984466553, 'ndvi_pc90': 31.813125610351562, 'ndvi_pc50': 35.00871157646179}, {'writing_data': 6.484926462173462, 'ndvi_pc10': 30.538794994354248, 'loading_data': 72.27108573913574, 'ndvi_pc90': 31.11927819252014, 'ndvi_pc50': 30.832648038864136}, {'writing_data': 6.359814405441284, 'ndvi_pc10': 46.55086040496826, 'loading_data': 59.67847752571106, 'ndvi_pc90': 39.096333265304565, 'ndvi_pc50': 42.16282844543457}, {'writing_data': 6.564153432846069, 'ndvi_pc10': 45.175180196762085, 'loading_data': 87.63148283958435, 'ndvi_pc90': 49.379384994506836, 'ndvi_pc50': 45.34032440185547}, {'writing_data': 6.604489326477051, 'ndvi_pc10': 32.93318557739258, 'loading_data': 78.88174366950989, 'ndvi_pc90': 31.08031392097473, 'ndvi_pc50': 29.89056134223938}, {'writing_data': 6.4211084842681885, 'ndvi_pc10': 41.337995767593384, 'loading_data': 82.0915629863739, 'ndvi_pc90': 39.3358314037323, 'ndvi_pc50': 39.409401655197144}, {'writing_data': 6.546594858169556, 'ndvi_pc10': 35.091548681259155, 'loading_data': 47.397238969802856, 'ndvi_pc90': 34.05122685432434, 'ndvi_pc50': 33.63374209403992}, {'writing_data': 6.11034631729126, 'ndvi_pc10': 43.16675114631653, 'loading_data': 63.00188064575195, 'ndvi_pc90': 40.11013221740723, 'ndvi_pc50': 40.178325176239014}, {'writing_data': 6.267251491546631, 'ndvi_pc10': 36.879666328430176, 'loading_data': 59.68582105636597, 'ndvi_pc90': 35.762709617614746, 'ndvi_pc50': 36.186012506484985}, {'writing_data': 6.086328744888306, 'ndvi_pc10': 34.747477531433105, 'loading_data': 51.13255739212036, 'ndvi_pc90': 33.50469946861267, 'ndvi_pc50': 33.493101358413696}, {'writing_data': 6.232825517654419, 'ndvi_pc10': 37.161699056625366, 'loading_data': 72.47414040565491, 'ndvi_pc90': 36.648998975753784, 'ndvi_pc50': 38.17262291908264}, {'writing_data': 6.4867870807647705, 'ndvi_pc10': 22.58499264717102, 'loading_data': 50.658077239990234, 'ndvi_pc90': 23.183380842208862, 'ndvi_pc50': 23.05723762512207}, {'writing_data': 6.315629243850708, 'ndvi_pc10': 24.482516288757324, 'loading_data': 52.54269289970398, 'ndvi_pc90': 23.933518171310425, 'ndvi_pc50': 23.647018909454346}, {'writing_data': 6.466713190078735, 'ndvi_pc10': 33.10160160064697, 'loading_data': 39.69579243659973, 'ndvi_pc90': 35.594271183013916, 'ndvi_pc50': 33.5105459690094}, {'writing_data': 6.146531581878662, 'ndvi_pc10': 41.39342451095581, 'loading_data': 82.68737983703613, 'ndvi_pc90': 40.2240526676178, 'ndvi_pc50': 42.00848603248596}, {'writing_data': 6.4085304737091064, 'ndvi_pc10': 24.061297178268433, 'loading_data': 65.79187154769897, 'ndvi_pc90': 24.270387649536133, 'ndvi_pc50': 23.630946397781372}, {'writing_data': 5.905577898025513, 'ndvi_pc10': 37.23882865905762, 'loading_data': 55.112420082092285, 'ndvi_pc90': 36.291778326034546, 'ndvi_pc50': 36.75375556945801}, {'writing_data': 6.305130481719971, 'ndvi_pc10': 35.108429193496704, 'loading_data': 56.73119306564331, 'ndvi_pc90': 35.175426959991455, 'ndvi_pc50': 35.82203245162964}, {'writing_data': 5.938111066818237, 'ndvi_pc10': 36.650582790374756, 'loading_data': 55.64810013771057, 'ndvi_pc90': 36.924052238464355, 'ndvi_pc50': 36.689247369766235}, {'writing_data': 5.939232587814331, 'ndvi_pc10': 34.53633236885071, 'loading_data': 64.5890371799469, 'ndvi_pc90': 32.73802304267883, 'ndvi_pc50': 35.01725482940674}, {'writing_data': 6.481805801391602, 'ndvi_pc10': 15.486124753952026, 'loading_data': 44.980570793151855, 'ndvi_pc90': 16.636183738708496, 'ndvi_pc50': 19.395575284957886}, {'writing_data': 6.364058494567871, 'ndvi_pc10': 34.192909955978394, 'loading_data': 41.18637776374817, 'ndvi_pc90': 33.94004559516907, 'ndvi_pc50': 32.72668814659119}, {'writing_data': 6.19329047203064, 'ndvi_pc10': 21.083044290542603, 'loading_data': 54.03144335746765, 'ndvi_pc90': 18.876606702804565, 'ndvi_pc50': 20.58382821083069}, {'writing_data': 6.390938997268677, 'ndvi_pc10': 17.885555505752563, 'loading_data': 64.85111451148987, 'ndvi_pc90': 17.912266969680786, 'ndvi_pc50': 16.847716808319092}, {'writing_data': 6.0089945793151855, 'ndvi_pc10': 37.12860655784607, 'loading_data': 80.22634196281433, 'ndvi_pc90': 36.44176435470581, 'ndvi_pc50': 37.66867637634277}, {'writing_data': 5.877416372299194, 'ndvi_pc10': 37.55026960372925, 'loading_data': 67.21783351898193, 'ndvi_pc90': 34.27371907234192, 'ndvi_pc50': 33.92675566673279}, {'writing_data': 6.228186845779419, 'ndvi_pc10': 31.5383403301239, 'loading_data': 61.13664984703064, 'ndvi_pc90': 30.51774287223816, 'ndvi_pc50': 30.585197687149048}, {'writing_data': 6.655982971191406, 'ndvi_pc10': 10.241628408432007, 'loading_data': 41.03610324859619, 'ndvi_pc90': 8.946972131729126, 'ndvi_pc50': 10.193110942840576}, {'writing_data': 6.053949356079102, 'ndvi_pc10': 34.719430446624756, 'loading_data': 69.46687150001526, 'ndvi_pc90': 31.912947416305542, 'ndvi_pc50': 34.160250186920166}, {'writing_data': 5.863107919692993, 'ndvi_pc10': 35.627281665802, 'loading_data': 58.374780893325806, 'ndvi_pc90': 35.16462683677673, 'ndvi_pc50': 35.169331073760986}, {'writing_data': 6.245217323303223, 'ndvi_pc10': 26.947230339050293, 'loading_data': 37.8329381942749, 'ndvi_pc90': 28.4262912273407, 'ndvi_pc50': 26.491452932357788}, {'writing_data': 6.1906843185424805, 'ndvi_pc10': 10.243769407272339, 'loading_data': 47.66607213020325, 'ndvi_pc90': 10.901005268096924, 'ndvi_pc50': 9.574926376342773}, {'writing_data': 6.27140212059021, 'ndvi_pc10': 9.982360601425171, 'loading_data': 52.55823802947998, 'ndvi_pc90': 9.319277286529541, 'ndvi_pc50': 9.227921962738037}, {'writing_data': 6.332434177398682, 'ndvi_pc10': 4.836212396621704, 'loading_data': 32.75589728355408, 'ndvi_pc90': 5.307963848114014, 'ndvi_pc50': 4.731549501419067}, {'writing_data': 6.2034995555877686, 'ndvi_pc10': 36.06976509094238, 'loading_data': 81.16117906570435, 'ndvi_pc90': 35.752469539642334, 'ndvi_pc50': 37.97353792190552}, {'writing_data': 6.317094087600708, 'ndvi_pc10': 6.397157907485962, 'loading_data': 32.58416557312012, 'ndvi_pc90': 7.095927000045776, 'ndvi_pc50': 6.454242944717407}, {'writing_data': 6.197620153427124, 'ndvi_pc10': 11.273391008377075, 'loading_data': 38.74477291107178, 'ndvi_pc90': 10.42611837387085, 'ndvi_pc50': 11.03548288345337}, {'writing_data': 6.481883764266968, 'ndvi_pc10': 3.8671746253967285, 'loading_data': 26.47277569770813, 'ndvi_pc90': 3.9668197631835938, 'ndvi_pc50': 3.716965675354004}, {'writing_data': 6.128786563873291, 'ndvi_pc10': 16.900771617889404, 'loading_data': 45.50841689109802, 'ndvi_pc90': 19.169956922531128, 'ndvi_pc50': 16.847289562225342}, {'writing_data': 6.797720909118652, 'ndvi_pc10': 4.179133892059326, 'loading_data': 24.04671049118042, 'ndvi_pc90': 4.420083284378052, 'ndvi_pc50': 4.485124349594116}, {'writing_data': 6.50871467590332, 'ndvi_pc10': 5.876180410385132, 'loading_data': 35.49396777153015, 'ndvi_pc90': 5.70380973815918, 'ndvi_pc50': 5.584086894989014}, {'writing_data': 6.459113836288452, 'ndvi_pc10': 4.990781784057617, 'loading_data': 42.639532804489136, 'ndvi_pc90': 4.918926239013672, 'ndvi_pc50': 4.503567218780518}]
times = [{'writing_data': 6.627535581588745, 'ndvi_pc10': 27.36231303215027, 'loading_data': 109.62806057929993, 'ndvi_pc90': 21.421257734298706, 'ndvi_pc50': 27.33169937133789}, {'writing_data': 6.443411588668823, 'ndvi_pc10': 39.16243243217468, 'loading_data': 123.19368815422058, 'ndvi_pc90': 38.72961163520813, 'ndvi_pc50': 36.39958381652832}, {'writing_data': 6.733800649642944, 'ndvi_pc10': 32.248281955718994, 'loading_data': 56.15437984466553, 'ndvi_pc90': 31.813125610351562, 'ndvi_pc50': 35.00871157646179}, {'writing_data': 6.484926462173462, 'ndvi_pc10': 30.538794994354248, 'loading_data': 72.27108573913574, 'ndvi_pc90': 31.11927819252014, 'ndvi_pc50': 30.832648038864136}, {'writing_data': 6.359814405441284, 'ndvi_pc10': 46.55086040496826, 'loading_data': 59.67847752571106, 'ndvi_pc90': 39.096333265304565, 'ndvi_pc50': 42.16282844543457}, {'writing_data': 6.564153432846069, 'ndvi_pc10': 45.175180196762085, 'loading_data': 87.63148283958435, 'ndvi_pc90': 49.379384994506836, 'ndvi_pc50': 45.34032440185547}, {'writing_data': 6.604489326477051, 'ndvi_pc10': 32.93318557739258, 'loading_data': 78.88174366950989, 'ndvi_pc90': 31.08031392097473, 'ndvi_pc50': 29.89056134223938}, {'writing_data': 6.4211084842681885, 'ndvi_pc10': 41.337995767593384, 'loading_data': 82.0915629863739, 'ndvi_pc90': 39.3358314037323, 'ndvi_pc50': 39.409401655197144}, {'writing_data': 6.546594858169556, 'ndvi_pc10': 35.091548681259155, 'loading_data': 47.397238969802856, 'ndvi_pc90': 34.05122685432434, 'ndvi_pc50': 33.63374209403992}, {'writing_data': 6.11034631729126, 'ndvi_pc10': 43.16675114631653, 'loading_data': 63.00188064575195, 'ndvi_pc90': 40.11013221740723, 'ndvi_pc50': 40.178325176239014}, {'writing_data': 6.267251491546631, 'ndvi_pc10': 36.879666328430176, 'loading_data': 59.68582105636597, 'ndvi_pc90': 35.762709617614746, 'ndvi_pc50': 36.186012506484985}, {'writing_data': 6.086328744888306, 'ndvi_pc10': 34.747477531433105, 'loading_data': 51.13255739212036, 'ndvi_pc90': 33.50469946861267, 'ndvi_pc50': 33.493101358413696}, {'writing_data': 6.232825517654419, 'ndvi_pc10': 37.161699056625366, 'loading_data': 72.47414040565491, 'ndvi_pc90': 36.648998975753784, 'ndvi_pc50': 38.17262291908264}, {'writing_data': 6.4867870807647705, 'ndvi_pc10': 22.58499264717102, 'loading_data': 50.658077239990234, 'ndvi_pc90': 23.183380842208862, 'ndvi_pc50': 23.05723762512207}, {'writing_data': 6.315629243850708, 'ndvi_pc10': 24.482516288757324, 'loading_data': 52.54269289970398, 'ndvi_pc90': 23.933518171310425, 'ndvi_pc50': 23.647018909454346}, {'writing_data': 6.466713190078735, 'ndvi_pc10': 33.10160160064697, 'loading_data': 39.69579243659973, 'ndvi_pc90': 35.594271183013916, 'ndvi_pc50': 33.5105459690094}, {'writing_data': 6.146531581878662, 'ndvi_pc10': 41.39342451095581, 'loading_data': 82.68737983703613, 'ndvi_pc90': 40.2240526676178, 'ndvi_pc50': 42.00848603248596}, {'writing_data': 6.4085304737091064, 'ndvi_pc10': 24.061297178268433, 'loading_data': 65.79187154769897, 'ndvi_pc90': 24.270387649536133, 'ndvi_pc50': 23.630946397781372}, {'writing_data': 5.905577898025513, 'ndvi_pc10': 37.23882865905762, 'loading_data': 55.112420082092285, 'ndvi_pc90': 36.291778326034546, 'ndvi_pc50': 36.75375556945801}, {'writing_data': 6.305130481719971, 'ndvi_pc10': 35.108429193496704, 'loading_data': 56.73119306564331, 'ndvi_pc90': 35.175426959991455, 'ndvi_pc50': 35.82203245162964}, {'writing_data': 5.938111066818237, 'ndvi_pc10': 36.650582790374756, 'loading_data': 55.64810013771057, 'ndvi_pc90': 36.924052238464355, 'ndvi_pc50': 36.689247369766235}, {'writing_data': 5.939232587814331, 'ndvi_pc10': 34.53633236885071, 'loading_data': 64.5890371799469, 'ndvi_pc90': 32.73802304267883, 'ndvi_pc50': 35.01725482940674}, {'writing_data': 6.481805801391602, 'ndvi_pc10': 15.486124753952026, 'loading_data': 44.980570793151855, 'ndvi_pc90': 16.636183738708496, 'ndvi_pc50': 19.395575284957886}, {'writing_data': 6.364058494567871, 'ndvi_pc10': 34.192909955978394, 'loading_data': 41.18637776374817, 'ndvi_pc90': 33.94004559516907, 'ndvi_pc50': 32.72668814659119}, {'writing_data': 6.19329047203064, 'ndvi_pc10': 21.083044290542603, 'loading_data': 54.03144335746765, 'ndvi_pc90': 18.876606702804565, 'ndvi_pc50': 20.58382821083069}, {'writing_data': 6.390938997268677, 'ndvi_pc10': 17.885555505752563, 'loading_data': 64.85111451148987, 'ndvi_pc90': 17.912266969680786, 'ndvi_pc50': 16.847716808319092}, {'writing_data': 6.0089945793151855, 'ndvi_pc10': 37.12860655784607, 'loading_data': 80.22634196281433, 'ndvi_pc90': 36.44176435470581, 'ndvi_pc50': 37.66867637634277}, {'writing_data': 5.877416372299194, 'ndvi_pc10': 37.55026960372925, 'loading_data': 67.21783351898193, 'ndvi_pc90': 34.27371907234192, 'ndvi_pc50': 33.92675566673279}, {'writing_data': 6.228186845779419, 'ndvi_pc10': 31.5383403301239, 'loading_data': 61.13664984703064, 'ndvi_pc90': 30.51774287223816, 'ndvi_pc50': 30.585197687149048}, {'writing_data': 6.655982971191406, 'ndvi_pc10': 10.241628408432007, 'loading_data': 41.03610324859619, 'ndvi_pc90': 8.946972131729126, 'ndvi_pc50': 10.193110942840576}, {'writing_data': 6.053949356079102, 'ndvi_pc10': 34.719430446624756, 'loading_data': 69.46687150001526, 'ndvi_pc90': 31.912947416305542, 'ndvi_pc50': 34.160250186920166}, {'writing_data': 5.863107919692993, 'ndvi_pc10': 35.627281665802, 'loading_data': 58.374780893325806, 'ndvi_pc90': 35.16462683677673, 'ndvi_pc50': 35.169331073760986}, {'writing_data': 6.245217323303223, 'ndvi_pc10': 26.947230339050293, 'loading_data': 37.8329381942749, 'ndvi_pc90': 28.4262912273407, 'ndvi_pc50': 26.491452932357788}, {'writing_data': 6.1906843185424805, 'ndvi_pc10': 10.243769407272339, 'loading_data': 47.66607213020325, 'ndvi_pc90': 10.901005268096924, 'ndvi_pc50': 9.574926376342773}, {'writing_data': 6.27140212059021, 'ndvi_pc10': 9.982360601425171, 'loading_data': 52.55823802947998, 'ndvi_pc90': 9.319277286529541, 'ndvi_pc50': 9.227921962738037}, {'writing_data': 6.332434177398682, 'ndvi_pc10': 4.836212396621704, 'loading_data': 32.75589728355408, 'ndvi_pc90': 5.307963848114014, 'ndvi_pc50': 4.731549501419067}, {'writing_data': 6.2034995555877686, 'ndvi_pc10': 36.06976509094238, 'loading_data': 81.16117906570435, 'ndvi_pc90': 35.752469539642334, 'ndvi_pc50': 37.97353792190552}, {'writing_data': 6.317094087600708, 'ndvi_pc10': 6.397157907485962, 'loading_data': 32.58416557312012, 'ndvi_pc90': 7.095927000045776, 'ndvi_pc50': 6.454242944717407}, {'writing_data': 6.197620153427124, 'ndvi_pc10': 11.273391008377075, 'loading_data': 38.74477291107178, 'ndvi_pc90': 10.42611837387085, 'ndvi_pc50': 11.03548288345337}, {'writing_data': 6.481883764266968, 'ndvi_pc10': 3.8671746253967285, 'loading_data': 26.47277569770813, 'ndvi_pc90': 3.9668197631835938, 'ndvi_pc50': 3.716965675354004}, {'writing_data': 6.128786563873291, 'ndvi_pc10': 16.900771617889404, 'loading_data': 45.50841689109802, 'ndvi_pc90': 19.169956922531128, 'ndvi_pc50': 16.847289562225342}, {'writing_data': 6.797720909118652, 'ndvi_pc10': 4.179133892059326, 'loading_data': 24.04671049118042, 'ndvi_pc90': 4.420083284378052, 'ndvi_pc50': 4.485124349594116}, {'writing_data': 6.50871467590332, 'ndvi_pc10': 5.876180410385132, 'loading_data': 35.49396777153015, 'ndvi_pc90': 5.70380973815918, 'ndvi_pc50': 5.584086894989014}, {'writing_data': 6.459113836288452, 'ndvi_pc10': 4.990781784057617, 'loading_data': 42.639532804489136, 'ndvi_pc90': 4.918926239013672, 'ndvi_pc50': 4.503567218780518}]
fname = input("Enter file name: ") fh = open(fname) total = 0.0 count = 0.0 for line in fh: if line.startswith("X-DSPAM-Confidence:"): total += float(line[line.find(":") + 1:]) count += 1 lf = total/count else: continue print('Average spam confidence: ',"{0:.12f}".format(round(lf,12)))
fname = input('Enter file name: ') fh = open(fname) total = 0.0 count = 0.0 for line in fh: if line.startswith('X-DSPAM-Confidence:'): total += float(line[line.find(':') + 1:]) count += 1 lf = total / count else: continue print('Average spam confidence: ', '{0:.12f}'.format(round(lf, 12)))
def selectmenuitem(window,object): #log("{} :not implemented yet".format(sys._getframe().f_code.co_name)) object = object.split(";") if len(object) == 2: objectHandle = getobjecthandle(window,object[0])['handle'] mousemove(window,object[0],handle=objectHandle) ldtp_extend_mouse_click_here() time.sleep(1) objectHandle = getobjecthandle(window,object[1])['handle'] mousemove(window,object[1],handle=objectHandle) ldtp_extend_mouse_click_here()
def selectmenuitem(window, object): object = object.split(';') if len(object) == 2: object_handle = getobjecthandle(window, object[0])['handle'] mousemove(window, object[0], handle=objectHandle) ldtp_extend_mouse_click_here() time.sleep(1) object_handle = getobjecthandle(window, object[1])['handle'] mousemove(window, object[1], handle=objectHandle) ldtp_extend_mouse_click_here()
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None def kAltReverse(head, k) : current = head next = None prev = None count = 0 #1) reverse first k nodes of the linked list while (current != None and count < k) : next = current.next current.next = prev prev = current current = next count = count + 1; # 2) Now head pos to the kth node. # So change next of head to (k+1)th node if(head != None): head.next = current # 3) We do not want to reverse next k # nodes. So move the current # poer to skip next k nodes count = 0 while(count < k - 1 and current != None ): current = current.next count = count + 1 # 4) Recursively call for the list # starting from current.next. And make # rest of the list as next of first node if(current != None): current.next = kAltReverse(current.next, k) # 5) prev is new head of the input list return prev class Solution: # @param A : head node of linked list # @param B : integer # @return the head node in the linked list def solve(self, A, B): return kAltReverse(A,B);
def k_alt_reverse(head, k): current = head next = None prev = None count = 0 while current != None and count < k: next = current.next current.next = prev prev = current current = next count = count + 1 if head != None: head.next = current count = 0 while count < k - 1 and current != None: current = current.next count = count + 1 if current != None: current.next = k_alt_reverse(current.next, k) return prev class Solution: def solve(self, A, B): return k_alt_reverse(A, B)
_base_ = "./FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py" OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/cat" DATASETS = dict(TRAIN=("lm_pbr_cat_train",), TEST=("lm_real_cat_test",)) # bbnc5 # objects cat Avg(1) # ad_2 19.26 19.26 # ad_5 62.48 62.48 # ad_10 91.52 91.52 # rete_2 78.24 78.24 # rete_5 99.60 99.60 # rete_10 100.00 100.00 # re_2 79.74 79.74 # re_5 99.60 99.60 # re_10 100.00 100.00 # te_2 97.70 97.70 # te_5 100.00 100.00 # te_10 100.00 100.00 # proj_2 83.63 83.63 # proj_5 99.10 99.10 # proj_10 100.00 100.00 # re 1.45 1.45 # te 0.01 0.01
_base_ = './FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py' output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/cat' datasets = dict(TRAIN=('lm_pbr_cat_train',), TEST=('lm_real_cat_test',))
def main(): with open('input.txt') as f: inputs = [line.split() for line in f.readlines()] pos = (0, 0) # horiz, depth for cmd, amount in inputs: amount = int(amount) match cmd: case 'forward': pos = (pos[0] + amount, pos[1]) case 'down': pos = (pos[0], pos[1] + amount) case 'up': pos = (pos[0], pos[1] - amount) case _: print(f'invalid direction: {cmd}') print(f'final coord: {pos}') print(f'answer 1: {pos[0] * pos[1]}') pos = (0, 0, 0) # horiz, depth, aim for cmd, amount in inputs: amount = int(amount) match cmd: case 'forward': pos = (pos[0] + amount, pos[1] + pos[2] * amount, pos[2]) case 'down': pos = (pos[0], pos[1], pos[2] + amount) case 'up': pos = (pos[0], pos[1], pos[2] - amount) case _: print(f'invalid direction: {cmd}') print(f'final coord: {pos}') print(f'answer 2: {pos[0] * pos[1]}') if __name__ == '__main__': main()
def main(): with open('input.txt') as f: inputs = [line.split() for line in f.readlines()] pos = (0, 0) for (cmd, amount) in inputs: amount = int(amount) match cmd: case 'forward': pos = (pos[0] + amount, pos[1]) case 'down': pos = (pos[0], pos[1] + amount) case 'up': pos = (pos[0], pos[1] - amount) case _: print(f'invalid direction: {cmd}') print(f'final coord: {pos}') print(f'answer 1: {pos[0] * pos[1]}') pos = (0, 0, 0) for (cmd, amount) in inputs: amount = int(amount) match cmd: case 'forward': pos = (pos[0] + amount, pos[1] + pos[2] * amount, pos[2]) case 'down': pos = (pos[0], pos[1], pos[2] + amount) case 'up': pos = (pos[0], pos[1], pos[2] - amount) case _: print(f'invalid direction: {cmd}') print(f'final coord: {pos}') print(f'answer 2: {pos[0] * pos[1]}') if __name__ == '__main__': main()
# Python Lists # @IdiotInside_ print ("Creating List:") colors = ['red', 'blue', 'green'] print (colors[0]) ## red print (colors[1]) ## blue print (colors[2]) ## green print (len(colors)) ## 3 print ("Append to the List") colors.append("orange") print (colors[3]) ##orange print ("Insert to the List") colors.insert(3, "yellow") print (colors[3]) ##yellow print (colors[4]) ##orange print ("Remove from the List") print (colors[1]) ## blue colors.remove("blue") ## deletes blue and shifts elements to the left print (colors[1]) ## green print ("Sorting Ascending order using sorted") nums = [98,22,45,30] numsAsc = sorted(nums) print (numsAsc[0]) ## 22 print (numsAsc[1]) ## 30 print (numsAsc[2]) ## 45 print ("Sorting Descending order using sorted") numsDesc = sorted(nums,reverse=True) print (numsDesc[0]) ## 98 print (numsDesc[1]) ## 45 print (numsDesc[2]) ## 30
print('Creating List:') colors = ['red', 'blue', 'green'] print(colors[0]) print(colors[1]) print(colors[2]) print(len(colors)) print('Append to the List') colors.append('orange') print(colors[3]) print('Insert to the List') colors.insert(3, 'yellow') print(colors[3]) print(colors[4]) print('Remove from the List') print(colors[1]) colors.remove('blue') print(colors[1]) print('Sorting Ascending order using sorted') nums = [98, 22, 45, 30] nums_asc = sorted(nums) print(numsAsc[0]) print(numsAsc[1]) print(numsAsc[2]) print('Sorting Descending order using sorted') nums_desc = sorted(nums, reverse=True) print(numsDesc[0]) print(numsDesc[1]) print(numsDesc[2])
class Solution: def find_averages(self, k, arr): result = [] window_sum = 0 window_start = 0 for window_end in range(len(arr)): window_sum += arr[window_end] if window_end >= k - 1: result.append(window_sum / k) window_sum -= arr[window_start] window_start += 1 return result def main(): solution = Solution() print(solution.find_averages(5, [1, 3, 2, 6, -1, 4, 1, 8, 2])) if __name__ == '__main__': main()
class Solution: def find_averages(self, k, arr): result = [] window_sum = 0 window_start = 0 for window_end in range(len(arr)): window_sum += arr[window_end] if window_end >= k - 1: result.append(window_sum / k) window_sum -= arr[window_start] window_start += 1 return result def main(): solution = solution() print(solution.find_averages(5, [1, 3, 2, 6, -1, 4, 1, 8, 2])) if __name__ == '__main__': main()
# calculting factorial using recursion def Fact(n): return (n * Fact(n-1) if (n > 1) else 1.0) #main num = int(input("n = ")) print(Fact(num))
def fact(n): return n * fact(n - 1) if n > 1 else 1.0 num = int(input('n = ')) print(fact(num))
# https://www.hackerrank.com/challenges/ctci-lonely-integer def lonely_integer(a): bitArray = 0b0 for ele in a: bitArray = bitArray ^ ele # print(ele, bin(bitArray)) return int(bitArray)
def lonely_integer(a): bit_array = 0 for ele in a: bit_array = bitArray ^ ele return int(bitArray)
andmed = [] nimekiri = open("nimekiri.txt", encoding="UTF-8") for rida in nimekiri: f = open(rida.strip() + ".txt", encoding="UTF-8") kirje = {} for attr in f: osad = attr.strip().split(": ") kirje[osad[0]] = osad[1] f.close() andmed.append(kirje) nimekiri.close() uus_failinimi = input("Sisesta uue faili nimi: ") veerud = input("Sisesta attribuutide nimed: ") uus = open(uus_failinimi, mode="w", encoding="utf-8") uus.write(veerud + "\n") for isik in andmed: atts = [] for veerg in veerud.split(","): if veerg in isik: atts.append(isik[veerg]) else: atts.append("") uus.write(",".join(atts) + "\n") uus.close()
andmed = [] nimekiri = open('nimekiri.txt', encoding='UTF-8') for rida in nimekiri: f = open(rida.strip() + '.txt', encoding='UTF-8') kirje = {} for attr in f: osad = attr.strip().split(': ') kirje[osad[0]] = osad[1] f.close() andmed.append(kirje) nimekiri.close() uus_failinimi = input('Sisesta uue faili nimi: ') veerud = input('Sisesta attribuutide nimed: ') uus = open(uus_failinimi, mode='w', encoding='utf-8') uus.write(veerud + '\n') for isik in andmed: atts = [] for veerg in veerud.split(','): if veerg in isik: atts.append(isik[veerg]) else: atts.append('') uus.write(','.join(atts) + '\n') uus.close()
# window's attributes TITLE = 'Arkanoid.py' WIDTH = 640 HEIGHT = 400 ICON = 'images/ball.png'
title = 'Arkanoid.py' width = 640 height = 400 icon = 'images/ball.png'
elemDictInv = { 100:'TrivialElement', 101:'PolyElement', 102:'NullElement', 110:'DirichletNode', 111:'DirichletNodeLag', 112:'zeroVariable', 120:'NodalForce', 121:'NodalForceLine', 130:'setMaterialParam', 131:'setDamageParam', 132:'IncrementVariables', 133:'insertDeformation', 134:'insertDeformationGeneral', 140:'posProcElem', 141:'posProcElemOld', 142:'Cell2Point', 143:'PosProcElemNew', 150:'Viscosity', 200:'FSgen', 201:'FSgenMixedStab', 203:'FSgen_newDamage', 210:'NeumannFiniteStrain', 211:'NeumannFiniteStrainSpatial', 212:'NeumannRefTraction', 300:'damageEvolution', 400:'StressHom', 410:'TotalDisp', 4410:'TotalDisp3D', 420:'minRestrictionBC2DExact', 421:'minRestrictionRVE', 422:'enforcePeriodic2D', 423:'MRmeanVolRVE', 424:'enforcePeriodic2D_inc', 425:'enforcePeriodic2D_inc_copy', 430:'canonicalProblem', 431:'computeTangent', 432:'TangentHom', 433:'computeMinDetQ', 434:'computeMinDetQNew', 440:'DecisionBifurcation', 441:'LocDomainBC', 442:'MarkLocPoint', 443:'LocPointsBC', 500:'nonlinearFibres', 501:'nonlinearFibresDamage', 502:'nonlinearFibresDamage_localised', 503:'NonLinFibresGen', 504:'NonlinearFibresQuang', 505:'nonlinearFibresDamage_viscous', 5505:'nonlinearFibresDamage_viscous3D', 506:'torsionalSpring', 507:'networkConstraintGen_pureInc', 5507:'networkConstraintGen_pureInc3D', 508:'networkConstraintLinear', 5508:'networkConstraintLinear3D', 509:'networkConstraintGen', 5509:'networkConstraintGen3D', 510:'networkConstraint', 511:'networkConstraint_noVolume', 512:'affineBoundary', 513:'networkConstraint_delta', 514:'networkConstraint_RVEnormal_new_gen', 515:'networkConstraintTheta', 516:'affineBoundaryTheta', 517:'networkConstraint_RVEnormal', 518:'networkConstraint_RVEnormal_', 519:'networkConstraint_RVEnormal_new', 520:'computeAnisotropyTensor', 521:'computeAnisotropyTensorInv', 530:'damageEvolutionFibres', 540:'initParamFibres', 5550:'posProcFibres3D', 550:'posProcFibres', 560:'canonicalProblemFibres', 561:'tangentHomFibres', 601:'zeroVariable_arcLength', 602:'computeCoeficientsCilindrical_arcLength', 603:'incrementIncrementEstimation', 604:'chooseIncrementLambda', 605:'incrementDisplacementsArcLength', 606:'enforcePeriodic2D_arcLength', 607:'incrementBoundaryMultipliersArcLength', 608:'IncrementVariables_Conditional', 609:'IncrementVariablesArcLength', 610:'arcLengthConsistent', 611:'incrementLambda', 612:'incrementLambdaArcLength', 613:'computeCoeficientsSpherical_arcLength', 614:'PosProcElem_arcLength', 615:'zeroVariable_arcLength2', 616:'zeroVariable_arcLength_generic', 617:'computeCoeficientsArcLength_generic', 700:'arcLength_simple', 701:'zeroVariable_arcLength_simple', 702:'computeCoeficientsCilindrical_arcLength_simple', 703:'computeIncrementEstimation_simple', 704:'chooseIncrementLambda_simple', 705:'incrementDisplacementsArcLength_simple', 706:'computeCoeficientsSpherical_arcLength_simple'} elemDict = dict(zip(elemDictInv.values(),elemDictInv.keys()))
elem_dict_inv = {100: 'TrivialElement', 101: 'PolyElement', 102: 'NullElement', 110: 'DirichletNode', 111: 'DirichletNodeLag', 112: 'zeroVariable', 120: 'NodalForce', 121: 'NodalForceLine', 130: 'setMaterialParam', 131: 'setDamageParam', 132: 'IncrementVariables', 133: 'insertDeformation', 134: 'insertDeformationGeneral', 140: 'posProcElem', 141: 'posProcElemOld', 142: 'Cell2Point', 143: 'PosProcElemNew', 150: 'Viscosity', 200: 'FSgen', 201: 'FSgenMixedStab', 203: 'FSgen_newDamage', 210: 'NeumannFiniteStrain', 211: 'NeumannFiniteStrainSpatial', 212: 'NeumannRefTraction', 300: 'damageEvolution', 400: 'StressHom', 410: 'TotalDisp', 4410: 'TotalDisp3D', 420: 'minRestrictionBC2DExact', 421: 'minRestrictionRVE', 422: 'enforcePeriodic2D', 423: 'MRmeanVolRVE', 424: 'enforcePeriodic2D_inc', 425: 'enforcePeriodic2D_inc_copy', 430: 'canonicalProblem', 431: 'computeTangent', 432: 'TangentHom', 433: 'computeMinDetQ', 434: 'computeMinDetQNew', 440: 'DecisionBifurcation', 441: 'LocDomainBC', 442: 'MarkLocPoint', 443: 'LocPointsBC', 500: 'nonlinearFibres', 501: 'nonlinearFibresDamage', 502: 'nonlinearFibresDamage_localised', 503: 'NonLinFibresGen', 504: 'NonlinearFibresQuang', 505: 'nonlinearFibresDamage_viscous', 5505: 'nonlinearFibresDamage_viscous3D', 506: 'torsionalSpring', 507: 'networkConstraintGen_pureInc', 5507: 'networkConstraintGen_pureInc3D', 508: 'networkConstraintLinear', 5508: 'networkConstraintLinear3D', 509: 'networkConstraintGen', 5509: 'networkConstraintGen3D', 510: 'networkConstraint', 511: 'networkConstraint_noVolume', 512: 'affineBoundary', 513: 'networkConstraint_delta', 514: 'networkConstraint_RVEnormal_new_gen', 515: 'networkConstraintTheta', 516: 'affineBoundaryTheta', 517: 'networkConstraint_RVEnormal', 518: 'networkConstraint_RVEnormal_', 519: 'networkConstraint_RVEnormal_new', 520: 'computeAnisotropyTensor', 521: 'computeAnisotropyTensorInv', 530: 'damageEvolutionFibres', 540: 'initParamFibres', 5550: 'posProcFibres3D', 550: 'posProcFibres', 560: 'canonicalProblemFibres', 561: 'tangentHomFibres', 601: 'zeroVariable_arcLength', 602: 'computeCoeficientsCilindrical_arcLength', 603: 'incrementIncrementEstimation', 604: 'chooseIncrementLambda', 605: 'incrementDisplacementsArcLength', 606: 'enforcePeriodic2D_arcLength', 607: 'incrementBoundaryMultipliersArcLength', 608: 'IncrementVariables_Conditional', 609: 'IncrementVariablesArcLength', 610: 'arcLengthConsistent', 611: 'incrementLambda', 612: 'incrementLambdaArcLength', 613: 'computeCoeficientsSpherical_arcLength', 614: 'PosProcElem_arcLength', 615: 'zeroVariable_arcLength2', 616: 'zeroVariable_arcLength_generic', 617: 'computeCoeficientsArcLength_generic', 700: 'arcLength_simple', 701: 'zeroVariable_arcLength_simple', 702: 'computeCoeficientsCilindrical_arcLength_simple', 703: 'computeIncrementEstimation_simple', 704: 'chooseIncrementLambda_simple', 705: 'incrementDisplacementsArcLength_simple', 706: 'computeCoeficientsSpherical_arcLength_simple'} elem_dict = dict(zip(elemDictInv.values(), elemDictInv.keys()))
tupla = ('python', 'estudar', 'linguagem', 'curso', 'viajar', 'cinema', 'pipoca', 'futuro', 'programador', 'mercado') for c in tupla: print(f'\nNa palavra {c} temos as vogais:', end=' ') for vogais in c: if vogais.lower() in 'aeiou': print(vogais, end=' ')
tupla = ('python', 'estudar', 'linguagem', 'curso', 'viajar', 'cinema', 'pipoca', 'futuro', 'programador', 'mercado') for c in tupla: print(f'\nNa palavra {c} temos as vogais:', end=' ') for vogais in c: if vogais.lower() in 'aeiou': print(vogais, end=' ')
# Funcion de evaluacion de calidad de codigo. Devuelve un entero con un numero que representa la calidad. Cuanto mas cercano a 0 esten los valores, mayor sera la calidad. def evaluateCode(listOfRefactors): # Good code -> Close to 0 # Bad code -> Far from 0 codeQuality = 0 for refactor in listOfRefactors: codeQuality = refactor['nPriority'] + codeQuality return codeQuality
def evaluate_code(listOfRefactors): code_quality = 0 for refactor in listOfRefactors: code_quality = refactor['nPriority'] + codeQuality return codeQuality
DIRECTIONS = { "U": (0, 1), "D": (0, -1), "L": (-1, 0), "R": (1, 0) } def wire_to_point_set(wire): s = set() d = dict() x, y, steps = 0, 0, 0 for w in wire: dx, dy = DIRECTIONS[w[0]] dist = int(w[1:]) for _ in range(dist): x += dx y += dy s.add((x, y)) steps += 1 if (x, y) not in d: d[(x, y)] = steps return s, d if __name__ == "__main__": with open('3.txt') as f: wires = [line.strip().split(',') for line in f.readlines()] w1, w2 = wires s1, d1 = wire_to_point_set(w1) s2, d2 = wire_to_point_set(w2) intersections = s1 & s2 p1_intersections = [(abs(x) + abs(y), (x, y)) for (x, y) in intersections] p1_intersections.sort() print("Part 1: {}".format(p1_intersections[0][0])) p2_intersections = [(d1[p] + d2[p], p) for p in intersections] p2_intersections.sort() print("Part 2: {}".format(p2_intersections[0][0]))
directions = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)} def wire_to_point_set(wire): s = set() d = dict() (x, y, steps) = (0, 0, 0) for w in wire: (dx, dy) = DIRECTIONS[w[0]] dist = int(w[1:]) for _ in range(dist): x += dx y += dy s.add((x, y)) steps += 1 if (x, y) not in d: d[x, y] = steps return (s, d) if __name__ == '__main__': with open('3.txt') as f: wires = [line.strip().split(',') for line in f.readlines()] (w1, w2) = wires (s1, d1) = wire_to_point_set(w1) (s2, d2) = wire_to_point_set(w2) intersections = s1 & s2 p1_intersections = [(abs(x) + abs(y), (x, y)) for (x, y) in intersections] p1_intersections.sort() print('Part 1: {}'.format(p1_intersections[0][0])) p2_intersections = [(d1[p] + d2[p], p) for p in intersections] p2_intersections.sort() print('Part 2: {}'.format(p2_intersections[0][0]))
def main(): print("Welcome To play Ground") # Invocation if __name__ == "__main__": main() myInt = 5 myFloat = 13.2 myString = "Hello" myBool = True myList = [0, 1, "Two", 3.4, 78, 89, 45, 67] myTuple = (0, 1, 2) myDict = {"one": 1, "Two": 2} # Random print Statements print(myDict) print(myTuple) print(myInt) print(myList) print(myFloat) print(myString) # Slicing in list print(myList) print(myList[2:5]) print(myList[::-1]) print(myList[:5]) print(myList[5]) # Dicts Accessing via keys print(myDict["Two"]) # Error : Variables of Different Types can't be Combined print("String" + str(123)) # Global vs Local Variables def some(): myString = "inside function" print(myString) def addition(arg1, arg2): # for default args we can use like => function(arg1, arg2=x) : result = 1 for i in range(arg2): result = result * arg1 return result def multiArg(*args): # we can have multiple args with multi, but it should always atLast result = 0 for x in args: result = result + x return result def conditionals(): x, y = 10, 100 result = "x is greater" if x > y else "y is greater" value = "three" match value: case "one": result = 1 case "two": result = 2 case "three" | "four": result = (3, 4) case _: result = -1 print(result) print("---------") x = 0 while x < 5: print(x) x = x + 1 print("---------") days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] for day in days: print(day) print("---------") for x in range(5, 10): # if x == 7: # break if x % 2 == 0: continue print(x) print("---------") for i, d in enumerate(days): print(i, d) print("---------") some() print("============") print(myString) print("============") print(some()) print("============") print(addition(2, 10)) print("============") print(multiArg(2, 3, 4, 5, 6, 4)) print("============") conditionals() print("============")
def main(): print('Welcome To play Ground') if __name__ == '__main__': main() my_int = 5 my_float = 13.2 my_string = 'Hello' my_bool = True my_list = [0, 1, 'Two', 3.4, 78, 89, 45, 67] my_tuple = (0, 1, 2) my_dict = {'one': 1, 'Two': 2} print(myDict) print(myTuple) print(myInt) print(myList) print(myFloat) print(myString) print(myList) print(myList[2:5]) print(myList[::-1]) print(myList[:5]) print(myList[5]) print(myDict['Two']) print('String' + str(123)) def some(): my_string = 'inside function' print(myString) def addition(arg1, arg2): result = 1 for i in range(arg2): result = result * arg1 return result def multi_arg(*args): result = 0 for x in args: result = result + x return result def conditionals(): (x, y) = (10, 100) result = 'x is greater' if x > y else 'y is greater' value = 'three' match value: case 'one': result = 1 case 'two': result = 2 case 'three' | 'four': result = (3, 4) case _: result = -1 print(result) print('---------') x = 0 while x < 5: print(x) x = x + 1 print('---------') days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] for day in days: print(day) print('---------') for x in range(5, 10): if x % 2 == 0: continue print(x) print('---------') for (i, d) in enumerate(days): print(i, d) print('---------') some() print('============') print(myString) print('============') print(some()) print('============') print(addition(2, 10)) print('============') print(multi_arg(2, 3, 4, 5, 6, 4)) print('============') conditionals() print('============')
expected_output = { "version": 3, "interfaces": { "GigabitEthernet1/0/9": { "interface": "GigabitEthernet1/0/9", "max_start": 3, "pae": "supplicant", "credentials": "switch4", "supplicant": {"eap": {"profile": "EAP-METH"}}, "timeout": {"held_period": 60, "start_period": 30, "auth_period": 30}, } }, "system_auth_control": True, }
expected_output = {'version': 3, 'interfaces': {'GigabitEthernet1/0/9': {'interface': 'GigabitEthernet1/0/9', 'max_start': 3, 'pae': 'supplicant', 'credentials': 'switch4', 'supplicant': {'eap': {'profile': 'EAP-METH'}}, 'timeout': {'held_period': 60, 'start_period': 30, 'auth_period': 30}}}, 'system_auth_control': True}
def isintersect(a,b): for i in a: for j in b: if i==j: return True return False class RopChain(object): def __init__(self): self.chains = [] self.dump_str = None self.payload = b"" self.base_addr = 0 self.next_call = None self.is_noreturn = False def merge_ropchain(self, ropchain): assert not self.is_noreturn, "can't merge ropchain, this chain is no-return" assert isinstance(ropchain, RopChain), "not RopChain instance" if self.next_call: self.append(self.next_call) for chain in ropchain.chains: self.append(chain) self.next_call = ropchain.next_call def __add__(self, ropchain): self.merge_ropchain(ropchain) return self def set_next_call(self, addr, type_val=0, comment=""): chain = Chain() chain.set_chain_values([ChainItem(addr, type_val, comment)]) self.next_call = chain def set_base_addr(self, addr): self.base_addr = addr def insert(self, idx, chain): self.chains.insert(idx, chain) def append(self, chain): self.chains.append(chain) def insert_chain(self, chain): intersect = False if isintersect(chain.written_regs, set(self.get_solved_regs())): intersect = True if intersect and len(self.chains) > 0: for i in range(len(self.chains)-1, -1, -1): solved_before = set(self.get_solved_regs(0,i+1)) written_before = set(self.get_written_regs(0, i+1)) if isintersect(chain.solved_regs, self.chains[i].written_regs) and not isintersect(solved_before, chain.written_regs): self.insert(i+1, chain) break if i == 0: regs_used_after = set(self.get_written_regs()) depends_regs_after = set(self.get_depends_regs()) if not isintersect(chain.solved_regs, regs_used_after) and not isintersect(chain.written_regs, depends_regs_after): self.insert(0, chain) else: return False else: self.append(chain) return True def get_solved_regs(self, start_chain=None, end_chain=None): regs_solved = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_solved.update(chain.solved_regs) return regs_solved def get_written_regs(self, start_chain=None, end_chain=None): regs_written = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_written.update(chain.written_regs) return regs_written def get_depends_regs(self, start_chain=None, end_chain=None): regs_depends = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_depends.update(chain.depends_regs) return regs_depends def get_chains(self): chains = [] for chain in self.chains: chains.extend(chain.get_chains()) return chains def get_comment(self): comments = [] for chain in self.chains: comments.extend(chain.comment) return comments def dump(self): next_sp = 0 for chain in self.chains: next_sp = chain.dump(next_sp, self.base_addr) if self.next_call: self.next_call.dump(next_sp, self.base_addr) print("") def payload_str(self): payload = b"" for chain in self.chains: payload += chain.payload_str(self.base_addr) if self.next_call: payload += self.next_call.payload_str(self.base_addr) return payload CHAINITEM_TYPE_VALUE = 0 CHAINITEM_TYPE_ADDR = 1 class ChainItem(object): def __init__(self, value=0, idx_chain=-1, comment="", type_val=0): self.value = value self.type_val = type_val self.comment = comment self.idx_chain = idx_chain def parseFromModel(chain_value_model, comment="", type_val=0): chain_item = chain_value_model[0] alias = chain_item.getVariable().getAlias() idxchain = int(alias.replace("STACK", "")) + 1 chain_value = chain_item.getValue() return ChainItem(chain_value, idxchain, comment, type_val) def getValue(self, base_addr=0): if base_addr and self.type_val == 1: # check if value is address return self.value + base_addr return self.value class Chain(object): def __init__(self): self.written_regs = set() self.solved_regs = set() self.depends_regs = set() self.gadget = None self.chain_values = [] def set_chain_values(self, chain_values): self.chain_values = chain_values def set_solved(self, gadget, values, regs=set(), written_regs=set(), depends_regs=set()): self.solved_regs.update(regs) self.written_regs.update(gadget.written_regs) self.written_regs.update(written_regs) self.depends_regs.update(depends_regs) self.gadget = gadget depends_chain_values = [] chain_values = [ChainItem(0)]*(gadget.diff_sp//8 + 1) chain_values[0] = ChainItem(gadget.addr, 0, str(gadget), CHAINITEM_TYPE_ADDR) for chain_item in values: if isinstance(chain_item, RopChain): self.written_regs.update(chain_item.get_written_regs()) self.depends_regs.update(chain_item.get_depends_regs()) depends_chain_values += chain_item.get_chains() continue if chain_item: chain_values[chain_item.idx_chain] = chain_item self.chain_values += depends_chain_values + chain_values if gadget.end_gadget: self.written_regs.update(gadget.end_gadget.written_regs) def get_chains(self): return self.chain_values def get_written_regs(self): return self.written_regs def get_solved_regs(self): return self.solved_regs def dump(self, sp, base_addr=0): chains = self.get_chains() dump_str = "" for i in range(len(chains)): chain = chains[i] com = "" if chain.comment: com = " # {}".format(chain.comment) dump_str += "$RSP+0x{:04x} : 0x{:016x}{}\n".format(sp, chain.getValue(base_addr), com) sp += 8 print(dump_str, end="") return sp def payload_str(self, base_addr=0): chains = self.get_chains() payload = b"" for i in range(len(chains)): chain = chains[i] payload += chain.getValue(base_addr).to_bytes(8, 'little') return payload def __repr__(self): return "written_regs : {}\nsolved_regs: {}\n".format(self.written_regs, self.solved_regs) def __str__(self): return "written_regs : {}\nsolved_regs: {}\n".format(self.written_regs, self.solved_regs)
def isintersect(a, b): for i in a: for j in b: if i == j: return True return False class Ropchain(object): def __init__(self): self.chains = [] self.dump_str = None self.payload = b'' self.base_addr = 0 self.next_call = None self.is_noreturn = False def merge_ropchain(self, ropchain): assert not self.is_noreturn, "can't merge ropchain, this chain is no-return" assert isinstance(ropchain, RopChain), 'not RopChain instance' if self.next_call: self.append(self.next_call) for chain in ropchain.chains: self.append(chain) self.next_call = ropchain.next_call def __add__(self, ropchain): self.merge_ropchain(ropchain) return self def set_next_call(self, addr, type_val=0, comment=''): chain = chain() chain.set_chain_values([chain_item(addr, type_val, comment)]) self.next_call = chain def set_base_addr(self, addr): self.base_addr = addr def insert(self, idx, chain): self.chains.insert(idx, chain) def append(self, chain): self.chains.append(chain) def insert_chain(self, chain): intersect = False if isintersect(chain.written_regs, set(self.get_solved_regs())): intersect = True if intersect and len(self.chains) > 0: for i in range(len(self.chains) - 1, -1, -1): solved_before = set(self.get_solved_regs(0, i + 1)) written_before = set(self.get_written_regs(0, i + 1)) if isintersect(chain.solved_regs, self.chains[i].written_regs) and (not isintersect(solved_before, chain.written_regs)): self.insert(i + 1, chain) break if i == 0: regs_used_after = set(self.get_written_regs()) depends_regs_after = set(self.get_depends_regs()) if not isintersect(chain.solved_regs, regs_used_after) and (not isintersect(chain.written_regs, depends_regs_after)): self.insert(0, chain) else: return False else: self.append(chain) return True def get_solved_regs(self, start_chain=None, end_chain=None): regs_solved = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_solved.update(chain.solved_regs) return regs_solved def get_written_regs(self, start_chain=None, end_chain=None): regs_written = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_written.update(chain.written_regs) return regs_written def get_depends_regs(self, start_chain=None, end_chain=None): regs_depends = set() chains = self.chains[start_chain:end_chain] for chain in chains: regs_depends.update(chain.depends_regs) return regs_depends def get_chains(self): chains = [] for chain in self.chains: chains.extend(chain.get_chains()) return chains def get_comment(self): comments = [] for chain in self.chains: comments.extend(chain.comment) return comments def dump(self): next_sp = 0 for chain in self.chains: next_sp = chain.dump(next_sp, self.base_addr) if self.next_call: self.next_call.dump(next_sp, self.base_addr) print('') def payload_str(self): payload = b'' for chain in self.chains: payload += chain.payload_str(self.base_addr) if self.next_call: payload += self.next_call.payload_str(self.base_addr) return payload chainitem_type_value = 0 chainitem_type_addr = 1 class Chainitem(object): def __init__(self, value=0, idx_chain=-1, comment='', type_val=0): self.value = value self.type_val = type_val self.comment = comment self.idx_chain = idx_chain def parse_from_model(chain_value_model, comment='', type_val=0): chain_item = chain_value_model[0] alias = chain_item.getVariable().getAlias() idxchain = int(alias.replace('STACK', '')) + 1 chain_value = chain_item.getValue() return chain_item(chain_value, idxchain, comment, type_val) def get_value(self, base_addr=0): if base_addr and self.type_val == 1: return self.value + base_addr return self.value class Chain(object): def __init__(self): self.written_regs = set() self.solved_regs = set() self.depends_regs = set() self.gadget = None self.chain_values = [] def set_chain_values(self, chain_values): self.chain_values = chain_values def set_solved(self, gadget, values, regs=set(), written_regs=set(), depends_regs=set()): self.solved_regs.update(regs) self.written_regs.update(gadget.written_regs) self.written_regs.update(written_regs) self.depends_regs.update(depends_regs) self.gadget = gadget depends_chain_values = [] chain_values = [chain_item(0)] * (gadget.diff_sp // 8 + 1) chain_values[0] = chain_item(gadget.addr, 0, str(gadget), CHAINITEM_TYPE_ADDR) for chain_item in values: if isinstance(chain_item, RopChain): self.written_regs.update(chain_item.get_written_regs()) self.depends_regs.update(chain_item.get_depends_regs()) depends_chain_values += chain_item.get_chains() continue if chain_item: chain_values[chain_item.idx_chain] = chain_item self.chain_values += depends_chain_values + chain_values if gadget.end_gadget: self.written_regs.update(gadget.end_gadget.written_regs) def get_chains(self): return self.chain_values def get_written_regs(self): return self.written_regs def get_solved_regs(self): return self.solved_regs def dump(self, sp, base_addr=0): chains = self.get_chains() dump_str = '' for i in range(len(chains)): chain = chains[i] com = '' if chain.comment: com = ' # {}'.format(chain.comment) dump_str += '$RSP+0x{:04x} : 0x{:016x}{}\n'.format(sp, chain.getValue(base_addr), com) sp += 8 print(dump_str, end='') return sp def payload_str(self, base_addr=0): chains = self.get_chains() payload = b'' for i in range(len(chains)): chain = chains[i] payload += chain.getValue(base_addr).to_bytes(8, 'little') return payload def __repr__(self): return 'written_regs : {}\nsolved_regs: {}\n'.format(self.written_regs, self.solved_regs) def __str__(self): return 'written_regs : {}\nsolved_regs: {}\n'.format(self.written_regs, self.solved_regs)
def triplets_with_sum(number): triplets = [] for a in range(1, number // 3): l = a + 1 r = (number - a - 1) // 2 while l <= r: b = (l + r) // 2 c = number - a - b if a * a + b * b < c * c: l = b + 1 elif a * a + b * b > c * c: r = b - 1 else: triplets.append([a, b, c]) break return triplets
def triplets_with_sum(number): triplets = [] for a in range(1, number // 3): l = a + 1 r = (number - a - 1) // 2 while l <= r: b = (l + r) // 2 c = number - a - b if a * a + b * b < c * c: l = b + 1 elif a * a + b * b > c * c: r = b - 1 else: triplets.append([a, b, c]) break return triplets
class ChangeTextState: def __init__(self): self.prev_tail = '' self.context = None _change_text_state = None def init(): global _change_text_state _change_text_state = ChangeTextState() init() def get_state() -> ChangeTextState: global _change_text_state if _change_text_state is None: _change_text_state = ChangeTextState() return _change_text_state
class Changetextstate: def __init__(self): self.prev_tail = '' self.context = None _change_text_state = None def init(): global _change_text_state _change_text_state = change_text_state() init() def get_state() -> ChangeTextState: global _change_text_state if _change_text_state is None: _change_text_state = change_text_state() return _change_text_state
Size = (512, 748) ScaleFactor = 0.33 ZoomLevel = 1.0 Orientation = -90 Mirror = True NominalPixelSize = 0.002325 filename = '' ImageWindow.Center = (680, 512) ImageWindow.ViewportCenter = (1.1904, 1.5774772727272726) ImageWindow.crosshair_color = (255, 0, 255) ImageWindow.boxsize = (0.1, 0.06) ImageWindow.box_color = (128, 128, 255) ImageWindow.show_box = False ImageWindow.Scale = [[0.062775, -0.5417249999999999], [0.9044249999999999, -0.5324249999999999]] ImageWindow.show_scale = False ImageWindow.scale_color = (255, 0, 255) ImageWindow.crosshair_size = (0.05, 0.05) ImageWindow.show_crosshair = True ImageWindow.show_profile = False ImageWindow.show_FWHM = False ImageWindow.show_center = False ImageWindow.calculate_section = False ImageWindow.profile_color = (255, 0, 255) ImageWindow.FWHM_color = (0, 0, 255) ImageWindow.center_color = (0, 0, 255) ImageWindow.ROI = [[-0.299925, -0.5905499999999999], [0.3999, 0.19529999999999997]] ImageWindow.ROI_color = (255, 255, 0) ImageWindow.show_saturated_pixels = False ImageWindow.mask_bad_pixels = False ImageWindow.saturation_threshold = 233 ImageWindow.saturated_color = (255, 0, 0) ImageWindow.linearity_correction = False ImageWindow.bad_pixel_threshold = 233 ImageWindow.bad_pixel_color = (30, 30, 30) ImageWindow.show_grid = False ImageWindow.grid_type = u'xy' ImageWindow.grid_color = (98, 98, 98) ImageWindow.grid_x_spacing = 0.1 ImageWindow.grid_x_offset = 0.0 ImageWindow.grid_y_spacing = 1.0 ImageWindow.grid_y_offset = 0.0 camera.use_multicast = False camera.IP_addr = u'id14b-prosilica1.cars.aps.anl.gov'
size = (512, 748) scale_factor = 0.33 zoom_level = 1.0 orientation = -90 mirror = True nominal_pixel_size = 0.002325 filename = '' ImageWindow.Center = (680, 512) ImageWindow.ViewportCenter = (1.1904, 1.5774772727272726) ImageWindow.crosshair_color = (255, 0, 255) ImageWindow.boxsize = (0.1, 0.06) ImageWindow.box_color = (128, 128, 255) ImageWindow.show_box = False ImageWindow.Scale = [[0.062775, -0.5417249999999999], [0.9044249999999999, -0.5324249999999999]] ImageWindow.show_scale = False ImageWindow.scale_color = (255, 0, 255) ImageWindow.crosshair_size = (0.05, 0.05) ImageWindow.show_crosshair = True ImageWindow.show_profile = False ImageWindow.show_FWHM = False ImageWindow.show_center = False ImageWindow.calculate_section = False ImageWindow.profile_color = (255, 0, 255) ImageWindow.FWHM_color = (0, 0, 255) ImageWindow.center_color = (0, 0, 255) ImageWindow.ROI = [[-0.299925, -0.5905499999999999], [0.3999, 0.19529999999999997]] ImageWindow.ROI_color = (255, 255, 0) ImageWindow.show_saturated_pixels = False ImageWindow.mask_bad_pixels = False ImageWindow.saturation_threshold = 233 ImageWindow.saturated_color = (255, 0, 0) ImageWindow.linearity_correction = False ImageWindow.bad_pixel_threshold = 233 ImageWindow.bad_pixel_color = (30, 30, 30) ImageWindow.show_grid = False ImageWindow.grid_type = u'xy' ImageWindow.grid_color = (98, 98, 98) ImageWindow.grid_x_spacing = 0.1 ImageWindow.grid_x_offset = 0.0 ImageWindow.grid_y_spacing = 1.0 ImageWindow.grid_y_offset = 0.0 camera.use_multicast = False camera.IP_addr = u'id14b-prosilica1.cars.aps.anl.gov'
#! /usr/bin/env python3 def analyse_pattern(ls) : corresponds = {2:1,7:8,4:4,3:7} dct = {corresponds[len(i)]:i for i in ls if len(i) in [2, 3, 4, 7]} for i in range(10) : s = len(ls[i]) if s == 6 : #0 6 9 if sum(ls[i][j] in dct[4] for j in range(s)) == 3 : if sum(ls[i][j] in dct[1] for j in range(s)) == 2 : dct[0] = ls[i] else : dct[6] = ls[i] else : dct[9] = ls[i] elif s == 5 : #2 3 5 if sum(ls[i][j] in dct[7] for j in range(s)) == 3 : dct[3] = ls[i] elif sum(ls[i][j] in dct[4] for j in range(s)) == 3 : dct[5] = ls[i] else : dct[2] = ls[i] return dct def get_number(dct, n) : return int([i for i in range(10) if len(n) == len(dct[i]) and all(c in dct[i] for c in n)][0]) numbers = [tuple(map(lambda x:x.split(), line.split("|"))) for line in open("input")] print(sum(sum(10**(len(signals)-i-1) * get_number(analyse_pattern(patterns), signals[i]) for i in range(len(signals))) for patterns, signals in numbers))
def analyse_pattern(ls): corresponds = {2: 1, 7: 8, 4: 4, 3: 7} dct = {corresponds[len(i)]: i for i in ls if len(i) in [2, 3, 4, 7]} for i in range(10): s = len(ls[i]) if s == 6: if sum((ls[i][j] in dct[4] for j in range(s))) == 3: if sum((ls[i][j] in dct[1] for j in range(s))) == 2: dct[0] = ls[i] else: dct[6] = ls[i] else: dct[9] = ls[i] elif s == 5: if sum((ls[i][j] in dct[7] for j in range(s))) == 3: dct[3] = ls[i] elif sum((ls[i][j] in dct[4] for j in range(s))) == 3: dct[5] = ls[i] else: dct[2] = ls[i] return dct def get_number(dct, n): return int([i for i in range(10) if len(n) == len(dct[i]) and all((c in dct[i] for c in n))][0]) numbers = [tuple(map(lambda x: x.split(), line.split('|'))) for line in open('input')] print(sum((sum((10 ** (len(signals) - i - 1) * get_number(analyse_pattern(patterns), signals[i]) for i in range(len(signals)))) for (patterns, signals) in numbers)))
class Solution: def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode: if not postorder: return root = TreeNode(postorder[-1]) rootpos = inorder.index(postorder[-1]) root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos]) root.right = self.buildTree(inorder[rootpos + 1 :], postorder[rootpos : -1]) return root
class Solution: def build_tree(self, inorder: List[int], postorder: List[int]) -> TreeNode: if not postorder: return root = tree_node(postorder[-1]) rootpos = inorder.index(postorder[-1]) root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos]) root.right = self.buildTree(inorder[rootpos + 1:], postorder[rootpos:-1]) return root
class Node: def __init__(self, data=None, next=None): self.__data = data self.__next = next @property def data(self): return self.__data @data.setter def data(self, data): self.__data = data @property def next(self): return self.__next @next.setter def next(self, ptr): self.__next = ptr def equals(node1, node2): if node1 is None and node2 is None: return True elif node1 is None or node2 is None: return False else: return (node1.data == node2.data) and (equals(node1.next, node2.next))
class Node: def __init__(self, data=None, next=None): self.__data = data self.__next = next @property def data(self): return self.__data @data.setter def data(self, data): self.__data = data @property def next(self): return self.__next @next.setter def next(self, ptr): self.__next = ptr def equals(node1, node2): if node1 is None and node2 is None: return True elif node1 is None or node2 is None: return False else: return node1.data == node2.data and equals(node1.next, node2.next)
def y(): raise TypeError def x(): y() try: x() except TypeError: print("x")
def y(): raise TypeError def x(): y() try: x() except TypeError: print('x')
# nominal reactor positions data = dict([ ('YJ1', [52.5]), ('YJ2', [52.5]), ('YJ3', [52.5]), ('YJ4', [52.5]), ('YJ5', [52.5]), ('YJ6', [52.5]), ('TS1', [52.5]), ('TS2', [52.5]), ('TS3', [52.5]), ('TS4', [52.5]), ('DYB', [215.0]), ('HZ', [265.0]), ])
data = dict([('YJ1', [52.5]), ('YJ2', [52.5]), ('YJ3', [52.5]), ('YJ4', [52.5]), ('YJ5', [52.5]), ('YJ6', [52.5]), ('TS1', [52.5]), ('TS2', [52.5]), ('TS3', [52.5]), ('TS4', [52.5]), ('DYB', [215.0]), ('HZ', [265.0])])
class Summary: def __init__(self, total_income, net_income, income_tax, employees_ni, employers_ni): self._total_income = total_income self._net_income = net_income self._income_tax = income_tax self._employees_ni = employees_ni self._employers_ni = employers_ni @property def total_income(self): return self._total_income @property def net_income(self): return self._net_income @property def income_tax(self): return self._income_tax @property def employees_ni(self): return self._employees_ni @property def employers_ni(self): return self._employers_ni
class Summary: def __init__(self, total_income, net_income, income_tax, employees_ni, employers_ni): self._total_income = total_income self._net_income = net_income self._income_tax = income_tax self._employees_ni = employees_ni self._employers_ni = employers_ni @property def total_income(self): return self._total_income @property def net_income(self): return self._net_income @property def income_tax(self): return self._income_tax @property def employees_ni(self): return self._employees_ni @property def employers_ni(self): return self._employers_ni
class Solution: def reverseOnlyLetters(self, s: str) -> str: def isChar(c): return True if ord('z')>=ord(c)>=ord('a') or ord('Z')>=ord(c)>=ord('A') else False right = len(s)-1 left = 0 charArray = [c for c in s] while left<right: print(charArray,right) while right>-1 and isChar(charArray[right])==False: right -= 1 if(not right>left): break while isChar(charArray[left])==False: left += 1 if(right>-1 and left < right): charArray[left],charArray[right] = charArray[right],charArray[left] left += 1 right -= 1 return ''.join(charArray)
class Solution: def reverse_only_letters(self, s: str) -> str: def is_char(c): return True if ord('z') >= ord(c) >= ord('a') or ord('Z') >= ord(c) >= ord('A') else False right = len(s) - 1 left = 0 char_array = [c for c in s] while left < right: print(charArray, right) while right > -1 and is_char(charArray[right]) == False: right -= 1 if not right > left: break while is_char(charArray[left]) == False: left += 1 if right > -1 and left < right: (charArray[left], charArray[right]) = (charArray[right], charArray[left]) left += 1 right -= 1 return ''.join(charArray)
def fp(i,n) : i /= 100 return (1+i)**n def pf(i,n) : i /= 100 return 1/((1+i)**n) def fa(i,n) : i /= 100 return (((1+i)**n)-1)/i def af(i,n) : i /= 100 return i/(((1+i)**n)-1) def pa(i,n) : i /= 100 return (((1+i)**n)-1)/(i*((1+i)**n)) def ap(i,n) : i /= 100 return (i*((1+i)**n))/(((1+i)**n)-1) def pg(i,n) : i /= 100 return (((1+i)**n)-(1+n*i))/((i**2)*((1+i)**n)) def ag(i,n) : i /= 100 return (1/i)-(n/(((1+i)**n)-1))
def fp(i, n): i /= 100 return (1 + i) ** n def pf(i, n): i /= 100 return 1 / (1 + i) ** n def fa(i, n): i /= 100 return ((1 + i) ** n - 1) / i def af(i, n): i /= 100 return i / ((1 + i) ** n - 1) def pa(i, n): i /= 100 return ((1 + i) ** n - 1) / (i * (1 + i) ** n) def ap(i, n): i /= 100 return i * (1 + i) ** n / ((1 + i) ** n - 1) def pg(i, n): i /= 100 return ((1 + i) ** n - (1 + n * i)) / (i ** 2 * (1 + i) ** n) def ag(i, n): i /= 100 return 1 / i - n / ((1 + i) ** n - 1)
# Copyright (c) 2018 Turysaz <turysaz@posteo.org> class IoCContainer(): def __init__(self): self.__constructors = {} # {"service_key" : service_ctor} self.__dependencies = {} # {"service_key" : ["dep_key_1", "dep_key_2", ..]} constructor parameters self.__quantity = {} # {"service_key" : "singleton" | "multiple"} self.__singletons = {} def register_on_demand(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, "multiple", dependencies) def register_singleton(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, "singleton", dependencies) def get_instance(self, service_name_string): if service_name_string not in self.__constructors: raise Exception() if self.__quantity[service_name_string] == "multiple": return __create_instance_recursive(service_name_string) elif self.__quantity[service_name_string] == "singleton": if service_name_string in self.__singletons: return self.__singletons[service_name_string] singleton = self.__create_instance_recursive(service_name_string) self.__singletons[service_name_string] = singleton return singleton def __register_internal(self, service_name_string, service, quantity, dependencies): if service_name_string in self.__constructors: raise Exception() # already registered self.__constructors[service_name_string] = service self.__dependencies[service_name_string] = dependencies self.__quantity[service_name_string] = quantity def __create_instance_recursive(self, service_name_string): deps = [self.get_instance(d) for d in self.__dependencies[service_name_string]] return self.__constructors[service_name_string](*deps)
class Ioccontainer: def __init__(self): self.__constructors = {} self.__dependencies = {} self.__quantity = {} self.__singletons = {} def register_on_demand(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, 'multiple', dependencies) def register_singleton(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, 'singleton', dependencies) def get_instance(self, service_name_string): if service_name_string not in self.__constructors: raise exception() if self.__quantity[service_name_string] == 'multiple': return __create_instance_recursive(service_name_string) elif self.__quantity[service_name_string] == 'singleton': if service_name_string in self.__singletons: return self.__singletons[service_name_string] singleton = self.__create_instance_recursive(service_name_string) self.__singletons[service_name_string] = singleton return singleton def __register_internal(self, service_name_string, service, quantity, dependencies): if service_name_string in self.__constructors: raise exception() self.__constructors[service_name_string] = service self.__dependencies[service_name_string] = dependencies self.__quantity[service_name_string] = quantity def __create_instance_recursive(self, service_name_string): deps = [self.get_instance(d) for d in self.__dependencies[service_name_string]] return self.__constructors[service_name_string](*deps)
# def isIPv4Address(inputString): # return len([num for num in inputString.split(".") if num != "" and 0 <= int(num) < 255]) == 4 # def isIPv4Address(inputString): # return len([int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255]) == 4 # def isIPv4Address(inputString): # print([num.isdigit() for num in inputString.split(".")]) # print(inputString.count(".")) # numbers = [int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255 and len(num) == len(str(int(num)))] # print(numbers) # print(len(numbers)) # return len(numbers) == 4 def isIPv4Address(inputString): if inputString.count(".") != 3: return False return len([int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255 and len(num) == len(str(int(num)))]) == 4 # 172.16.254.1 => True # 172.316.254.1 => False # .254.255.0 => False print(isIPv4Address("0..1.0.0"))
def is_i_pv4_address(inputString): if inputString.count('.') != 3: return False return len([int(num) for num in inputString.split('.') if num != '' and (not num.islower()) and (0 <= int(num) <= 255) and (len(num) == len(str(int(num))))]) == 4 print(is_i_pv4_address('0..1.0.0'))
def validTime(time): tokens = time.split(":") hours, mins = tokens[0], tokens[1] if int(hours) < 0 or int(hours) > 23: return False if int(mins) < 0 or int(mins) > 59: return False return True
def valid_time(time): tokens = time.split(':') (hours, mins) = (tokens[0], tokens[1]) if int(hours) < 0 or int(hours) > 23: return False if int(mins) < 0 or int(mins) > 59: return False return True
# # PySNMP MIB module AT-IGMP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-IGMP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:30:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint") modules, = mibBuilder.importSymbols("AT-SMI-MIB", "modules") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, ObjectIdentity, Counter32, iso, IpAddress, ModuleIdentity, Counter64, Bits, Unsigned32, NotificationType, MibIdentifier, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "ObjectIdentity", "Counter32", "iso", "IpAddress", "ModuleIdentity", "Counter64", "Bits", "Unsigned32", "NotificationType", "MibIdentifier", "Integer32") DisplayString, TruthValue, MacAddress, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TruthValue", "MacAddress", "TextualConvention") igmp = ModuleIdentity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139)) igmp.setRevisions(('2007-08-08 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: igmp.setRevisionsDescriptions(('Initial version, to support IGMP membership status polling.',)) if mibBuilder.loadTexts: igmp.setLastUpdated('200708080000Z') if mibBuilder.loadTexts: igmp.setOrganization('Allied Telesis, Inc.') if mibBuilder.loadTexts: igmp.setContactInfo(' Stan Xiang,Hamish Kellahan Allied Telesis EMail: support@alliedtelesis.co.nz') if mibBuilder.loadTexts: igmp.setDescription('The MIB module for IGMP Management.') igmpIntInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1)) igmpIntMember = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9)) igmpSnooping = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10)) igmpInterfaceTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1), ) if mibBuilder.loadTexts: igmpInterfaceTable.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceTable.setDescription('The (conceptual) table listing IGMP capable IP interfaces.') igmpInterfaceEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpInterfaceEntry.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceEntry.setDescription('An entry (conceptual row) in the igmpInterfaceTable.') igmpInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInterface.setStatus('current') if mibBuilder.loadTexts: igmpInterface.setDescription('The index value of the interface for which IGMP is enabled. This table is indexed by this value.') igmpInterfaceName = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInterfaceName.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceName.setDescription('The name of the interface for which IGMP or MLD is enabled.') igmpQueryTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpQueryTimeout.setStatus('current') if mibBuilder.loadTexts: igmpQueryTimeout.setDescription('It represents the maximum expected time interval, in seconds, between successive IGMP general query messages arriving on the interface. A vlaue of zero means there is no limits.') igmpProxy = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("off", 0), ("upstream", 1), ("downstream", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpProxy.setStatus('current') if mibBuilder.loadTexts: igmpProxy.setDescription('The object represents states of igmp proxy. When it has a value of 0 then it means the inteface proxy is currently disabled. When it has a value of 1 then it means IGMP is performing upstream inteface proxying. When it has a value of 2 then it means IGMP is performing downstream inteface proxying.') igmpIntStatsTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2), ) if mibBuilder.loadTexts: igmpIntStatsTable.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsTable.setDescription('The (conceptual) table listing statistics for IGMP capable IP interfaces.') igmpIntStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpIntStatsEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsEntry.setDescription('An entry (conceptual row) in the igmpIntStatsTable.') igmpInQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 1), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInQuery.setStatus('current') if mibBuilder.loadTexts: igmpInQuery.setDescription('The number of IGMP Query messages received by the interface.') igmpInReportV1 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInReportV1.setStatus('current') if mibBuilder.loadTexts: igmpInReportV1.setDescription('The number of IGMP version 1 Report messages received by the interface.') igmpInReportV2 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInReportV2.setStatus('current') if mibBuilder.loadTexts: igmpInReportV2.setDescription('The number of IGMP version 2 Report messages received by the interface.') igmpInLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 4), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInLeave.setStatus('current') if mibBuilder.loadTexts: igmpInLeave.setDescription('The number of IGMP Leave Group messages received by the interface.') igmpInTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 5), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInTotal.setStatus('current') if mibBuilder.loadTexts: igmpInTotal.setDescription('The total number of IGMP messages received by the interface.') igmpOutQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 6), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpOutQuery.setStatus('current') if mibBuilder.loadTexts: igmpOutQuery.setDescription('The total number of IGMP Query messages that were transmitted by the switch over the interface.') igmpOutTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 7), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpOutTotal.setStatus('current') if mibBuilder.loadTexts: igmpOutTotal.setDescription('The total number of IGMP messages that were transmitted by the switch over the interface.') igmpBadQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 8), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadQuery.setStatus('current') if mibBuilder.loadTexts: igmpBadQuery.setDescription('The number of IGMP membership query messages with errors that were received by the interface.') igmpBadReportV1 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 9), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadReportV1.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV1.setDescription('The number of IGMP Version 1 membership report messages with errors that were received by the interface.') igmpBadReportV2 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 10), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadReportV2.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV2.setDescription('The number of IGMP Version 2 membership report messages with errors that were received by the interface.') igmpBadLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 11), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadLeave.setStatus('current') if mibBuilder.loadTexts: igmpBadLeave.setDescription('The number of IGMP Leave Group messages with errors that were received by the interface.') igmpBadTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 12), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadTotal.setStatus('current') if mibBuilder.loadTexts: igmpBadTotal.setDescription('The total number of IGMP messages with errors that were received by the interface..') igmpIntGroupTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1), ) if mibBuilder.loadTexts: igmpIntGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupTable.setDescription('The (conceptual) table listing the IP multicast groups of which there are members on a particular interface.') igmpIntGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpIntGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupEntry.setDescription('An entry (conceptual row) in the igmpGroupTable.') igmpIntGroupAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpIntGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupAddress.setDescription('The IP multicast group address for which this entry contains information.') igmpLastHost = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpLastHost.setStatus('current') if mibBuilder.loadTexts: igmpLastHost.setDescription('The IP address of the last host reporting a membership. If it is static, then 0.0.0.0 presents.') igmpRefreshTime = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpRefreshTime.setStatus('current') if mibBuilder.loadTexts: igmpRefreshTime.setDescription('The time in seconds until the membership group is deleted if another membership report is not received. A value of 0xffffffff means infinity.') igmpSnoopAdminInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1)) igmpSnoopAdminEnabled = MibScalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1, 1), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setStatus('current') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setDescription('Indicates whether IGMP Snooping is globally enabled.') igmpSnoopVlanTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2), ) if mibBuilder.loadTexts: igmpSnoopVlanTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanTable.setDescription('The (conceptual) table listing the layer 2 interfaces performing IGMP snooping.') igmpSnoopVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID")) if mibBuilder.loadTexts: igmpSnoopVlanEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanEntry.setDescription('An entry (conceptual row) in the IGMP Snooping Vlan Table.') igmpSnoopVID = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopVID.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVID.setDescription('The 802.1 VLAN ID of the layer 2 interface performing IGMP snooping.') igmpSnoopVlanName = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopVlanName.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanName.setDescription('The name of the layer 2 interface performing IGMP snooping.') igmpSnoopFastLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("off", 0), ("single", 1), ("multi", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopFastLeave.setStatus('current') if mibBuilder.loadTexts: igmpSnoopFastLeave.setDescription('Indicates whether FastLeave is enabled, and operating in Single-Host or Multi-Host mode.') igmpSnoopQuerySolicit = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 4), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setStatus('current') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setDescription('Indicates whether query solicitation is on') igmpSnoopStaticRouterPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setStatus('current') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setDescription('Indicates the configured static multicast router ports.') igmpSnoopGroupTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3), ) if mibBuilder.loadTexts: igmpSnoopGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTable.setDescription('The (conceptual) table of IGMP Groups snooped on a layer 2 interface.') igmpSnoopGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress")) if mibBuilder.loadTexts: igmpSnoopGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupEntry.setDescription('A (conceptual) row in the IGMP Snooping Group table.') igmpSnoopGroupAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setDescription('The Multicast Group IP Address detected on a layer 2 interface.') igmpSnoopGroupTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopGroupTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setDescription('The time remaining before the multicast group is deleted from the layer 2 interface.') igmpSnoopPortTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4), ) if mibBuilder.loadTexts: igmpSnoopPortTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTable.setDescription('A (conceptual) table of ports in a layer 2 interface that are currently members of a multicast group.') igmpSnoopPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress"), (0, "AT-IGMP-MIB", "igmpSnoopPortNumber")) if mibBuilder.loadTexts: igmpSnoopPortEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortEntry.setDescription('A (conceptual) row in the IGMP Snooping Port Table.') igmpSnoopPortNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortNumber.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortNumber.setDescription('Provides the number of a port in a multicast group.') igmpSnoopPortIsStatic = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 2), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setDescription('Indicates whether a port has been administratively added to a multicast group.') igmpSnoopPortTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTimer.setDescription('Indicates the time remaining before the port is removed.') igmpSnoopHostTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5), ) if mibBuilder.loadTexts: igmpSnoopHostTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTable.setDescription('A (conceptual) table of hosts receiving multicast data.') igmpSnoopHostEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress"), (0, "AT-IGMP-MIB", "igmpSnoopPortNumber"), (0, "AT-IGMP-MIB", "igmpSnoopHostMAC")) if mibBuilder.loadTexts: igmpSnoopHostEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostEntry.setDescription('A (conceptual) row in the IGMP Snooping Host Table.') igmpSnoopHostMAC = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 1), MacAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostMAC.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostMAC.setDescription('Provides the Media Access Control Address of an IGMP Host.') igmpSnoopHostIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setDescription('Provides the Internet Protocol Address of an IGMP Host.') igmpSnoopHostTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTimer.setDescription('Indicates the time remaining before the host times out.') mibBuilder.exportSymbols("AT-IGMP-MIB", igmpInReportV1=igmpInReportV1, igmpSnoopQuerySolicit=igmpSnoopQuerySolicit, igmpBadQuery=igmpBadQuery, igmpOutQuery=igmpOutQuery, igmpInterfaceEntry=igmpInterfaceEntry, igmpIntStatsTable=igmpIntStatsTable, igmpProxy=igmpProxy, igmpIntGroupTable=igmpIntGroupTable, igmpSnoopAdminEnabled=igmpSnoopAdminEnabled, igmpSnoopFastLeave=igmpSnoopFastLeave, igmpIntMember=igmpIntMember, igmpRefreshTime=igmpRefreshTime, igmpSnoopPortTimer=igmpSnoopPortTimer, igmpIntInfo=igmpIntInfo, igmpSnoopGroupAddress=igmpSnoopGroupAddress, igmpSnoopVlanName=igmpSnoopVlanName, igmpIntGroupEntry=igmpIntGroupEntry, igmpSnoopAdminInfo=igmpSnoopAdminInfo, igmpInQuery=igmpInQuery, igmpBadTotal=igmpBadTotal, igmpBadReportV1=igmpBadReportV1, igmp=igmp, igmpSnoopGroupEntry=igmpSnoopGroupEntry, igmpBadReportV2=igmpBadReportV2, igmpInterface=igmpInterface, igmpIntGroupAddress=igmpIntGroupAddress, PYSNMP_MODULE_ID=igmp, igmpSnoopVlanTable=igmpSnoopVlanTable, igmpSnoopGroupTimer=igmpSnoopGroupTimer, igmpSnoopHostTable=igmpSnoopHostTable, igmpSnoopHostIpAddress=igmpSnoopHostIpAddress, igmpIntStatsEntry=igmpIntStatsEntry, igmpBadLeave=igmpBadLeave, igmpSnoopPortEntry=igmpSnoopPortEntry, igmpLastHost=igmpLastHost, igmpQueryTimeout=igmpQueryTimeout, igmpSnoopGroupTable=igmpSnoopGroupTable, igmpSnoopHostMAC=igmpSnoopHostMAC, igmpSnoopPortIsStatic=igmpSnoopPortIsStatic, igmpInTotal=igmpInTotal, igmpInterfaceName=igmpInterfaceName, igmpSnoopPortNumber=igmpSnoopPortNumber, igmpSnoopHostEntry=igmpSnoopHostEntry, igmpSnoopStaticRouterPorts=igmpSnoopStaticRouterPorts, igmpSnoopVID=igmpSnoopVID, igmpSnoopHostTimer=igmpSnoopHostTimer, igmpSnoopPortTable=igmpSnoopPortTable, igmpInReportV2=igmpInReportV2, igmpInLeave=igmpInLeave, igmpSnooping=igmpSnooping, igmpSnoopVlanEntry=igmpSnoopVlanEntry, igmpOutTotal=igmpOutTotal, igmpInterfaceTable=igmpInterfaceTable)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, value_range_constraint, constraints_union, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint') (modules,) = mibBuilder.importSymbols('AT-SMI-MIB', 'modules') (interface_index,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndex') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (time_ticks, mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, object_identity, counter32, iso, ip_address, module_identity, counter64, bits, unsigned32, notification_type, mib_identifier, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'ObjectIdentity', 'Counter32', 'iso', 'IpAddress', 'ModuleIdentity', 'Counter64', 'Bits', 'Unsigned32', 'NotificationType', 'MibIdentifier', 'Integer32') (display_string, truth_value, mac_address, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TruthValue', 'MacAddress', 'TextualConvention') igmp = module_identity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139)) igmp.setRevisions(('2007-08-08 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: igmp.setRevisionsDescriptions(('Initial version, to support IGMP membership status polling.',)) if mibBuilder.loadTexts: igmp.setLastUpdated('200708080000Z') if mibBuilder.loadTexts: igmp.setOrganization('Allied Telesis, Inc.') if mibBuilder.loadTexts: igmp.setContactInfo(' Stan Xiang,Hamish Kellahan Allied Telesis EMail: support@alliedtelesis.co.nz') if mibBuilder.loadTexts: igmp.setDescription('The MIB module for IGMP Management.') igmp_int_info = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1)) igmp_int_member = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9)) igmp_snooping = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10)) igmp_interface_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1)) if mibBuilder.loadTexts: igmpInterfaceTable.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceTable.setDescription('The (conceptual) table listing IGMP capable IP interfaces.') igmp_interface_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpInterfaceEntry.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceEntry.setDescription('An entry (conceptual row) in the igmpInterfaceTable.') igmp_interface = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInterface.setStatus('current') if mibBuilder.loadTexts: igmpInterface.setDescription('The index value of the interface for which IGMP is enabled. This table is indexed by this value.') igmp_interface_name = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInterfaceName.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceName.setDescription('The name of the interface for which IGMP or MLD is enabled.') igmp_query_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpQueryTimeout.setStatus('current') if mibBuilder.loadTexts: igmpQueryTimeout.setDescription('It represents the maximum expected time interval, in seconds, between successive IGMP general query messages arriving on the interface. A vlaue of zero means there is no limits.') igmp_proxy = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('off', 0), ('upstream', 1), ('downstream', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpProxy.setStatus('current') if mibBuilder.loadTexts: igmpProxy.setDescription('The object represents states of igmp proxy. When it has a value of 0 then it means the inteface proxy is currently disabled. When it has a value of 1 then it means IGMP is performing upstream inteface proxying. When it has a value of 2 then it means IGMP is performing downstream inteface proxying.') igmp_int_stats_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2)) if mibBuilder.loadTexts: igmpIntStatsTable.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsTable.setDescription('The (conceptual) table listing statistics for IGMP capable IP interfaces.') igmp_int_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpIntStatsEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsEntry.setDescription('An entry (conceptual row) in the igmpIntStatsTable.') igmp_in_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 1), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInQuery.setStatus('current') if mibBuilder.loadTexts: igmpInQuery.setDescription('The number of IGMP Query messages received by the interface.') igmp_in_report_v1 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInReportV1.setStatus('current') if mibBuilder.loadTexts: igmpInReportV1.setDescription('The number of IGMP version 1 Report messages received by the interface.') igmp_in_report_v2 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInReportV2.setStatus('current') if mibBuilder.loadTexts: igmpInReportV2.setDescription('The number of IGMP version 2 Report messages received by the interface.') igmp_in_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 4), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInLeave.setStatus('current') if mibBuilder.loadTexts: igmpInLeave.setDescription('The number of IGMP Leave Group messages received by the interface.') igmp_in_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 5), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInTotal.setStatus('current') if mibBuilder.loadTexts: igmpInTotal.setDescription('The total number of IGMP messages received by the interface.') igmp_out_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 6), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpOutQuery.setStatus('current') if mibBuilder.loadTexts: igmpOutQuery.setDescription('The total number of IGMP Query messages that were transmitted by the switch over the interface.') igmp_out_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 7), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpOutTotal.setStatus('current') if mibBuilder.loadTexts: igmpOutTotal.setDescription('The total number of IGMP messages that were transmitted by the switch over the interface.') igmp_bad_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 8), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadQuery.setStatus('current') if mibBuilder.loadTexts: igmpBadQuery.setDescription('The number of IGMP membership query messages with errors that were received by the interface.') igmp_bad_report_v1 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 9), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadReportV1.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV1.setDescription('The number of IGMP Version 1 membership report messages with errors that were received by the interface.') igmp_bad_report_v2 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 10), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadReportV2.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV2.setDescription('The number of IGMP Version 2 membership report messages with errors that were received by the interface.') igmp_bad_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 11), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadLeave.setStatus('current') if mibBuilder.loadTexts: igmpBadLeave.setDescription('The number of IGMP Leave Group messages with errors that were received by the interface.') igmp_bad_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 12), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadTotal.setStatus('current') if mibBuilder.loadTexts: igmpBadTotal.setDescription('The total number of IGMP messages with errors that were received by the interface..') igmp_int_group_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1)) if mibBuilder.loadTexts: igmpIntGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupTable.setDescription('The (conceptual) table listing the IP multicast groups of which there are members on a particular interface.') igmp_int_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpIntGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupEntry.setDescription('An entry (conceptual row) in the igmpGroupTable.') igmp_int_group_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpIntGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupAddress.setDescription('The IP multicast group address for which this entry contains information.') igmp_last_host = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 2), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpLastHost.setStatus('current') if mibBuilder.loadTexts: igmpLastHost.setDescription('The IP address of the last host reporting a membership. If it is static, then 0.0.0.0 presents.') igmp_refresh_time = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpRefreshTime.setStatus('current') if mibBuilder.loadTexts: igmpRefreshTime.setDescription('The time in seconds until the membership group is deleted if another membership report is not received. A value of 0xffffffff means infinity.') igmp_snoop_admin_info = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1)) igmp_snoop_admin_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1, 1), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setStatus('current') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setDescription('Indicates whether IGMP Snooping is globally enabled.') igmp_snoop_vlan_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2)) if mibBuilder.loadTexts: igmpSnoopVlanTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanTable.setDescription('The (conceptual) table listing the layer 2 interfaces performing IGMP snooping.') igmp_snoop_vlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID')) if mibBuilder.loadTexts: igmpSnoopVlanEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanEntry.setDescription('An entry (conceptual row) in the IGMP Snooping Vlan Table.') igmp_snoop_vid = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopVID.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVID.setDescription('The 802.1 VLAN ID of the layer 2 interface performing IGMP snooping.') igmp_snoop_vlan_name = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopVlanName.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanName.setDescription('The name of the layer 2 interface performing IGMP snooping.') igmp_snoop_fast_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('off', 0), ('single', 1), ('multi', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopFastLeave.setStatus('current') if mibBuilder.loadTexts: igmpSnoopFastLeave.setDescription('Indicates whether FastLeave is enabled, and operating in Single-Host or Multi-Host mode.') igmp_snoop_query_solicit = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 4), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setStatus('current') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setDescription('Indicates whether query solicitation is on') igmp_snoop_static_router_ports = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 5), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setStatus('current') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setDescription('Indicates the configured static multicast router ports.') igmp_snoop_group_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3)) if mibBuilder.loadTexts: igmpSnoopGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTable.setDescription('The (conceptual) table of IGMP Groups snooped on a layer 2 interface.') igmp_snoop_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress')) if mibBuilder.loadTexts: igmpSnoopGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupEntry.setDescription('A (conceptual) row in the IGMP Snooping Group table.') igmp_snoop_group_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setDescription('The Multicast Group IP Address detected on a layer 2 interface.') igmp_snoop_group_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setDescription('The time remaining before the multicast group is deleted from the layer 2 interface.') igmp_snoop_port_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4)) if mibBuilder.loadTexts: igmpSnoopPortTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTable.setDescription('A (conceptual) table of ports in a layer 2 interface that are currently members of a multicast group.') igmp_snoop_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress'), (0, 'AT-IGMP-MIB', 'igmpSnoopPortNumber')) if mibBuilder.loadTexts: igmpSnoopPortEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortEntry.setDescription('A (conceptual) row in the IGMP Snooping Port Table.') igmp_snoop_port_number = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortNumber.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortNumber.setDescription('Provides the number of a port in a multicast group.') igmp_snoop_port_is_static = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 2), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setDescription('Indicates whether a port has been administratively added to a multicast group.') igmp_snoop_port_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTimer.setDescription('Indicates the time remaining before the port is removed.') igmp_snoop_host_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5)) if mibBuilder.loadTexts: igmpSnoopHostTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTable.setDescription('A (conceptual) table of hosts receiving multicast data.') igmp_snoop_host_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress'), (0, 'AT-IGMP-MIB', 'igmpSnoopPortNumber'), (0, 'AT-IGMP-MIB', 'igmpSnoopHostMAC')) if mibBuilder.loadTexts: igmpSnoopHostEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostEntry.setDescription('A (conceptual) row in the IGMP Snooping Host Table.') igmp_snoop_host_mac = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 1), mac_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostMAC.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostMAC.setDescription('Provides the Media Access Control Address of an IGMP Host.') igmp_snoop_host_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 2), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setDescription('Provides the Internet Protocol Address of an IGMP Host.') igmp_snoop_host_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTimer.setDescription('Indicates the time remaining before the host times out.') mibBuilder.exportSymbols('AT-IGMP-MIB', igmpInReportV1=igmpInReportV1, igmpSnoopQuerySolicit=igmpSnoopQuerySolicit, igmpBadQuery=igmpBadQuery, igmpOutQuery=igmpOutQuery, igmpInterfaceEntry=igmpInterfaceEntry, igmpIntStatsTable=igmpIntStatsTable, igmpProxy=igmpProxy, igmpIntGroupTable=igmpIntGroupTable, igmpSnoopAdminEnabled=igmpSnoopAdminEnabled, igmpSnoopFastLeave=igmpSnoopFastLeave, igmpIntMember=igmpIntMember, igmpRefreshTime=igmpRefreshTime, igmpSnoopPortTimer=igmpSnoopPortTimer, igmpIntInfo=igmpIntInfo, igmpSnoopGroupAddress=igmpSnoopGroupAddress, igmpSnoopVlanName=igmpSnoopVlanName, igmpIntGroupEntry=igmpIntGroupEntry, igmpSnoopAdminInfo=igmpSnoopAdminInfo, igmpInQuery=igmpInQuery, igmpBadTotal=igmpBadTotal, igmpBadReportV1=igmpBadReportV1, igmp=igmp, igmpSnoopGroupEntry=igmpSnoopGroupEntry, igmpBadReportV2=igmpBadReportV2, igmpInterface=igmpInterface, igmpIntGroupAddress=igmpIntGroupAddress, PYSNMP_MODULE_ID=igmp, igmpSnoopVlanTable=igmpSnoopVlanTable, igmpSnoopGroupTimer=igmpSnoopGroupTimer, igmpSnoopHostTable=igmpSnoopHostTable, igmpSnoopHostIpAddress=igmpSnoopHostIpAddress, igmpIntStatsEntry=igmpIntStatsEntry, igmpBadLeave=igmpBadLeave, igmpSnoopPortEntry=igmpSnoopPortEntry, igmpLastHost=igmpLastHost, igmpQueryTimeout=igmpQueryTimeout, igmpSnoopGroupTable=igmpSnoopGroupTable, igmpSnoopHostMAC=igmpSnoopHostMAC, igmpSnoopPortIsStatic=igmpSnoopPortIsStatic, igmpInTotal=igmpInTotal, igmpInterfaceName=igmpInterfaceName, igmpSnoopPortNumber=igmpSnoopPortNumber, igmpSnoopHostEntry=igmpSnoopHostEntry, igmpSnoopStaticRouterPorts=igmpSnoopStaticRouterPorts, igmpSnoopVID=igmpSnoopVID, igmpSnoopHostTimer=igmpSnoopHostTimer, igmpSnoopPortTable=igmpSnoopPortTable, igmpInReportV2=igmpInReportV2, igmpInLeave=igmpInLeave, igmpSnooping=igmpSnooping, igmpSnoopVlanEntry=igmpSnoopVlanEntry, igmpOutTotal=igmpOutTotal, igmpInterfaceTable=igmpInterfaceTable)
#!/usr/bin/env python # # Copyright (c) 2018 10X Genomics, Inc. All rights reserved. # MULTI_REFS_PREFIX = 'multi' # Constants for metasamples GENE_EXPRESSION_LIBRARY_TYPE = 'Gene Expression' VDJ_LIBRARY_TYPE = 'VDJ' ATACSEQ_LIBRARY_TYPE = 'Peaks' ATACSEQ_LIBRARY_DERIVED_TYPE = 'Motifs' DEFAULT_LIBRARY_TYPE = GENE_EXPRESSION_LIBRARY_TYPE
multi_refs_prefix = 'multi' gene_expression_library_type = 'Gene Expression' vdj_library_type = 'VDJ' atacseq_library_type = 'Peaks' atacseq_library_derived_type = 'Motifs' default_library_type = GENE_EXPRESSION_LIBRARY_TYPE
def noOfwords(strs): l = strs.split(' ') return len(l) string = input() count = noOfwords(string) print(count)
def no_ofwords(strs): l = strs.split(' ') return len(l) string = input() count = no_ofwords(string) print(count)
def modular_exp(b, e, mod): if e == 0: return 1 res = modular_exp(b, e//2, mod) res = (res * res ) % mod if e%2 == 1: res = (res * b) % mod return res
def modular_exp(b, e, mod): if e == 0: return 1 res = modular_exp(b, e // 2, mod) res = res * res % mod if e % 2 == 1: res = res * b % mod return res
#!C:\Python27\python.exe # EASY-INSTALL-SCRIPT: 'docutils==0.12','rst2odt_prepstyles.py' __requires__ = 'docutils==0.12' __import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py')
__requires__ = 'docutils==0.12' __import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py')
#!/usr/bin/env python3 def raw_limit_ranges(callback_values): data = { '__meta': { 'chart': 'cisco-sso/raw', 'version': '0.1.0' }, 'resources': [{ 'apiVersion': 'v1', 'kind': 'LimitRange', 'metadata': { 'name': 'limits' }, 'spec': { 'limits': [{ 'default': { 'cpu': '100m', 'memory': '256Mi' }, 'defaultRequest': { 'cpu': '100m', 'memory': '256Mi' }, 'type': 'Container' }] } }] } callback_values.update(data) return callback_values
def raw_limit_ranges(callback_values): data = {'__meta': {'chart': 'cisco-sso/raw', 'version': '0.1.0'}, 'resources': [{'apiVersion': 'v1', 'kind': 'LimitRange', 'metadata': {'name': 'limits'}, 'spec': {'limits': [{'default': {'cpu': '100m', 'memory': '256Mi'}, 'defaultRequest': {'cpu': '100m', 'memory': '256Mi'}, 'type': 'Container'}]}}]} callback_values.update(data) return callback_values
#definir variables y otros print("Ejemplo 01-Area de un triangulo") #Datos de entrada - Ingresados mediante dispositivos de entrada b=int(input("Ingrese Base:")) h=int(input("Ingrese altura")) #proceso de calculo de Area area=(b*h)/2 #Datos de salida print("El area del triangulo es:", area)
print('Ejemplo 01-Area de un triangulo') b = int(input('Ingrese Base:')) h = int(input('Ingrese altura')) area = b * h / 2 print('El area del triangulo es:', area)
def handle_request(response): if response.error: print("Error:", response.error) else: print('called') print(response.body)
def handle_request(response): if response.error: print('Error:', response.error) else: print('called') print(response.body)
# CPP Program of Prim's algorithm for MST inf = 65000 # To add an edge def addEdge(adj, u, v, wt): adj[u].append([v, wt]) adj[v].append([u, wt]) def primMST(adj, V): # Create a priority queue to store vertices that # are being preinMST. pq = [] src = 0 # Taking vertex 0 as source # Create a vector for keys and initialize all keys as infinite (INF) key = [inf for i in range(V)] # To store parent array which in turn store MST parent = [-1 for i in range(V)] # To keep track of vertices included in MST inMST = [False for i in range(V)] # Insert source itself in priority queue and initialize its key as 0. pq.append([0, src]) key[src] = 0 # Looping till priority queue becomes empty while len(pq) != 0: # The first vertex in pair is the minimum key # vertex, extract it from priority queue. # vertex label is stored in second of pair (it # has to be done this way to keep the vertices # sorted key (key must be first item # in pair) u = pq[0][1] del pq[0] # Different key values for same vertex may exist in the priority queue. # The one with the least key value is always processed first. # Therefore, ignore the rest. if inMST[u] == True: continue inMST[u] = True # Include vertex in MST # Traverse all adjacent of u for x in adj[u]: # Get vertex label and weight of current adjacent of u. v = x[0] weight = x[1] # If v is not in MST and weight of (u,v) is smaller # than current key of v if inMST[v] == False and key[v] > weight: # Updating key of v key[v] = weight pq.append([key[v], v]) pq.sort() parent[v] = u for i in range(1, V): print(parent[i], "-", i) # Driver code V = 9 adj = [[] for i in range(V)] addEdge(adj, 0, 1, 4) addEdge(adj, 0, 7, 8) addEdge(adj, 1, 2, 8) addEdge(adj, 1, 7, 11) addEdge(adj, 2, 3, 7) addEdge(adj, 2, 8, 2) addEdge(adj, 2, 5, 4) addEdge(adj, 3, 4, 9) addEdge(adj, 3, 5, 14) addEdge(adj, 4, 5, 10) addEdge(adj, 5, 6, 2) addEdge(adj, 6, 7, 1) addEdge(adj, 6, 8, 6) addEdge(adj, 7, 8, 7) print("Edges of MST are") primMST(adj, V) # Output: # Edges of MST are # 0 - 1 # 1 - 2 # 2 - 3 # 3 - 4 # 2 - 5 # 5 - 6 # 6 - 7 # 2 - 8
inf = 65000 def add_edge(adj, u, v, wt): adj[u].append([v, wt]) adj[v].append([u, wt]) def prim_mst(adj, V): pq = [] src = 0 key = [inf for i in range(V)] parent = [-1 for i in range(V)] in_mst = [False for i in range(V)] pq.append([0, src]) key[src] = 0 while len(pq) != 0: u = pq[0][1] del pq[0] if inMST[u] == True: continue inMST[u] = True for x in adj[u]: v = x[0] weight = x[1] if inMST[v] == False and key[v] > weight: key[v] = weight pq.append([key[v], v]) pq.sort() parent[v] = u for i in range(1, V): print(parent[i], '-', i) v = 9 adj = [[] for i in range(V)] add_edge(adj, 0, 1, 4) add_edge(adj, 0, 7, 8) add_edge(adj, 1, 2, 8) add_edge(adj, 1, 7, 11) add_edge(adj, 2, 3, 7) add_edge(adj, 2, 8, 2) add_edge(adj, 2, 5, 4) add_edge(adj, 3, 4, 9) add_edge(adj, 3, 5, 14) add_edge(adj, 4, 5, 10) add_edge(adj, 5, 6, 2) add_edge(adj, 6, 7, 1) add_edge(adj, 6, 8, 6) add_edge(adj, 7, 8, 7) print('Edges of MST are') prim_mst(adj, V)
n,m,k = map(int,input().split()) d = list(map(int,input().split())) m = list(map(int,input().split())) ans = [] check = 10**18 for i in range(len(d)): frog=d[i] c=0 for j in range(len(m)): if m[j]%frog==0: c+=1 if c<check: ans.clear() ans.append(i+1) check=c elif c==check: ans.append(i+1) c=check print(len(ans)) print(*ans)
(n, m, k) = map(int, input().split()) d = list(map(int, input().split())) m = list(map(int, input().split())) ans = [] check = 10 ** 18 for i in range(len(d)): frog = d[i] c = 0 for j in range(len(m)): if m[j] % frog == 0: c += 1 if c < check: ans.clear() ans.append(i + 1) check = c elif c == check: ans.append(i + 1) c = check print(len(ans)) print(*ans)
# Variables age = 20 # declaring int variable temperature = 89.8 # declaring float variable name = 'John' # declaring str variable, Note: we use single quotes to store the text. model = "SD902" # declaring str variable print(model) model = 8890 # now re-declaring model variable as int # In Python this is allowed, anywhere you can change the type of variable # just be re declaring with new value of any type. print(model) # Another way of declaring variables # also the variable names are case sensitive msg = str("Big Brother is in town") Msg = str("Case sensitive variable") print(f"msg = {msg}") print(f"Msg = {Msg}")
age = 20 temperature = 89.8 name = 'John' model = 'SD902' print(model) model = 8890 print(model) msg = str('Big Brother is in town') msg = str('Case sensitive variable') print(f'msg = {msg}') print(f'Msg = {Msg}')
# -*- coding: utf-8 -*- ''' Copyright (c) 2014 @author: Marat Khayrullin <xmm.dev@gmail.com> ''' API_VERSION_V0 = 0 API_VERSION = API_VERSION_V0 bp_name = 'api_v0' api_v0_prefix = '{prefix}/v{version}'.format( prefix='/api', # current_app.config['URL_PREFIX'], version=API_VERSION_V0 )
""" Copyright (c) 2014 @author: Marat Khayrullin <xmm.dev@gmail.com> """ api_version_v0 = 0 api_version = API_VERSION_V0 bp_name = 'api_v0' api_v0_prefix = '{prefix}/v{version}'.format(prefix='/api', version=API_VERSION_V0)
hex2bin = dict('{:x} {:04b}'.format(x,x).split() for x in range(16)) def float_dec2bin(n): neg = False if n < 0: n = -n neg = True hx = float(n).hex() p = hx.index('p') bn = ''.join(hex2bin.get(char, char) for char in hx[2:p]) return (('1' if neg else '0') + bn.strip('0') + hx[p:p+2] + bin(int(hx[p+2:]))[2:])
hex2bin = dict(('{:x} {:04b}'.format(x, x).split() for x in range(16))) def float_dec2bin(n): neg = False if n < 0: n = -n neg = True hx = float(n).hex() p = hx.index('p') bn = ''.join((hex2bin.get(char, char) for char in hx[2:p])) return ('1' if neg else '0') + bn.strip('0') + hx[p:p + 2] + bin(int(hx[p + 2:]))[2:]
# basicpackage/foo.py a = 10 class Foo(object): pass print("inside 'basicpackage/foo.py' with a variable in it")
a = 10 class Foo(object): pass print("inside 'basicpackage/foo.py' with a variable in it")
famous_people = [] with open("/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt",'r') as foo: for line in foo.readlines(): if '``' in line: famous_people.append(line) with open("famous_people.txt", "a") as f: for person in famous_people: f.write(person)
famous_people = [] with open('/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt', 'r') as foo: for line in foo.readlines(): if '``' in line: famous_people.append(line) with open('famous_people.txt', 'a') as f: for person in famous_people: f.write(person)
class no_deps(object): pass class one_dep(object): def __init__(self, dependency): self.dependency = dependency class two_deps(object): def __init__(self, first_dep, second_dep): self.first_dep = first_dep self.second_dep = second_dep
class No_Deps(object): pass class One_Dep(object): def __init__(self, dependency): self.dependency = dependency class Two_Deps(object): def __init__(self, first_dep, second_dep): self.first_dep = first_dep self.second_dep = second_dep
# # PySNMP MIB module HP-ICF-ARP-PROTECT (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-ARP-PROTECT # Produced by pysmi-0.3.4 at Mon Apr 29 19:20:43 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint") hpSwitch, = mibBuilder.importSymbols("HP-ICF-OID", "hpSwitch") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType") VlanIndex, = mibBuilder.importSymbols("Q-BRIDGE-MIB", "VlanIndex") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") NotificationType, Integer32, ModuleIdentity, MibIdentifier, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Counter64, Gauge32, IpAddress, Bits, Counter32, iso, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Integer32", "ModuleIdentity", "MibIdentifier", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Counter64", "Gauge32", "IpAddress", "Bits", "Counter32", "iso", "TimeTicks") DisplayString, TextualConvention, MacAddress, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "MacAddress", "TruthValue") hpicfArpProtect = ModuleIdentity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37)) hpicfArpProtect.setRevisions(('2007-08-29 00:00', '2006-05-03 00:27',)) if mibBuilder.loadTexts: hpicfArpProtect.setLastUpdated('200708290000Z') if mibBuilder.loadTexts: hpicfArpProtect.setOrganization('HP Networking') hpicfArpProtectNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0)) hpicfArpProtectErrantReply = NotificationType((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantCnt"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIp")) if mibBuilder.loadTexts: hpicfArpProtectErrantReply.setStatus('current') hpicfArpProtectObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1)) hpicfArpProtectConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1)) hpicfArpProtectGlobalCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1)) hpicfArpProtectEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 1), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectEnable.setStatus('current') hpicfArpProtectVlanEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(512, 512)).setFixedLength(512)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectVlanEnable.setStatus('current') hpicfArpProtectValidation = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 3), Bits().clone(namedValues=NamedValues(("srcMac", 0), ("dstMac", 1), ("ip", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectValidation.setStatus('current') hpicfArpProtectErrantNotifyEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectErrantNotifyEnable.setStatus('current') hpicfArpProtectPortTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2), ) if mibBuilder.loadTexts: hpicfArpProtectPortTable.setStatus('current') hpicfArpProtectPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: hpicfArpProtectPortEntry.setStatus('current') hpicfArpProtectPortTrust = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1, 1), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectPortTrust.setStatus('current') hpicfArpProtectStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2)) hpicfArpProtectVlanStatTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1), ) if mibBuilder.loadTexts: hpicfArpProtectVlanStatTable.setStatus('current') hpicfArpProtectVlanStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1), ).setIndexNames((0, "HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatIndex")) if mibBuilder.loadTexts: hpicfArpProtectVlanStatEntry.setStatus('current') hpicfArpProtectVlanStatIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 1), VlanIndex()) if mibBuilder.loadTexts: hpicfArpProtectVlanStatIndex.setStatus('current') hpicfArpProtectVlanStatForwards = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatForwards.setStatus('current') hpicfArpProtectVlanStatBadPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadPkts.setStatus('current') hpicfArpProtectVlanStatBadBindings = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadBindings.setStatus('current') hpicfArpProtectVlanStatBadSrcMacs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadSrcMacs.setStatus('current') hpicfArpProtectVlanStatBadDstMacs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadDstMacs.setStatus('current') hpicfArpProtectVlanStatBadIpAddrs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadIpAddrs.setStatus('current') hpicfArpProtectErrantCnt = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 3), Counter32()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantCnt.setStatus('current') hpicfArpProtectErrantSrcMac = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 4), MacAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcMac.setStatus('current') hpicfArpProtectErrantSrcIpType = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 5), InetAddressType()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIpType.setStatus('current') hpicfArpProtectErrantSrcIp = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 6), InetAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIp.setStatus('current') hpicfArpProtectErrantDestMac = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 7), MacAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestMac.setStatus('current') hpicfArpProtectErrantDestIpType = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 8), InetAddressType()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestIpType.setStatus('current') hpicfArpProtectErrantDestIp = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 9), InetAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestIp.setStatus('current') hpicfArpProtectConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2)) hpicfArpProtectGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1)) hpicfArpProtectBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectEnable"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanEnable"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectValidation"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectPortTrust"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatForwards"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadPkts"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadBindings"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadSrcMacs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadDstMacs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadIpAddrs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantCnt"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantNotifyEnable")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectBaseGroup = hpicfArpProtectBaseGroup.setStatus('current') hpicfArpProtectionNotifications = NotificationGroup((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 2)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantReply")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectionNotifications = hpicfArpProtectionNotifications.setStatus('current') hpicfArpProtectCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2)) hpicfArpProtectCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectBaseGroup"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectionNotifications")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectCompliance = hpicfArpProtectCompliance.setStatus('current') mibBuilder.exportSymbols("HP-ICF-ARP-PROTECT", hpicfArpProtectVlanStatBadDstMacs=hpicfArpProtectVlanStatBadDstMacs, hpicfArpProtectErrantSrcMac=hpicfArpProtectErrantSrcMac, hpicfArpProtectErrantDestIp=hpicfArpProtectErrantDestIp, hpicfArpProtectStatus=hpicfArpProtectStatus, hpicfArpProtectVlanStatBadSrcMacs=hpicfArpProtectVlanStatBadSrcMacs, hpicfArpProtectNotifications=hpicfArpProtectNotifications, hpicfArpProtectionNotifications=hpicfArpProtectionNotifications, hpicfArpProtectGroups=hpicfArpProtectGroups, hpicfArpProtectVlanStatIndex=hpicfArpProtectVlanStatIndex, hpicfArpProtectVlanStatBadBindings=hpicfArpProtectVlanStatBadBindings, hpicfArpProtectEnable=hpicfArpProtectEnable, PYSNMP_MODULE_ID=hpicfArpProtect, hpicfArpProtectValidation=hpicfArpProtectValidation, hpicfArpProtectVlanStatForwards=hpicfArpProtectVlanStatForwards, hpicfArpProtectErrantSrcIpType=hpicfArpProtectErrantSrcIpType, hpicfArpProtectErrantNotifyEnable=hpicfArpProtectErrantNotifyEnable, hpicfArpProtectCompliances=hpicfArpProtectCompliances, hpicfArpProtectBaseGroup=hpicfArpProtectBaseGroup, hpicfArpProtectErrantReply=hpicfArpProtectErrantReply, hpicfArpProtectConfig=hpicfArpProtectConfig, hpicfArpProtectVlanStatBadPkts=hpicfArpProtectVlanStatBadPkts, hpicfArpProtectErrantCnt=hpicfArpProtectErrantCnt, hpicfArpProtectGlobalCfg=hpicfArpProtectGlobalCfg, hpicfArpProtectVlanStatEntry=hpicfArpProtectVlanStatEntry, hpicfArpProtectObjects=hpicfArpProtectObjects, hpicfArpProtectErrantDestIpType=hpicfArpProtectErrantDestIpType, hpicfArpProtectErrantSrcIp=hpicfArpProtectErrantSrcIp, hpicfArpProtectVlanStatBadIpAddrs=hpicfArpProtectVlanStatBadIpAddrs, hpicfArpProtectCompliance=hpicfArpProtectCompliance, hpicfArpProtectConformance=hpicfArpProtectConformance, hpicfArpProtectPortTable=hpicfArpProtectPortTable, hpicfArpProtectVlanEnable=hpicfArpProtectVlanEnable, hpicfArpProtectPortTrust=hpicfArpProtectPortTrust, hpicfArpProtectVlanStatTable=hpicfArpProtectVlanStatTable, hpicfArpProtectErrantDestMac=hpicfArpProtectErrantDestMac, hpicfArpProtect=hpicfArpProtect, hpicfArpProtectPortEntry=hpicfArpProtectPortEntry)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint') (hp_switch,) = mibBuilder.importSymbols('HP-ICF-OID', 'hpSwitch') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddress', 'InetAddressType') (vlan_index,) = mibBuilder.importSymbols('Q-BRIDGE-MIB', 'VlanIndex') (object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance') (notification_type, integer32, module_identity, mib_identifier, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, counter64, gauge32, ip_address, bits, counter32, iso, time_ticks) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Integer32', 'ModuleIdentity', 'MibIdentifier', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'Counter64', 'Gauge32', 'IpAddress', 'Bits', 'Counter32', 'iso', 'TimeTicks') (display_string, textual_convention, mac_address, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention', 'MacAddress', 'TruthValue') hpicf_arp_protect = module_identity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37)) hpicfArpProtect.setRevisions(('2007-08-29 00:00', '2006-05-03 00:27')) if mibBuilder.loadTexts: hpicfArpProtect.setLastUpdated('200708290000Z') if mibBuilder.loadTexts: hpicfArpProtect.setOrganization('HP Networking') hpicf_arp_protect_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0)) hpicf_arp_protect_errant_reply = notification_type((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantCnt'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIp')) if mibBuilder.loadTexts: hpicfArpProtectErrantReply.setStatus('current') hpicf_arp_protect_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1)) hpicf_arp_protect_config = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1)) hpicf_arp_protect_global_cfg = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1)) hpicf_arp_protect_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 1), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectEnable.setStatus('current') hpicf_arp_protect_vlan_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 2), octet_string().subtype(subtypeSpec=value_size_constraint(512, 512)).setFixedLength(512)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectVlanEnable.setStatus('current') hpicf_arp_protect_validation = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 3), bits().clone(namedValues=named_values(('srcMac', 0), ('dstMac', 1), ('ip', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectValidation.setStatus('current') hpicf_arp_protect_errant_notify_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectErrantNotifyEnable.setStatus('current') hpicf_arp_protect_port_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2)) if mibBuilder.loadTexts: hpicfArpProtectPortTable.setStatus('current') hpicf_arp_protect_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: hpicfArpProtectPortEntry.setStatus('current') hpicf_arp_protect_port_trust = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1, 1), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectPortTrust.setStatus('current') hpicf_arp_protect_status = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2)) hpicf_arp_protect_vlan_stat_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1)) if mibBuilder.loadTexts: hpicfArpProtectVlanStatTable.setStatus('current') hpicf_arp_protect_vlan_stat_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1)).setIndexNames((0, 'HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatIndex')) if mibBuilder.loadTexts: hpicfArpProtectVlanStatEntry.setStatus('current') hpicf_arp_protect_vlan_stat_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 1), vlan_index()) if mibBuilder.loadTexts: hpicfArpProtectVlanStatIndex.setStatus('current') hpicf_arp_protect_vlan_stat_forwards = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 2), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatForwards.setStatus('current') hpicf_arp_protect_vlan_stat_bad_pkts = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 3), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadPkts.setStatus('current') hpicf_arp_protect_vlan_stat_bad_bindings = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadBindings.setStatus('current') hpicf_arp_protect_vlan_stat_bad_src_macs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadSrcMacs.setStatus('current') hpicf_arp_protect_vlan_stat_bad_dst_macs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadDstMacs.setStatus('current') hpicf_arp_protect_vlan_stat_bad_ip_addrs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 7), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadIpAddrs.setStatus('current') hpicf_arp_protect_errant_cnt = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 3), counter32()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantCnt.setStatus('current') hpicf_arp_protect_errant_src_mac = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 4), mac_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcMac.setStatus('current') hpicf_arp_protect_errant_src_ip_type = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 5), inet_address_type()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIpType.setStatus('current') hpicf_arp_protect_errant_src_ip = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 6), inet_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIp.setStatus('current') hpicf_arp_protect_errant_dest_mac = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 7), mac_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestMac.setStatus('current') hpicf_arp_protect_errant_dest_ip_type = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 8), inet_address_type()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestIpType.setStatus('current') hpicf_arp_protect_errant_dest_ip = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 9), inet_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestIp.setStatus('current') hpicf_arp_protect_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2)) hpicf_arp_protect_groups = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1)) hpicf_arp_protect_base_group = object_group((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectEnable'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanEnable'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectValidation'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectPortTrust'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatForwards'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadPkts'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadBindings'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadSrcMacs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadDstMacs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadIpAddrs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantCnt'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantNotifyEnable')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protect_base_group = hpicfArpProtectBaseGroup.setStatus('current') hpicf_arp_protection_notifications = notification_group((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 2)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantReply')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protection_notifications = hpicfArpProtectionNotifications.setStatus('current') hpicf_arp_protect_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2)) hpicf_arp_protect_compliance = module_compliance((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectBaseGroup'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectionNotifications')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protect_compliance = hpicfArpProtectCompliance.setStatus('current') mibBuilder.exportSymbols('HP-ICF-ARP-PROTECT', hpicfArpProtectVlanStatBadDstMacs=hpicfArpProtectVlanStatBadDstMacs, hpicfArpProtectErrantSrcMac=hpicfArpProtectErrantSrcMac, hpicfArpProtectErrantDestIp=hpicfArpProtectErrantDestIp, hpicfArpProtectStatus=hpicfArpProtectStatus, hpicfArpProtectVlanStatBadSrcMacs=hpicfArpProtectVlanStatBadSrcMacs, hpicfArpProtectNotifications=hpicfArpProtectNotifications, hpicfArpProtectionNotifications=hpicfArpProtectionNotifications, hpicfArpProtectGroups=hpicfArpProtectGroups, hpicfArpProtectVlanStatIndex=hpicfArpProtectVlanStatIndex, hpicfArpProtectVlanStatBadBindings=hpicfArpProtectVlanStatBadBindings, hpicfArpProtectEnable=hpicfArpProtectEnable, PYSNMP_MODULE_ID=hpicfArpProtect, hpicfArpProtectValidation=hpicfArpProtectValidation, hpicfArpProtectVlanStatForwards=hpicfArpProtectVlanStatForwards, hpicfArpProtectErrantSrcIpType=hpicfArpProtectErrantSrcIpType, hpicfArpProtectErrantNotifyEnable=hpicfArpProtectErrantNotifyEnable, hpicfArpProtectCompliances=hpicfArpProtectCompliances, hpicfArpProtectBaseGroup=hpicfArpProtectBaseGroup, hpicfArpProtectErrantReply=hpicfArpProtectErrantReply, hpicfArpProtectConfig=hpicfArpProtectConfig, hpicfArpProtectVlanStatBadPkts=hpicfArpProtectVlanStatBadPkts, hpicfArpProtectErrantCnt=hpicfArpProtectErrantCnt, hpicfArpProtectGlobalCfg=hpicfArpProtectGlobalCfg, hpicfArpProtectVlanStatEntry=hpicfArpProtectVlanStatEntry, hpicfArpProtectObjects=hpicfArpProtectObjects, hpicfArpProtectErrantDestIpType=hpicfArpProtectErrantDestIpType, hpicfArpProtectErrantSrcIp=hpicfArpProtectErrantSrcIp, hpicfArpProtectVlanStatBadIpAddrs=hpicfArpProtectVlanStatBadIpAddrs, hpicfArpProtectCompliance=hpicfArpProtectCompliance, hpicfArpProtectConformance=hpicfArpProtectConformance, hpicfArpProtectPortTable=hpicfArpProtectPortTable, hpicfArpProtectVlanEnable=hpicfArpProtectVlanEnable, hpicfArpProtectPortTrust=hpicfArpProtectPortTrust, hpicfArpProtectVlanStatTable=hpicfArpProtectVlanStatTable, hpicfArpProtectErrantDestMac=hpicfArpProtectErrantDestMac, hpicfArpProtect=hpicfArpProtect, hpicfArpProtectPortEntry=hpicfArpProtectPortEntry)
pkgname = "libuninameslist" pkgver = "20211114" pkgrel = 0 build_style = "gnu_configure" hostmakedepends = ["pkgconf", "automake", "libtool"] pkgdesc = "Library of Unicode names and annotation data" maintainer = "q66 <q66@chimera-linux.org>" license = "BSD-3-Clause" url = "https://github.com/fontforge/libuninameslist" source = f"{url}/archive/{pkgver}.tar.gz" sha256 = "c089c6164f2cef361c3419a07408be72d6b58d6ef224ec226724a9fa93c0d46e" def pre_configure(self): self.do("autoreconf", "-if") def post_install(self): self.install_license("LICENSE") @subpackage("libuninameslist-devel") def _devel(self): return self.default_devel()
pkgname = 'libuninameslist' pkgver = '20211114' pkgrel = 0 build_style = 'gnu_configure' hostmakedepends = ['pkgconf', 'automake', 'libtool'] pkgdesc = 'Library of Unicode names and annotation data' maintainer = 'q66 <q66@chimera-linux.org>' license = 'BSD-3-Clause' url = 'https://github.com/fontforge/libuninameslist' source = f'{url}/archive/{pkgver}.tar.gz' sha256 = 'c089c6164f2cef361c3419a07408be72d6b58d6ef224ec226724a9fa93c0d46e' def pre_configure(self): self.do('autoreconf', '-if') def post_install(self): self.install_license('LICENSE') @subpackage('libuninameslist-devel') def _devel(self): return self.default_devel()
POSTGRESQL = 'PostgreSQL' MYSQL = 'MySQL' DEV = 'Development' STAGE = 'Staging' TEST = 'Testing' PROD = 'Production'
postgresql = 'PostgreSQL' mysql = 'MySQL' dev = 'Development' stage = 'Staging' test = 'Testing' prod = 'Production'
# 10001st prime # The nth prime number def isPrime(n): for i in range(2, int(math.sqrt(n))+1): if n%i == 0: return False return True def nthPrime(n): num = 2 nums = [] while len(nums) < n: if isPrime(num) == True: nums.append(num) num += 1 return nums[-1]
def is_prime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def nth_prime(n): num = 2 nums = [] while len(nums) < n: if is_prime(num) == True: nums.append(num) num += 1 return nums[-1]
class IntervalNum: def __init__(self,a,b): if a > b: a,b = b,a self.a = a self.b = b def __str__(self): return f"[{self.a};{self.b}]" def __add__(self,other): return IntervalNum(self.a+other.a, self.b+other.b) def __sub__(self,other): return IntervalNum(self.a-other.b, self.b-other.a) def __mul__(self,other): sa, sb = self.a, self.b oa, ob = other.a, other.b a = min([sa*oa,sa*ob,sb*oa,sb*ob]) b = max([sa*oa,sa*ob,sb*oa,sb*ob]) return IntervalNum(a,b) if __name__ == '__main__': x = IntervalNum(-2,3) print(f"x = {x}") print(f"x+x = {x+x}") print(f"x-x = {x-x}") print(f"x*x = {x*x}")
class Intervalnum: def __init__(self, a, b): if a > b: (a, b) = (b, a) self.a = a self.b = b def __str__(self): return f'[{self.a};{self.b}]' def __add__(self, other): return interval_num(self.a + other.a, self.b + other.b) def __sub__(self, other): return interval_num(self.a - other.b, self.b - other.a) def __mul__(self, other): (sa, sb) = (self.a, self.b) (oa, ob) = (other.a, other.b) a = min([sa * oa, sa * ob, sb * oa, sb * ob]) b = max([sa * oa, sa * ob, sb * oa, sb * ob]) return interval_num(a, b) if __name__ == '__main__': x = interval_num(-2, 3) print(f'x = {x}') print(f'x+x = {x + x}') print(f'x-x = {x - x}') print(f'x*x = {x * x}')
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'cv.sqlite', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenance.middleware.MaintenanceMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'django.middleware.common.CommonMiddleware', ) ROOT_URLCONF = 'maintenance.tests.test_urls' SITE_ID = 1 INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.flatpages', 'maintenance', )
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'cv.sqlite', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': ''}} middleware_classes = ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenance.middleware.MaintenanceMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'django.middleware.common.CommonMiddleware') root_urlconf = 'maintenance.tests.test_urls' site_id = 1 installed_apps = ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.flatpages', 'maintenance')
vehicles = { 'dream': 'Honda 250T', 'er5': 'Kawasaki ER5', 'can-am': 'Bombardier Can-Am 250', 'virago': 'Yamaha XV250', 'tenere': 'Yamaha XT650', 'jimny': 'Suzuki Jimny 1.5', 'fiesta': 'Ford Fiesta Ghia 1.4', 'roadster': 'Triumph Street Triple' } vehicles["starfighter"] = "Lockhead F-104" vehicles ["learjet"] = "Bombardier Learjet 75" vehicles["toy"] = "Glider" # upgrade Virago vehicles["virago"] = "Yamaha XV535" del vehicles['starfighter'] result = vehicles.pop('f1', "You wish! Sell the Learjet and you might afford a racing car.") print(result) plane = vehicles.pop('learjet') print(plane) bike = vehicles.pop("tenere", "not present") print(bike) print() # for key in vehicles: # print(key, vehicles[key], sep=", ") for key, value in vehicles.items(): print(key, value, sep=", ")
vehicles = {'dream': 'Honda 250T', 'er5': 'Kawasaki ER5', 'can-am': 'Bombardier Can-Am 250', 'virago': 'Yamaha XV250', 'tenere': 'Yamaha XT650', 'jimny': 'Suzuki Jimny 1.5', 'fiesta': 'Ford Fiesta Ghia 1.4', 'roadster': 'Triumph Street Triple'} vehicles['starfighter'] = 'Lockhead F-104' vehicles['learjet'] = 'Bombardier Learjet 75' vehicles['toy'] = 'Glider' vehicles['virago'] = 'Yamaha XV535' del vehicles['starfighter'] result = vehicles.pop('f1', 'You wish! Sell the Learjet and you might afford a racing car.') print(result) plane = vehicles.pop('learjet') print(plane) bike = vehicles.pop('tenere', 'not present') print(bike) print() for (key, value) in vehicles.items(): print(key, value, sep=', ')