content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
## Copyright 2018 The Chromium Authors. All rights reserved. ## Use of this source code is governed by a BSD-style license that can be ## found in the LICENSE file. ProtocolCompatibilityInfo = provider() def _check_protocol_compatibility_impl(ctx): stamp = ctx.actions.declare_file("{}.stamp".format(ctx.attr.name)) ctx.actions.run( outputs = [stamp], inputs = [ctx.file.protocol], arguments = [ "--stamp", stamp.path, ctx.file.protocol.path, ], executable = ctx.executable._check_protocol_compatibility, ) return [ ProtocolCompatibilityInfo( stamp = stamp, ), ] check_protocol_compatibility = rule( implementation = _check_protocol_compatibility_impl, attrs = { "protocol": attr.label( mandatory = True, allow_single_file = [".json"], ), "_check_protocol_compatibility": attr.label( default = Label("//third_party/inspector_protocol:CheckProtocolCompatibility"), executable = True, cfg = "host", ), }, )
protocol_compatibility_info = provider() def _check_protocol_compatibility_impl(ctx): stamp = ctx.actions.declare_file('{}.stamp'.format(ctx.attr.name)) ctx.actions.run(outputs=[stamp], inputs=[ctx.file.protocol], arguments=['--stamp', stamp.path, ctx.file.protocol.path], executable=ctx.executable._check_protocol_compatibility) return [protocol_compatibility_info(stamp=stamp)] check_protocol_compatibility = rule(implementation=_check_protocol_compatibility_impl, attrs={'protocol': attr.label(mandatory=True, allow_single_file=['.json']), '_check_protocol_compatibility': attr.label(default=label('//third_party/inspector_protocol:CheckProtocolCompatibility'), executable=True, cfg='host')})
bot_token = "" users = [ ] website_links =[ "https://www.google.com", ]
bot_token = '' users = [] website_links = ['https://www.google.com']
# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Clock Tree Synthesis openROAD commands""" load("//place_and_route:open_road.bzl", "OpenRoadInfo", "format_openroad_do_not_use_list", "merge_open_road_info", "openroad_command") load("//synthesis:build_defs.bzl", "SynthesisInfo") load("//pdk:open_road_configuration.bzl", "get_open_road_configuration") def clock_tree_synthesis(ctx, open_road_info): """Performs clock tree synthesis. Returns: OpenRoadInfo: the openROAD info provider containing required input files and and commands run. Args: ctx: Bazel rule ctx open_road_info: OpenRoadInfo provider from a previous step. """ netlist_target = ctx.attr.synthesized_rtl liberty = netlist_target[SynthesisInfo].standard_cell_info.default_corner.liberty open_road_configuration = get_open_road_configuration(ctx.attr.synthesized_rtl[SynthesisInfo]) rc_script = open_road_configuration.rc_script_configuration inputs = [ liberty, ] if rc_script: inputs.append(rc_script) open_road_commands = [ "read_liberty {liberty_file}".format( liberty_file = liberty.path, ), "source {}".format(rc_script.path) if rc_script else "", "remove_buffers", "set_wire_rc -signal -layer \"{}\"".format(open_road_configuration.wire_rc_signal_metal_layer), "set_wire_rc -clock -layer \"{}\"".format(open_road_configuration.wire_rc_clock_metal_layer), format_openroad_do_not_use_list(open_road_configuration.do_not_use_cell_list), "configure_cts_characterization", "estimate_parasitics -placement", "repair_clock_inverters", "clock_tree_synthesis -root_buf \"{cts_buffer}\" -buf_list \"{cts_buffer}\" -sink_clustering_enable".format( cts_buffer = open_road_configuration.cts_buffer_cell, ), "repair_clock_nets", "estimate_parasitics -placement", "set_propagated_clock [all_clocks]", "repair_timing", "detailed_placement", "report_checks -path_delay min_max -format full_clock_expanded -fields {input_pin slew capacitance} -digits 3", "detailed_placement", "filler_placement \"{filler_cells}\"".format( filler_cells = " ".join(open_road_configuration.fill_cells), ), "check_placement", ] command_output = openroad_command( ctx, commands = open_road_commands, input_db = open_road_info.output_db, inputs = inputs, step_name = "clock_tree_synthesis", ) current_action_open_road_info = OpenRoadInfo( commands = open_road_commands, input_files = depset(inputs), output_db = command_output.db, logs = depset([command_output.log_file]), ) return merge_open_road_info(open_road_info, current_action_open_road_info)
"""Clock Tree Synthesis openROAD commands""" load('//place_and_route:open_road.bzl', 'OpenRoadInfo', 'format_openroad_do_not_use_list', 'merge_open_road_info', 'openroad_command') load('//synthesis:build_defs.bzl', 'SynthesisInfo') load('//pdk:open_road_configuration.bzl', 'get_open_road_configuration') def clock_tree_synthesis(ctx, open_road_info): """Performs clock tree synthesis. Returns: OpenRoadInfo: the openROAD info provider containing required input files and and commands run. Args: ctx: Bazel rule ctx open_road_info: OpenRoadInfo provider from a previous step. """ netlist_target = ctx.attr.synthesized_rtl liberty = netlist_target[SynthesisInfo].standard_cell_info.default_corner.liberty open_road_configuration = get_open_road_configuration(ctx.attr.synthesized_rtl[SynthesisInfo]) rc_script = open_road_configuration.rc_script_configuration inputs = [liberty] if rc_script: inputs.append(rc_script) open_road_commands = ['read_liberty {liberty_file}'.format(liberty_file=liberty.path), 'source {}'.format(rc_script.path) if rc_script else '', 'remove_buffers', 'set_wire_rc -signal -layer "{}"'.format(open_road_configuration.wire_rc_signal_metal_layer), 'set_wire_rc -clock -layer "{}"'.format(open_road_configuration.wire_rc_clock_metal_layer), format_openroad_do_not_use_list(open_road_configuration.do_not_use_cell_list), 'configure_cts_characterization', 'estimate_parasitics -placement', 'repair_clock_inverters', 'clock_tree_synthesis -root_buf "{cts_buffer}" -buf_list "{cts_buffer}" -sink_clustering_enable'.format(cts_buffer=open_road_configuration.cts_buffer_cell), 'repair_clock_nets', 'estimate_parasitics -placement', 'set_propagated_clock [all_clocks]', 'repair_timing', 'detailed_placement', 'report_checks -path_delay min_max -format full_clock_expanded -fields {input_pin slew capacitance} -digits 3', 'detailed_placement', 'filler_placement "{filler_cells}"'.format(filler_cells=' '.join(open_road_configuration.fill_cells)), 'check_placement'] command_output = openroad_command(ctx, commands=open_road_commands, input_db=open_road_info.output_db, inputs=inputs, step_name='clock_tree_synthesis') current_action_open_road_info = open_road_info(commands=open_road_commands, input_files=depset(inputs), output_db=command_output.db, logs=depset([command_output.log_file])) return merge_open_road_info(open_road_info, current_action_open_road_info)
test = { 'name': 'q3_b', 'points': 5, 'suites': [ { 'cases': [ { 'code': '>>> no_match in ' "list(['professor', 'engineer', " "'scientist', 'cat'])\n" 'True', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
test = {'name': 'q3_b', 'points': 5, 'suites': [{'cases': [{'code': ">>> no_match in list(['professor', 'engineer', 'scientist', 'cat'])\nTrue", 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
class CookieContainer(object): """ Provides a container for a collection of System.Net.CookieCollection objects. CookieContainer() CookieContainer(capacity: int) CookieContainer(capacity: int,perDomainCapacity: int,maxCookieSize: int) """ def ZZZ(self): """hardcoded/mock instance of the class""" return CookieContainer() instance=ZZZ() """hardcoded/returns an instance of the class""" def Add(self,*__args): """ Add(self: CookieContainer,cookie: Cookie) Adds a System.Net.Cookie to a System.Net.CookieContainer. This method uses the domain from the System.Net.Cookie to determine which domain collection to associate the System.Net.Cookie with. cookie: The System.Net.Cookie to be added to the System.Net.CookieContainer. Add(self: CookieContainer,cookies: CookieCollection) Adds the contents of a System.Net.CookieCollection to the System.Net.CookieContainer. cookies: The System.Net.CookieCollection to be added to the System.Net.CookieContainer. Add(self: CookieContainer,uri: Uri,cookie: Cookie) Adds a System.Net.Cookie to the System.Net.CookieContainer for a particular URI. uri: The URI of the System.Net.Cookie to be added to the System.Net.CookieContainer. cookie: The System.Net.Cookie to be added to the System.Net.CookieContainer. Add(self: CookieContainer,uri: Uri,cookies: CookieCollection) Adds the contents of a System.Net.CookieCollection to the System.Net.CookieContainer for a particular URI. uri: The URI of the System.Net.CookieCollection to be added to the System.Net.CookieContainer. cookies: The System.Net.CookieCollection to be added to the System.Net.CookieContainer. """ pass def GetCookieHeader(self,uri): """ GetCookieHeader(self: CookieContainer,uri: Uri) -> str Gets the HTTP cookie header that contains the HTTP cookies that represent the System.Net.Cookie instances that are associated with a specific URI. uri: The URI of the System.Net.Cookie instances desired. Returns: An HTTP cookie header,with strings representing System.Net.Cookie instances delimited by semicolons. """ pass def GetCookies(self,uri): """ GetCookies(self: CookieContainer,uri: Uri) -> CookieCollection Gets a System.Net.CookieCollection that contains the System.Net.Cookie instances that are associated with a specific URI. uri: The URI of the System.Net.Cookie instances desired. Returns: A System.Net.CookieCollection that contains the System.Net.Cookie instances that are associated with a specific URI. """ pass def SetCookies(self,uri,cookieHeader): """ SetCookies(self: CookieContainer,uri: Uri,cookieHeader: str) Adds System.Net.Cookie instances for one or more cookies from an HTTP cookie header to the System.Net.CookieContainer for a specific URI. uri: The URI of the System.Net.CookieCollection. cookieHeader: The contents of an HTTP set-cookie header as returned by a HTTP server,with System.Net.Cookie instances delimited by commas. """ pass def __add__(self,*args): """ x.__add__(y) <==> x+yx.__add__(y) <==> x+yx.__add__(y) <==> x+yx.__add__(y) <==> x+y """ pass @staticmethod def __new__(self,capacity=None,perDomainCapacity=None,maxCookieSize=None): """ __new__(cls: type) __new__(cls: type,capacity: int) __new__(cls: type,capacity: int,perDomainCapacity: int,maxCookieSize: int) """ pass Capacity=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets and sets the number of System.Net.Cookie instances that a System.Net.CookieContainer can hold. Get: Capacity(self: CookieContainer) -> int Set: Capacity(self: CookieContainer)=value """ Count=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the number of System.Net.Cookie instances that a System.Net.CookieContainer currently holds. Get: Count(self: CookieContainer) -> int """ MaxCookieSize=property(lambda self: object(),lambda self,v: None,lambda self: None) """Represents the maximum allowed length of a System.Net.Cookie. Get: MaxCookieSize(self: CookieContainer) -> int Set: MaxCookieSize(self: CookieContainer)=value """ PerDomainCapacity=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets and sets the number of System.Net.Cookie instances that a System.Net.CookieContainer can hold per domain. Get: PerDomainCapacity(self: CookieContainer) -> int Set: PerDomainCapacity(self: CookieContainer)=value """ DefaultCookieLengthLimit=4096 DefaultCookieLimit=300 DefaultPerDomainCookieLimit=20
class Cookiecontainer(object): """ Provides a container for a collection of System.Net.CookieCollection objects. CookieContainer() CookieContainer(capacity: int) CookieContainer(capacity: int,perDomainCapacity: int,maxCookieSize: int) """ def zzz(self): """hardcoded/mock instance of the class""" return cookie_container() instance = zzz() 'hardcoded/returns an instance of the class' def add(self, *__args): """ Add(self: CookieContainer,cookie: Cookie) Adds a System.Net.Cookie to a System.Net.CookieContainer. This method uses the domain from the System.Net.Cookie to determine which domain collection to associate the System.Net.Cookie with. cookie: The System.Net.Cookie to be added to the System.Net.CookieContainer. Add(self: CookieContainer,cookies: CookieCollection) Adds the contents of a System.Net.CookieCollection to the System.Net.CookieContainer. cookies: The System.Net.CookieCollection to be added to the System.Net.CookieContainer. Add(self: CookieContainer,uri: Uri,cookie: Cookie) Adds a System.Net.Cookie to the System.Net.CookieContainer for a particular URI. uri: The URI of the System.Net.Cookie to be added to the System.Net.CookieContainer. cookie: The System.Net.Cookie to be added to the System.Net.CookieContainer. Add(self: CookieContainer,uri: Uri,cookies: CookieCollection) Adds the contents of a System.Net.CookieCollection to the System.Net.CookieContainer for a particular URI. uri: The URI of the System.Net.CookieCollection to be added to the System.Net.CookieContainer. cookies: The System.Net.CookieCollection to be added to the System.Net.CookieContainer. """ pass def get_cookie_header(self, uri): """ GetCookieHeader(self: CookieContainer,uri: Uri) -> str Gets the HTTP cookie header that contains the HTTP cookies that represent the System.Net.Cookie instances that are associated with a specific URI. uri: The URI of the System.Net.Cookie instances desired. Returns: An HTTP cookie header,with strings representing System.Net.Cookie instances delimited by semicolons. """ pass def get_cookies(self, uri): """ GetCookies(self: CookieContainer,uri: Uri) -> CookieCollection Gets a System.Net.CookieCollection that contains the System.Net.Cookie instances that are associated with a specific URI. uri: The URI of the System.Net.Cookie instances desired. Returns: A System.Net.CookieCollection that contains the System.Net.Cookie instances that are associated with a specific URI. """ pass def set_cookies(self, uri, cookieHeader): """ SetCookies(self: CookieContainer,uri: Uri,cookieHeader: str) Adds System.Net.Cookie instances for one or more cookies from an HTTP cookie header to the System.Net.CookieContainer for a specific URI. uri: The URI of the System.Net.CookieCollection. cookieHeader: The contents of an HTTP set-cookie header as returned by a HTTP server,with System.Net.Cookie instances delimited by commas. """ pass def __add__(self, *args): """ x.__add__(y) <==> x+yx.__add__(y) <==> x+yx.__add__(y) <==> x+yx.__add__(y) <==> x+y """ pass @staticmethod def __new__(self, capacity=None, perDomainCapacity=None, maxCookieSize=None): """ __new__(cls: type) __new__(cls: type,capacity: int) __new__(cls: type,capacity: int,perDomainCapacity: int,maxCookieSize: int) """ pass capacity = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets and sets the number of System.Net.Cookie instances that a System.Net.CookieContainer can hold.\n\n\n\nGet: Capacity(self: CookieContainer) -> int\n\n\n\nSet: Capacity(self: CookieContainer)=value\n\n' count = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the number of System.Net.Cookie instances that a System.Net.CookieContainer currently holds.\n\n\n\nGet: Count(self: CookieContainer) -> int\n\n\n\n' max_cookie_size = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Represents the maximum allowed length of a System.Net.Cookie.\n\n\n\nGet: MaxCookieSize(self: CookieContainer) -> int\n\n\n\nSet: MaxCookieSize(self: CookieContainer)=value\n\n' per_domain_capacity = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets and sets the number of System.Net.Cookie instances that a System.Net.CookieContainer can hold per domain.\n\n\n\nGet: PerDomainCapacity(self: CookieContainer) -> int\n\n\n\nSet: PerDomainCapacity(self: CookieContainer)=value\n\n' default_cookie_length_limit = 4096 default_cookie_limit = 300 default_per_domain_cookie_limit = 20
#I, Andy Le, student number 000805099, certify that all code submitted is my own work; # that i have not copied it from any other source. I also certify that I have not allowed my work to be copied by others. color = input("What is your favourite color? ") print("You said " + color) #This is a comment, Python will ignore it.
color = input('What is your favourite color? ') print('You said ' + color)
# variables 2 x = 5 y = "John" print(x) print(y) # variables in py dont need to be specified as a boolean int char string etc
x = 5 y = 'John' print(x) print(y)
def format_timestamp(timestamp): localtime = timestamp.timetuple() result = unicode(int(time.strftime(u'%I', localtime))) result += time.strftime(u':%M %p, %A %B ', localtime) result += unicode(int(time.strftime(u'%d', localtime))) result += time.strftime(u', %Y') return result
def format_timestamp(timestamp): localtime = timestamp.timetuple() result = unicode(int(time.strftime(u'%I', localtime))) result += time.strftime(u':%M %p, %A %B ', localtime) result += unicode(int(time.strftime(u'%d', localtime))) result += time.strftime(u', %Y') return result
#!/usr/bin/python3 def safe_print_list(my_list=[], x=0): idx = 0 while my_list and idx < x: try: print("{:d}".format(my_list[idx]), end="") idx += 1 except IndexError: break print() return idx
def safe_print_list(my_list=[], x=0): idx = 0 while my_list and idx < x: try: print('{:d}'.format(my_list[idx]), end='') idx += 1 except IndexError: break print() return idx
#9TH PROGRAM # THIS PROGRAM WILL HELP IN ACCESSING DICTIONARY ITEMS AND PERFROM CERTAIN OPERATIONS WITH DICTIONARY ages = {} #EMPTY DICTIONARY ages["Micky"] = 24 ages["Lucky"] = 25 print(ages) keys = ages.keys # .keys prints all the keys avaialble in Dictionary print(keys) values = ages.values # .values prints all the values avaialble in Dictionary print(values) print(sorted(ages)) # NOTE Unable to sort print(sorted(ages.values)) print(ages.values) # Prints the values # NOTE has_key() has been replaced by "in" in Python 3 , You can access like below. # Syntax : "Values" in "dict" if("Micky" in ages): print("Micky is there") else: print("Micky is not there") print(len(ages)) # Print the length of the dictionary #Adding new item # New initialization ages = {"Snehasis" : "24" , "Sradhasis" : 25} print(ages) # New members ages["LKP"] = 45 # Here value is saved as int if("LKP" in ages): updatedValue = ages.get("LKP") + 10 print("Updated Value = " , updatedValue) print(ages) ages["JYOTI"] = "38" # Here value is saved as string if("JYOTI" in ages): updatedValue = ages.get("JYOTI") + " New Age" print("Updated Value = " , updatedValue) print(ages)
ages = {} ages['Micky'] = 24 ages['Lucky'] = 25 print(ages) keys = ages.keys print(keys) values = ages.values print(values) print(sorted(ages)) print(ages.values) if 'Micky' in ages: print('Micky is there') else: print('Micky is not there') print(len(ages)) ages = {'Snehasis': '24', 'Sradhasis': 25} print(ages) ages['LKP'] = 45 if 'LKP' in ages: updated_value = ages.get('LKP') + 10 print('Updated Value = ', updatedValue) print(ages) ages['JYOTI'] = '38' if 'JYOTI' in ages: updated_value = ages.get('JYOTI') + ' New Age' print('Updated Value = ', updatedValue) print(ages)
# # PySNMP MIB module A3COM-HUAWEI-LswIGSP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-LswIGSP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:51:01 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) # lswCommon, = mibBuilder.importSymbols("A3COM-HUAWEI-OID-MIB", "lswCommon") ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") IpAddress, Unsigned32, ModuleIdentity, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, iso, TimeTicks, NotificationType, Counter32, Integer32, ObjectIdentity, Gauge32, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Unsigned32", "ModuleIdentity", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "iso", "TimeTicks", "NotificationType", "Counter32", "Integer32", "ObjectIdentity", "Gauge32", "Bits") RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString") hwLswIgmpsnoopingMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7)) hwLswIgmpsnoopingMib.setRevisions(('2001-06-29 00:00',)) if mibBuilder.loadTexts: hwLswIgmpsnoopingMib.setLastUpdated('200106290000Z') if mibBuilder.loadTexts: hwLswIgmpsnoopingMib.setOrganization('') class EnabledStatus(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("enabled", 1), ("disabled", 2)) hwLswIgmpsnoopingMibObject = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1)) hwIgmpSnoopingStatus = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 1), EnabledStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingStatus.setStatus('current') hwIgmpSnoopingRouterPortAge = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000)).clone(105)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingRouterPortAge.setStatus('current') hwIgmpSnoopingResponseTime = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 25)).clone(10)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingResponseTime.setStatus('current') hwIgmpSnoopingHostTime = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(200, 1000)).clone(260)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingHostTime.setStatus('current') hwIgmpSnoopingGroupLimitTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5), ) if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitTable.setStatus('current') hwIgmpSnoopingGroupLimitEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1), ).setIndexNames((0, "A3COM-HUAWEI-LswIGSP-MIB", "hwIgmpSnoopingGroupIfIndex")) if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitEntry.setStatus('current') hwIgmpSnoopingGroupIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: hwIgmpSnoopingGroupIfIndex.setStatus('current') hwIgmpSnoopingGroupLimitNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1, 2), Unsigned32().clone(4294967295)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitNumber.setStatus('current') hwIgmpSnoopingFastLeaveTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6), ) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveTable.setStatus('current') hwIgmpSnoopingFastLeaveEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1), ).setIndexNames((0, "A3COM-HUAWEI-LswIGSP-MIB", "hwIgmpSnoopingFastLeaveIfIndex")) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveEntry.setStatus('current') hwIgmpSnoopingFastLeaveIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveIfIndex.setStatus('current') hwIgmpSnoopingFastLeaveStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1, 2), EnabledStatus().clone(2)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveStatus.setStatus('current') hwIgmpSnoopingGroupPolicyTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7), ) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyTable.setStatus('current') hwIgmpSnoopingGroupPolicyEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1), ).setIndexNames((0, "A3COM-HUAWEI-LswIGSP-MIB", "hwIgmpSnoopingGroupPolicyIfIndex"), (0, "A3COM-HUAWEI-LswIGSP-MIB", "hwIgmpSnoopingGroupPolicyVlanID")) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyEntry.setStatus('current') hwIgmpSnoopingGroupPolicyIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyIfIndex.setStatus('current') hwIgmpSnoopingGroupPolicyVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094))) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyVlanID.setStatus('current') hwIgmpSnoopingGroupPolicyParameter = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(2000, 2999))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyParameter.setStatus('current') hwIgmpSnoopingGroupPolicyStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyStatus.setStatus('current') hwIgmpSnoopingNonFloodingStatus = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 8), EnabledStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingNonFloodingStatus.setStatus('current') hwIgmpSnoopingVlanStatusTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9), ) if mibBuilder.loadTexts: hwIgmpSnoopingVlanStatusTable.setStatus('current') hwIgmpSnoopingVlanStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1), ).setIndexNames((0, "A3COM-HUAWEI-LswIGSP-MIB", "hwIgmpSnoopingVlanID")) if mibBuilder.loadTexts: hwIgmpSnoopingVlanStatusEntry.setStatus('current') hwIgmpSnoopingVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094))) if mibBuilder.loadTexts: hwIgmpSnoopingVlanID.setStatus('current') hwIgmpSnoopingVlanEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1, 2), EnabledStatus().clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingVlanEnabled.setStatus('current') hwIgmpSnoopingStatsObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10)) hwRecvIGMPGQueryNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvIGMPGQueryNum.setStatus('current') hwRecvIGMPSQueryNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvIGMPSQueryNum.setStatus('current') hwRecvIGMPV1ReportNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvIGMPV1ReportNum.setStatus('current') hwRecvIGMPV2ReportNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvIGMPV2ReportNum.setStatus('current') hwRecvIGMPLeaveNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvIGMPLeaveNum.setStatus('current') hwRecvErrorIGMPPacketNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwRecvErrorIGMPPacketNum.setStatus('current') hwSentIGMPSQueryNum = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwSentIGMPSQueryNum.setStatus('current') hwIgmpSnoopingClearStats = MibScalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("clear", 1), ("counting", 2))).clone('counting')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hwIgmpSnoopingClearStats.setStatus('current') mibBuilder.exportSymbols("A3COM-HUAWEI-LswIGSP-MIB", hwIgmpSnoopingStatus=hwIgmpSnoopingStatus, hwIgmpSnoopingResponseTime=hwIgmpSnoopingResponseTime, hwIgmpSnoopingGroupPolicyParameter=hwIgmpSnoopingGroupPolicyParameter, hwIgmpSnoopingRouterPortAge=hwIgmpSnoopingRouterPortAge, hwIgmpSnoopingHostTime=hwIgmpSnoopingHostTime, hwRecvIGMPV2ReportNum=hwRecvIGMPV2ReportNum, hwIgmpSnoopingGroupPolicyEntry=hwIgmpSnoopingGroupPolicyEntry, hwIgmpSnoopingGroupPolicyVlanID=hwIgmpSnoopingGroupPolicyVlanID, hwIgmpSnoopingGroupLimitEntry=hwIgmpSnoopingGroupLimitEntry, hwSentIGMPSQueryNum=hwSentIGMPSQueryNum, hwIgmpSnoopingGroupPolicyStatus=hwIgmpSnoopingGroupPolicyStatus, hwLswIgmpsnoopingMibObject=hwLswIgmpsnoopingMibObject, hwRecvIGMPSQueryNum=hwRecvIGMPSQueryNum, hwIgmpSnoopingGroupIfIndex=hwIgmpSnoopingGroupIfIndex, hwLswIgmpsnoopingMib=hwLswIgmpsnoopingMib, hwIgmpSnoopingVlanEnabled=hwIgmpSnoopingVlanEnabled, hwIgmpSnoopingClearStats=hwIgmpSnoopingClearStats, hwIgmpSnoopingStatsObjects=hwIgmpSnoopingStatsObjects, hwRecvErrorIGMPPacketNum=hwRecvErrorIGMPPacketNum, PYSNMP_MODULE_ID=hwLswIgmpsnoopingMib, hwIgmpSnoopingFastLeaveIfIndex=hwIgmpSnoopingFastLeaveIfIndex, hwRecvIGMPLeaveNum=hwRecvIGMPLeaveNum, hwIgmpSnoopingGroupLimitNumber=hwIgmpSnoopingGroupLimitNumber, hwIgmpSnoopingNonFloodingStatus=hwIgmpSnoopingNonFloodingStatus, hwIgmpSnoopingGroupLimitTable=hwIgmpSnoopingGroupLimitTable, hwIgmpSnoopingFastLeaveTable=hwIgmpSnoopingFastLeaveTable, hwRecvIGMPGQueryNum=hwRecvIGMPGQueryNum, EnabledStatus=EnabledStatus, hwIgmpSnoopingVlanStatusEntry=hwIgmpSnoopingVlanStatusEntry, hwIgmpSnoopingGroupPolicyIfIndex=hwIgmpSnoopingGroupPolicyIfIndex, hwIgmpSnoopingFastLeaveStatus=hwIgmpSnoopingFastLeaveStatus, hwIgmpSnoopingVlanID=hwIgmpSnoopingVlanID, hwIgmpSnoopingGroupPolicyTable=hwIgmpSnoopingGroupPolicyTable, hwIgmpSnoopingVlanStatusTable=hwIgmpSnoopingVlanStatusTable, hwIgmpSnoopingFastLeaveEntry=hwIgmpSnoopingFastLeaveEntry, hwRecvIGMPV1ReportNum=hwRecvIGMPV1ReportNum)
(lsw_common,) = mibBuilder.importSymbols('A3COM-HUAWEI-OID-MIB', 'lswCommon') (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion') (interface_index,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndex') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (ip_address, unsigned32, module_identity, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, iso, time_ticks, notification_type, counter32, integer32, object_identity, gauge32, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Unsigned32', 'ModuleIdentity', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'iso', 'TimeTicks', 'NotificationType', 'Counter32', 'Integer32', 'ObjectIdentity', 'Gauge32', 'Bits') (row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString') hw_lsw_igmpsnooping_mib = module_identity((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7)) hwLswIgmpsnoopingMib.setRevisions(('2001-06-29 00:00',)) if mibBuilder.loadTexts: hwLswIgmpsnoopingMib.setLastUpdated('200106290000Z') if mibBuilder.loadTexts: hwLswIgmpsnoopingMib.setOrganization('') class Enabledstatus(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2)) named_values = named_values(('enabled', 1), ('disabled', 2)) hw_lsw_igmpsnooping_mib_object = mib_identifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1)) hw_igmp_snooping_status = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 1), enabled_status()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingStatus.setStatus('current') hw_igmp_snooping_router_port_age = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000)).clone(105)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingRouterPortAge.setStatus('current') hw_igmp_snooping_response_time = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(1, 25)).clone(10)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingResponseTime.setStatus('current') hw_igmp_snooping_host_time = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(200, 1000)).clone(260)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingHostTime.setStatus('current') hw_igmp_snooping_group_limit_table = mib_table((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5)) if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitTable.setStatus('current') hw_igmp_snooping_group_limit_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1)).setIndexNames((0, 'A3COM-HUAWEI-LswIGSP-MIB', 'hwIgmpSnoopingGroupIfIndex')) if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitEntry.setStatus('current') hw_igmp_snooping_group_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1, 1), interface_index()) if mibBuilder.loadTexts: hwIgmpSnoopingGroupIfIndex.setStatus('current') hw_igmp_snooping_group_limit_number = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 5, 1, 2), unsigned32().clone(4294967295)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingGroupLimitNumber.setStatus('current') hw_igmp_snooping_fast_leave_table = mib_table((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6)) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveTable.setStatus('current') hw_igmp_snooping_fast_leave_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1)).setIndexNames((0, 'A3COM-HUAWEI-LswIGSP-MIB', 'hwIgmpSnoopingFastLeaveIfIndex')) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveEntry.setStatus('current') hw_igmp_snooping_fast_leave_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1, 1), interface_index()) if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveIfIndex.setStatus('current') hw_igmp_snooping_fast_leave_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 6, 1, 2), enabled_status().clone(2)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingFastLeaveStatus.setStatus('current') hw_igmp_snooping_group_policy_table = mib_table((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7)) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyTable.setStatus('current') hw_igmp_snooping_group_policy_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1)).setIndexNames((0, 'A3COM-HUAWEI-LswIGSP-MIB', 'hwIgmpSnoopingGroupPolicyIfIndex'), (0, 'A3COM-HUAWEI-LswIGSP-MIB', 'hwIgmpSnoopingGroupPolicyVlanID')) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyEntry.setStatus('current') hw_igmp_snooping_group_policy_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 1), interface_index()) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyIfIndex.setStatus('current') hw_igmp_snooping_group_policy_vlan_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 4094))) if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyVlanID.setStatus('current') hw_igmp_snooping_group_policy_parameter = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(2000, 2999))).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyParameter.setStatus('current') hw_igmp_snooping_group_policy_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 7, 1, 4), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwIgmpSnoopingGroupPolicyStatus.setStatus('current') hw_igmp_snooping_non_flooding_status = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 8), enabled_status()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingNonFloodingStatus.setStatus('current') hw_igmp_snooping_vlan_status_table = mib_table((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9)) if mibBuilder.loadTexts: hwIgmpSnoopingVlanStatusTable.setStatus('current') hw_igmp_snooping_vlan_status_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1)).setIndexNames((0, 'A3COM-HUAWEI-LswIGSP-MIB', 'hwIgmpSnoopingVlanID')) if mibBuilder.loadTexts: hwIgmpSnoopingVlanStatusEntry.setStatus('current') hw_igmp_snooping_vlan_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 4094))) if mibBuilder.loadTexts: hwIgmpSnoopingVlanID.setStatus('current') hw_igmp_snooping_vlan_enabled = mib_table_column((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 9, 1, 2), enabled_status().clone('disabled')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingVlanEnabled.setStatus('current') hw_igmp_snooping_stats_objects = mib_identifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10)) hw_recv_igmpg_query_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 1), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvIGMPGQueryNum.setStatus('current') hw_recv_igmps_query_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 2), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvIGMPSQueryNum.setStatus('current') hw_recv_igmpv1_report_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 3), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvIGMPV1ReportNum.setStatus('current') hw_recv_igmpv2_report_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvIGMPV2ReportNum.setStatus('current') hw_recv_igmp_leave_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvIGMPLeaveNum.setStatus('current') hw_recv_error_igmp_packet_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwRecvErrorIGMPPacketNum.setStatus('current') hw_sent_igmps_query_num = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 7), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwSentIGMPSQueryNum.setStatus('current') hw_igmp_snooping_clear_stats = mib_scalar((1, 3, 6, 1, 4, 1, 43, 45, 1, 2, 23, 1, 7, 1, 10, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('clear', 1), ('counting', 2))).clone('counting')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hwIgmpSnoopingClearStats.setStatus('current') mibBuilder.exportSymbols('A3COM-HUAWEI-LswIGSP-MIB', hwIgmpSnoopingStatus=hwIgmpSnoopingStatus, hwIgmpSnoopingResponseTime=hwIgmpSnoopingResponseTime, hwIgmpSnoopingGroupPolicyParameter=hwIgmpSnoopingGroupPolicyParameter, hwIgmpSnoopingRouterPortAge=hwIgmpSnoopingRouterPortAge, hwIgmpSnoopingHostTime=hwIgmpSnoopingHostTime, hwRecvIGMPV2ReportNum=hwRecvIGMPV2ReportNum, hwIgmpSnoopingGroupPolicyEntry=hwIgmpSnoopingGroupPolicyEntry, hwIgmpSnoopingGroupPolicyVlanID=hwIgmpSnoopingGroupPolicyVlanID, hwIgmpSnoopingGroupLimitEntry=hwIgmpSnoopingGroupLimitEntry, hwSentIGMPSQueryNum=hwSentIGMPSQueryNum, hwIgmpSnoopingGroupPolicyStatus=hwIgmpSnoopingGroupPolicyStatus, hwLswIgmpsnoopingMibObject=hwLswIgmpsnoopingMibObject, hwRecvIGMPSQueryNum=hwRecvIGMPSQueryNum, hwIgmpSnoopingGroupIfIndex=hwIgmpSnoopingGroupIfIndex, hwLswIgmpsnoopingMib=hwLswIgmpsnoopingMib, hwIgmpSnoopingVlanEnabled=hwIgmpSnoopingVlanEnabled, hwIgmpSnoopingClearStats=hwIgmpSnoopingClearStats, hwIgmpSnoopingStatsObjects=hwIgmpSnoopingStatsObjects, hwRecvErrorIGMPPacketNum=hwRecvErrorIGMPPacketNum, PYSNMP_MODULE_ID=hwLswIgmpsnoopingMib, hwIgmpSnoopingFastLeaveIfIndex=hwIgmpSnoopingFastLeaveIfIndex, hwRecvIGMPLeaveNum=hwRecvIGMPLeaveNum, hwIgmpSnoopingGroupLimitNumber=hwIgmpSnoopingGroupLimitNumber, hwIgmpSnoopingNonFloodingStatus=hwIgmpSnoopingNonFloodingStatus, hwIgmpSnoopingGroupLimitTable=hwIgmpSnoopingGroupLimitTable, hwIgmpSnoopingFastLeaveTable=hwIgmpSnoopingFastLeaveTable, hwRecvIGMPGQueryNum=hwRecvIGMPGQueryNum, EnabledStatus=EnabledStatus, hwIgmpSnoopingVlanStatusEntry=hwIgmpSnoopingVlanStatusEntry, hwIgmpSnoopingGroupPolicyIfIndex=hwIgmpSnoopingGroupPolicyIfIndex, hwIgmpSnoopingFastLeaveStatus=hwIgmpSnoopingFastLeaveStatus, hwIgmpSnoopingVlanID=hwIgmpSnoopingVlanID, hwIgmpSnoopingGroupPolicyTable=hwIgmpSnoopingGroupPolicyTable, hwIgmpSnoopingVlanStatusTable=hwIgmpSnoopingVlanStatusTable, hwIgmpSnoopingFastLeaveEntry=hwIgmpSnoopingFastLeaveEntry, hwRecvIGMPV1ReportNum=hwRecvIGMPV1ReportNum)
#!/usr/bin/env python # encoding: utf-8 def build_log_urls(node, path): url = node.web_url_for( 'addon_view_or_download_file', path=path, provider='osfstorage' ) return { 'view': url, 'download': url + '?action=download' } class OsfStorageNodeLogger(object): def __init__(self, node, auth, path=None): self.node = node self.auth = auth self.path = path def log(self, action, extra=None, save=False): """Log an event. Wraps the Node#add_log method, automatically adding relevant parameters and prefixing log events with `"osf_storage_"`. :param str action: Log action. Should be a class constant from NodeLog. :param dict extra: Extra parameters to add to the ``params`` dict of the new NodeLog. """ params = { 'project': self.node.parent_id, 'node': self.node._primary_key, } # If logging a file-related action, add the file's view and download URLs if self.path: params.update({ 'urls': build_log_urls(self.node, self.path), 'path': self.path, }) if extra: params.update(extra) # Prefix the action with osf_storage_ self.node.add_log( action='osf_storage_{0}'.format(action), params=params, auth=self.auth, ) if save: self.node.save()
def build_log_urls(node, path): url = node.web_url_for('addon_view_or_download_file', path=path, provider='osfstorage') return {'view': url, 'download': url + '?action=download'} class Osfstoragenodelogger(object): def __init__(self, node, auth, path=None): self.node = node self.auth = auth self.path = path def log(self, action, extra=None, save=False): """Log an event. Wraps the Node#add_log method, automatically adding relevant parameters and prefixing log events with `"osf_storage_"`. :param str action: Log action. Should be a class constant from NodeLog. :param dict extra: Extra parameters to add to the ``params`` dict of the new NodeLog. """ params = {'project': self.node.parent_id, 'node': self.node._primary_key} if self.path: params.update({'urls': build_log_urls(self.node, self.path), 'path': self.path}) if extra: params.update(extra) self.node.add_log(action='osf_storage_{0}'.format(action), params=params, auth=self.auth) if save: self.node.save()
T = input() hh, mm = map(int, T.split(':')) mm += 5 if mm > 59: hh += 1 mm %= 60 if hh > 23: hh %= 24 print('%02d:%02d' % (hh, mm))
t = input() (hh, mm) = map(int, T.split(':')) mm += 5 if mm > 59: hh += 1 mm %= 60 if hh > 23: hh %= 24 print('%02d:%02d' % (hh, mm))
class NodeSocketInterfaceIntUnsigned: default_value = None max_value = None min_value = None
class Nodesocketinterfaceintunsigned: default_value = None max_value = None min_value = None
''' # TASK 5 - Write a function that takes a string and a shift integer and returns the string with each letter shifted - you can iterate over the letters in a string - for letter in str: ''' def get_shifted_string(string, shift): ''' return the input string with each letter shifted shift steps ''' raise NotImplementedError
""" # TASK 5 - Write a function that takes a string and a shift integer and returns the string with each letter shifted - you can iterate over the letters in a string - for letter in str: """ def get_shifted_string(string, shift): """ return the input string with each letter shifted shift steps """ raise NotImplementedError
mytuple = (9,8,7,5,4,1,2,3) num = len(mytuple) print("# of element:", num) min_value = min(mytuple) max_value = max(mytuple) print("Min value:", min_value) print("Max value:", max_value)
mytuple = (9, 8, 7, 5, 4, 1, 2, 3) num = len(mytuple) print('# of element:', num) min_value = min(mytuple) max_value = max(mytuple) print('Min value:', min_value) print('Max value:', max_value)
class CalcController: def __init__(self, model, view): self.model = model self.model.OnResult = self.OnResult self.model.OnError = self.OnError self.view = view self.model.AllClear() # interface for view def command(self, command): if command in ['0','1','2','3','4','5','6','7','8','9']: self.model.EnterDigit(command) elif command == 'DOT': self.model.EnterDot() elif command == 'SIGN': self.model.Sign() elif command == 'CLEAR': self.model.Clear() elif command == 'ALL_CLEAR': self.model.AllClear() elif command == 'ADDITION': self.model.Addition() elif command == 'SUBSTRACTION': self.model.Substraction() elif command == 'MULTIPLICATION': self.model.Multiplication() elif command == 'DIVISION': self.model.Division() elif command == 'SQRT': self.model.CalcSqrt() elif command == 'CALCULATE': self.model.CalcResult() def OnResult(self, result): self.view.ShowResult(result) def OnError(self): self.view.ShowResult('ERROR')
class Calccontroller: def __init__(self, model, view): self.model = model self.model.OnResult = self.OnResult self.model.OnError = self.OnError self.view = view self.model.AllClear() def command(self, command): if command in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: self.model.EnterDigit(command) elif command == 'DOT': self.model.EnterDot() elif command == 'SIGN': self.model.Sign() elif command == 'CLEAR': self.model.Clear() elif command == 'ALL_CLEAR': self.model.AllClear() elif command == 'ADDITION': self.model.Addition() elif command == 'SUBSTRACTION': self.model.Substraction() elif command == 'MULTIPLICATION': self.model.Multiplication() elif command == 'DIVISION': self.model.Division() elif command == 'SQRT': self.model.CalcSqrt() elif command == 'CALCULATE': self.model.CalcResult() def on_result(self, result): self.view.ShowResult(result) def on_error(self): self.view.ShowResult('ERROR')
# Delete all keys that start with 'foo'. for k in hiera.keys(): if k.startswith('foo'): hiera.pop(k)
for k in hiera.keys(): if k.startswith('foo'): hiera.pop(k)
# -*- coding: utf-8 -*- # # Copyright 2012 James Thornton (http://jamesthornton.com) # BSD License (see LICENSE for details) # """ Bulbs is a Python persistence framework for graph databases. Bulbs is a Python client library for Neo4j Server and Rexster, Rexster is a REST server that provides access to any Blueprints-enabled graph database, including Neo4j, OrientDB, DEX, TinkerGraph and OpenRDF. Home Page: http://bulbflow.com Copyright (c) 2012, James Thornton (http://jamesthornton.com) License: BSD (see LICENSE for details) """ __version__ = '0.3' __author__ = 'James Thornton' __license__ = 'BSD'
""" Bulbs is a Python persistence framework for graph databases. Bulbs is a Python client library for Neo4j Server and Rexster, Rexster is a REST server that provides access to any Blueprints-enabled graph database, including Neo4j, OrientDB, DEX, TinkerGraph and OpenRDF. Home Page: http://bulbflow.com Copyright (c) 2012, James Thornton (http://jamesthornton.com) License: BSD (see LICENSE for details) """ __version__ = '0.3' __author__ = 'James Thornton' __license__ = 'BSD'
length = float(input()) width = float(input()) height = float(input()) perc_full = float(input()) aquarium_volume = length*width*height total_liters = aquarium_volume*0.001 perc = perc_full*0.01 needed_liters = total_liters*(1-perc) print(needed_liters)
length = float(input()) width = float(input()) height = float(input()) perc_full = float(input()) aquarium_volume = length * width * height total_liters = aquarium_volume * 0.001 perc = perc_full * 0.01 needed_liters = total_liters * (1 - perc) print(needed_liters)
"""Part 2: Write a Python program to add two given lists using lambda. Hint : Map nums1 = [1, 4, 5, 6, 5] nums2 = [3, 5, 7, 2, 5] Expected Input Output Result: after adding two list [4, 9, 12, 8, 10] Update code in script_2/lambda_2.py""" nums1 = [1, 4, 5, 6, 5] nums2 = [3, 5, 7, 2, 5] result = map(lambda x, y: x + y, nums1, nums2) print(list(result))
"""Part 2: Write a Python program to add two given lists using lambda. Hint : Map nums1 = [1, 4, 5, 6, 5] nums2 = [3, 5, 7, 2, 5] Expected Input Output Result: after adding two list [4, 9, 12, 8, 10] Update code in script_2/lambda_2.py""" nums1 = [1, 4, 5, 6, 5] nums2 = [3, 5, 7, 2, 5] result = map(lambda x, y: x + y, nums1, nums2) print(list(result))
def maximum_subarray(nums): current_sum = max_sum = nums[0] for num in nums[1:]: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum if __name__ == '__main__': print(maximum_subarray([-2,1,-3,4,-1,2,1,-5,4]))
def maximum_subarray(nums): current_sum = max_sum = nums[0] for num in nums[1:]: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum if __name__ == '__main__': print(maximum_subarray([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
class MocNode: def __init__(self): self.name = '' self.parent = '' self.refmoc = [] def setName(self, name): self.name = name def setParent(self, parent): self.parent = parent def setRefmoc(self, refmoc): self.refmoc = refmoc
class Mocnode: def __init__(self): self.name = '' self.parent = '' self.refmoc = [] def set_name(self, name): self.name = name def set_parent(self, parent): self.parent = parent def set_refmoc(self, refmoc): self.refmoc = refmoc
print("| U0 | U1 | U2 | Element |") print("|--|--|--|--------|") stack = [] for a in (0, 1, 2): for b in (0, 1, 2): for c in (0, 1, 2): stack.append(str(a) if a != 0 else '') stack.append(((str(b) if b > 1 else '') + 'x') if b != 0 else '') stack.append(((str(c) if c > 1 else '') + 'x^2') if c != 0 else '') while stack and stack[-1] == '': stack.pop() element = stack.pop() if stack else '' while stack: element = stack[-1] + ' + ' + element if stack[-1] != '' else element stack.pop() print("|" + str(a) + "|" + str(b) + "|" + str(c) + "|" + (element if element != '' else '0') + "|") # Galios field multiplicative inverse # SPN w = int() def permute(w, P): new = 0 for i in range(len(P)): new |= ((w & (1 << (15 - i))) >> (15 - i)) << (16 - P[i]) return new permute()
print('| U0 | U1 | U2 | Element |') print('|--|--|--|--------|') stack = [] for a in (0, 1, 2): for b in (0, 1, 2): for c in (0, 1, 2): stack.append(str(a) if a != 0 else '') stack.append((str(b) if b > 1 else '') + 'x' if b != 0 else '') stack.append((str(c) if c > 1 else '') + 'x^2' if c != 0 else '') while stack and stack[-1] == '': stack.pop() element = stack.pop() if stack else '' while stack: element = stack[-1] + ' + ' + element if stack[-1] != '' else element stack.pop() print('|' + str(a) + '|' + str(b) + '|' + str(c) + '|' + (element if element != '' else '0') + '|') w = int() def permute(w, P): new = 0 for i in range(len(P)): new |= (w & 1 << 15 - i) >> 15 - i << 16 - P[i] return new permute()
print(" ADIN EGIAZTAKETA\n") adina=int(input("Sartu zure adina: ")) while adina<0: print(f"{adina} zenbaki negatibo bat da eta ezin dezu adin negatiborik eduki.") adina=int(input("Sartu zure adina: ")) while adina>130: print(f"{adina} adin haundiegi bat da, ez det sinisten adin hoi dezunik.") adina=int(input("Sartu zure adina: ")) if adina>=18: print("18 urte baino gehiago dituzu, beraz pasa zaitezke.") else: print("18 urte baino gutxiago dituzu, beraz ezin zea pasa.")
print(' ADIN EGIAZTAKETA\n') adina = int(input('Sartu zure adina: ')) while adina < 0: print(f'{adina} zenbaki negatibo bat da eta ezin dezu adin negatiborik eduki.') adina = int(input('Sartu zure adina: ')) while adina > 130: print(f'{adina} adin haundiegi bat da, ez det sinisten adin hoi dezunik.') adina = int(input('Sartu zure adina: ')) if adina >= 18: print('18 urte baino gehiago dituzu, beraz pasa zaitezke.') else: print('18 urte baino gutxiago dituzu, beraz ezin zea pasa.')
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"show_binmask": "00_core.ipynb", "BinaryMasksBlock": "00_core.ipynb", "TensorBinMasks": "00_core.ipynb", "TensorBinMasks2TensorMask": "00_core.ipynb", "CocoData": "01_datasets.ipynb", "ObjectDetectionDataLoaders": "02_dataloaders.ipynb", "ObjDetAdapter": "03_callbacks.ipynb", "get_fasterrcnn_model": "04a_models.fasterrcnn.ipynb", "get_fasterrcnn_model_swin": "04a_models.fasterrcnn.ipynb", "SwinTransformerFPN": "04a_models.fasterrcnn.ipynb", "fasterrcnn_resnet18": "04a_models.fasterrcnn.ipynb", "fasterrcnn_resnet34": "04a_models.fasterrcnn.ipynb", "fasterrcnn_resnet50": "04a_models.fasterrcnn.ipynb", "fasterrcnn_resnet101": "04a_models.fasterrcnn.ipynb", "fasterrcnn_resnet152": "04a_models.fasterrcnn.ipynb", "fasterrcnn_swinT": "04a_models.fasterrcnn.ipynb", "fasterrcnn_swinS": "04a_models.fasterrcnn.ipynb", "fasterrcnn_swinB": "04a_models.fasterrcnn.ipynb", "fasterrcnn_swinL": "04a_models.fasterrcnn.ipynb", "get_maskrcnn_model": "04b_models.maskrcnn.ipynb", "maskrcnn_resnet18": "04b_models.maskrcnn.ipynb", "maskrcnn_resnet34": "04b_models.maskrcnn.ipynb", "maskrcnn_resnet50": "04b_models.maskrcnn.ipynb", "maskrcnn_resnet101": "04b_models.maskrcnn.ipynb", "maskrcnn_resnet152": "04b_models.maskrcnn.ipynb", "EffDetModelWrapper": "04c_models.efficientdet.ipynb", "get_efficientdet_model": "04c_models.efficientdet.ipynb", "efficientdet_d0": "04c_models.efficientdet.ipynb", "efficientdet_d1": "04c_models.efficientdet.ipynb", "efficientdet_d2": "04c_models.efficientdet.ipynb", "efficientdet_d3": "04c_models.efficientdet.ipynb", "efficientdet_d4": "04c_models.efficientdet.ipynb", "efficientdet_d5": "04c_models.efficientdet.ipynb", "efficientdet_d6": "04c_models.efficientdet.ipynb", "efficientdet_d7": "04c_models.efficientdet.ipynb", "no_split": "05_learners.ipynb", "rcnn_split": "05_learners.ipynb", "effdet_split": "05_learners.ipynb", "ObjDetLearner": "05_learners.ipynb", "ObjDetLearner.get_preds": "05_learners.ipynb", "ObjDetLearner.show_results": "05_learners.ipynb", "InstSegLearner": "05_learners.ipynb", "InstSegLearner.get_preds": "05_learners.ipynb", "InstSegLearner.show_results": "05_learners.ipynb", "fasterrcnn_learner": "05_learners.ipynb", "maskrcnn_learner": "05_learners.ipynb", "efficientdet_learner": "05_learners.ipynb", "mAP_Metric": "06_metrics.ipynb", "create_mAP_metric": "06_metrics.ipynb", "mAP_at_IoU40": "06_metrics.ipynb", "mAP_at_IoU50": "06_metrics.ipynb", "mAP_at_IoU60": "06_metrics.ipynb", "mAP_at_IoU70": "06_metrics.ipynb", "mAP_at_IoU80": "06_metrics.ipynb", "mAP_at_IoU90": "06_metrics.ipynb", "mAP_at_IoU50_95": "06_metrics.ipynb", "mAP_Metric_np": "07_metrics_np.ipynb", "create_mAP_metric_np": "07_metrics_np.ipynb", "mAP_at_IoU40_np": "07_metrics_np.ipynb", "mAP_at_IoU50_np": "07_metrics_np.ipynb", "mAP_at_IoU60_np": "07_metrics_np.ipynb", "mAP_at_IoU70_np": "07_metrics_np.ipynb", "mAP_at_IoU80_np": "07_metrics_np.ipynb", "mAP_at_IoU90_np": "07_metrics_np.ipynb", "mAP_at_IoU50_95_np": "07_metrics_np.ipynb"} modules = ["core.py", "datasets.py", "dataloaders.py", "callbacks.py", "models/fasterrcnn.py", "models/maskrcnn.py", "models/efficientdet.py", "learners.py", "metrics.py", "metrics_np.py"] doc_url = "https://rbrtwlz.github.io/fastai_object_detection/" git_url = "https://github.com/rbrtwlz/fastai_object_detection/tree/master/" def custom_doc_links(name): return None
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'show_binmask': '00_core.ipynb', 'BinaryMasksBlock': '00_core.ipynb', 'TensorBinMasks': '00_core.ipynb', 'TensorBinMasks2TensorMask': '00_core.ipynb', 'CocoData': '01_datasets.ipynb', 'ObjectDetectionDataLoaders': '02_dataloaders.ipynb', 'ObjDetAdapter': '03_callbacks.ipynb', 'get_fasterrcnn_model': '04a_models.fasterrcnn.ipynb', 'get_fasterrcnn_model_swin': '04a_models.fasterrcnn.ipynb', 'SwinTransformerFPN': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_resnet18': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_resnet34': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_resnet50': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_resnet101': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_resnet152': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_swinT': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_swinS': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_swinB': '04a_models.fasterrcnn.ipynb', 'fasterrcnn_swinL': '04a_models.fasterrcnn.ipynb', 'get_maskrcnn_model': '04b_models.maskrcnn.ipynb', 'maskrcnn_resnet18': '04b_models.maskrcnn.ipynb', 'maskrcnn_resnet34': '04b_models.maskrcnn.ipynb', 'maskrcnn_resnet50': '04b_models.maskrcnn.ipynb', 'maskrcnn_resnet101': '04b_models.maskrcnn.ipynb', 'maskrcnn_resnet152': '04b_models.maskrcnn.ipynb', 'EffDetModelWrapper': '04c_models.efficientdet.ipynb', 'get_efficientdet_model': '04c_models.efficientdet.ipynb', 'efficientdet_d0': '04c_models.efficientdet.ipynb', 'efficientdet_d1': '04c_models.efficientdet.ipynb', 'efficientdet_d2': '04c_models.efficientdet.ipynb', 'efficientdet_d3': '04c_models.efficientdet.ipynb', 'efficientdet_d4': '04c_models.efficientdet.ipynb', 'efficientdet_d5': '04c_models.efficientdet.ipynb', 'efficientdet_d6': '04c_models.efficientdet.ipynb', 'efficientdet_d7': '04c_models.efficientdet.ipynb', 'no_split': '05_learners.ipynb', 'rcnn_split': '05_learners.ipynb', 'effdet_split': '05_learners.ipynb', 'ObjDetLearner': '05_learners.ipynb', 'ObjDetLearner.get_preds': '05_learners.ipynb', 'ObjDetLearner.show_results': '05_learners.ipynb', 'InstSegLearner': '05_learners.ipynb', 'InstSegLearner.get_preds': '05_learners.ipynb', 'InstSegLearner.show_results': '05_learners.ipynb', 'fasterrcnn_learner': '05_learners.ipynb', 'maskrcnn_learner': '05_learners.ipynb', 'efficientdet_learner': '05_learners.ipynb', 'mAP_Metric': '06_metrics.ipynb', 'create_mAP_metric': '06_metrics.ipynb', 'mAP_at_IoU40': '06_metrics.ipynb', 'mAP_at_IoU50': '06_metrics.ipynb', 'mAP_at_IoU60': '06_metrics.ipynb', 'mAP_at_IoU70': '06_metrics.ipynb', 'mAP_at_IoU80': '06_metrics.ipynb', 'mAP_at_IoU90': '06_metrics.ipynb', 'mAP_at_IoU50_95': '06_metrics.ipynb', 'mAP_Metric_np': '07_metrics_np.ipynb', 'create_mAP_metric_np': '07_metrics_np.ipynb', 'mAP_at_IoU40_np': '07_metrics_np.ipynb', 'mAP_at_IoU50_np': '07_metrics_np.ipynb', 'mAP_at_IoU60_np': '07_metrics_np.ipynb', 'mAP_at_IoU70_np': '07_metrics_np.ipynb', 'mAP_at_IoU80_np': '07_metrics_np.ipynb', 'mAP_at_IoU90_np': '07_metrics_np.ipynb', 'mAP_at_IoU50_95_np': '07_metrics_np.ipynb'} modules = ['core.py', 'datasets.py', 'dataloaders.py', 'callbacks.py', 'models/fasterrcnn.py', 'models/maskrcnn.py', 'models/efficientdet.py', 'learners.py', 'metrics.py', 'metrics_np.py'] doc_url = 'https://rbrtwlz.github.io/fastai_object_detection/' git_url = 'https://github.com/rbrtwlz/fastai_object_detection/tree/master/' def custom_doc_links(name): return None
#Banar for Em-Bomber def logo(): return ("""\033[1;92m ___ ___ _ | __>._ _ _ ___ | . > ___ ._ _ _ | |_ ___ _ _ | _> | ' ' ||___|| . \/ . \| ' ' || . \/ ._>| '_> |___>|_|_|_| |___/\___/|_|_|_||___/\___.|_| \033[0;0m \033[1;0;101m Coded by Sajjad \033[0;0m \033[1;90;107m github: https://www.github.com/Background-Sajjad \033[1;0;0m """) if __name__=="__main__": print(logo())
def logo(): return "\x1b[1;92m\n ___ ___ _ \n | __>._ _ _ ___ | . > ___ ._ _ _ | |_ ___ _ _ \n | _> | ' ' ||___|| . \\/ . \\| ' ' || . \\/ ._>| '_>\n |___>|_|_|_| |___/\\___/|_|_|_||___/\\___.|_| \n \x1b[0;0m\n\t\x1b[1;0;101m\t Coded by Sajjad \n\x1b[0;0m\n \x1b[1;90;107m github: https://www.github.com/Background-Sajjad \x1b[1;0;0m\n" if __name__ == '__main__': print(logo())
DEFAULT_TIMEOUT = 120 def test_upgrade_simple(context, client): _run_upgrade(context, client, 1, 1, finalScale=2, intervalMillis=100) def test_upgrade_odd_numbers(context, client): _run_upgrade(context, client, 5, 2, batchSize=100, finalScale=3, intervalMillis=100) def test_upgrade_to_too_high(context, client): _run_upgrade(context, client, 1, 5, batchSize=2, finalScale=2, intervalMillis=100) def test_upgrade_relink(context, client): service, service2, env = _create_env_and_services(context, client) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} source = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) lb = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) source = client.wait_success(client.wait_success(source).activate()) assert source.state == "active" lb = client.wait_success(client.wait_success(lb).activate()) assert lb.state == "active" service_link = {"serviceId": service.id, "name": "link1"} source.setservicelinks(serviceLinks=[service_link]) lb.setservicelinks(serviceLinks=[service_link]) source = client.wait_success(source) assert source.state == "active" lb = client.wait_success(lb) assert lb.state == "active" assert len(source.consumedservices()) == 1 assert len(lb.consumedservices()) == 1 assert len(service.consumedbyservices()) == 2 assert len(service2.consumedbyservices()) == 0 strategy = {"finalScale": 1, "toServiceId": service2.id, "updateLinks": True, "intervalMillis": 100} service = service.upgrade_action(toServiceStrategy=strategy) service = client.wait_success(service, timeout=DEFAULT_TIMEOUT) assert service.state == "upgraded" assert len(source.consumedservices()) == 2 assert len(lb.consumedservices()) == 2 assert len(service.consumedbyservices()) == 2 assert len(service2.consumedbyservices()) == 2 links = client.list_service_consume_map(serviceId=lb.id) assert len(links) == 2 def test_in_service_upgrade_primary(context, client, super_client): env, svc, up_svc = _insvc_upgrade(context, client, super_client, True, launchConfig={"labels": {"foo": "bar"}}, startFirst=True) _validate_upgrade(super_client, svc, up_svc, primary="1", secondary1="0", secondary2="0") def test_in_service_upgrade_inactive(context, client, super_client): env, svc, up_svc = _insvc_upgrade(context, client, super_client, True, activate=False, launchConfig={"labels": {"foo": "bar"}}, startFirst=True) _validate_upgrade(super_client, svc, up_svc, primary="1", secondary1="0", secondary2="0") def test_in_service_upgrade_all(context, client, super_client): secondary = [{"name": "secondary1", "labels": {"foo": "bar"}}, {"name": "secondary2", "labels": {"foo": "bar"}}] env, svc, up_svc = _insvc_upgrade(context, client, super_client, True, launchConfig={"labels": {"foo": "bar"}}, secondaryLaunchConfigs=secondary, batchSize=3, intervalMillis=100) _validate_upgrade(super_client, svc, up_svc, primary="1", secondary1="1", secondary2="1") def test_in_service_upgrade_one_secondary(context, client, super_client): secondary = [{"name": "secondary1", "labels": {"foo": "bar"}}] env, svc, upgraded_svc = _insvc_upgrade(context, client, super_client, True, secondaryLaunchConfigs=secondary, batchSize=2, intervalMillis=100) _validate_upgrade(super_client, svc, upgraded_svc, primary="0", secondary1="1", secondary2="0") def test_in_service_upgrade_mix(context, client, super_client): secondary = [{"name": "secondary1", "labels": {"foo": "bar"}}] env, svc, up_svc = _insvc_upgrade(context, client, super_client, True, launchConfig={"labels": {"foo": "bar"}}, secondaryLaunchConfigs=secondary, batchSize=1) _validate_upgrade(super_client, svc, up_svc, primary="1", secondary1="1", secondary2="0") def test_big_scale(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == "active" image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=10, launchConfig=launch_config, intervalMillis=100) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), DEFAULT_TIMEOUT) svc = _run_insvc_upgrade(svc, batchSize=1, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) svc = client.wait_success(svc.finishupgrade()) svc = _run_insvc_upgrade(svc, batchSize=5, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) client.wait_success(svc.finishupgrade()) def test_rollback_regular_upgrade(context, client, super_client): svc, service2, env = _create_env_and_services(context, client, 4, 4) svc = _run_tosvc_upgrade(svc, service2, toServiceId=service2.id, finalScale=4) time.sleep(1) svc = wait_state(client, svc.cancelupgrade(), "canceled-upgrade") svc = wait_state(client, svc.rollback(), "active") _wait_for_map_count(super_client, svc) def _create_and_schedule_inservice_upgrade(client, context, startFirst=False): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == "active" image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=4, launchConfig=launch_config, image=image_uuid) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) svc = _run_insvc_upgrade(svc, batchSize=2, launchConfig=launch_config, startFirst=startFirst, intervalMillis=100) def upgrade_not_null(): return _validate_in_svc_upgrade(client, svc) svc = wait_for(upgrade_not_null, DEFAULT_TIMEOUT) return svc def test_rollback_inservice_upgrade(context, client, super_client): svc = _create_and_schedule_inservice_upgrade(client, context) time.sleep(1) svc = _cancel_upgrade(client, svc) _rollback(client, super_client, svc, 1, 0, 0) def test_cancelupgrade_remove(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc.remove() def test_cancelupgrade_rollback(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc = client.wait_success(svc.rollback()) svc.remove() def test_cancelupgrade_finish(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc.continueupgrade() def test_upgrade_finish_cancel_rollback(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "upgraded" svc = svc.finishupgrade() wait_for(lambda: client.reload(svc).state == "finishing-upgrade") svc = _cancel_upgrade(client, svc) assert svc.state == "canceled-upgrade" svc = client.wait_success(svc.rollback()) def test_state_transition_start_first(context, client): svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=False) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "upgraded" svc = svc.rollback() svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "active" return svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=True) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "upgraded" svc = svc.rollback() svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "active" svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=False) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == "upgraded" client.wait_success(svc.remove()) def test_in_service_upgrade_networks_from(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": "container", "networkLaunchConfig": "secondary1"} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _validate_upgrade(super_client, svc, u_svc, primary="1", secondary1="1", secondary2="0") def test_in_service_upgrade_volumes_from(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1", "dataVolumesFromLaunchConfigs": ["secondary2"]} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _validate_upgrade(super_client, svc, u_svc, primary="1", secondary1="1", secondary2="1") def _create_stack(client): env = client.create_environment(name=random_str()) env = client.wait_success(env) return env def test_dns_service_upgrade(client): env = _create_stack(client) labels = {"foo": "bar"} launch_config = {"labels": labels} dns = client.create_dnsService(name=random_str(), environmentId=env.id, launchConfig=launch_config) dns = client.wait_success(dns) assert dns.launchConfig is not None assert dns.launchConfig.labels == labels dns = client.wait_success(dns.activate()) labels = {"bar": "foo"} launch_config = {"labels": labels} dns = _run_insvc_upgrade(dns, batchSize=1, launchConfig=launch_config) dns = client.wait_success(dns, DEFAULT_TIMEOUT) assert dns.launchConfig is not None assert dns.launchConfig.labels == labels def test_external_service_upgrade(client): env = _create_stack(client) labels = {"foo": "bar"} launch_config = {"labels": labels} ips = ["72.22.16.5", "192.168.0.10"] svc = client.create_externalService(name=random_str(), environmentId=env.id, externalIpAddresses=ips, launchConfig=launch_config) svc = client.wait_success(svc) assert svc.launchConfig is not None assert svc.launchConfig.labels == labels svc = client.wait_success(svc.activate()) labels = {"bar": "foo"} launch_config = {"labels": labels} svc = _run_insvc_upgrade(svc, batchSize=1, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.launchConfig is not None assert svc.launchConfig.labels == labels def test_service_upgrade_no_image_selector(client): env = _create_stack(client) launch_config = {"imageUuid": "rancher/none"} svc1 = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config, selectorContainer="foo=barbar") svc1 = client.wait_success(svc1) svc1 = client.wait_success(svc1.activate()) strategy = {"intervalMillis": 100, "launchConfig": {}} svc1.upgrade_action(launchConfig=launch_config, inServiceStrategy=strategy) def test_service_upgrade_mixed_selector(client, context): env = _create_stack(client) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} svc2 = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config, selectorContainer="foo=barbar") svc2 = client.wait_success(svc2) svc2 = client.wait_success(svc2.activate()) _run_insvc_upgrade(svc2, launchConfig=launch_config) def test_rollback_sidekicks(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=3, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) initial_maps = super_client.list_serviceExposeMap(serviceId=svc.id, state="active", upgrade=False) u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1], batchSize=2) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) assert u_svc.state == "active" final_maps = super_client.list_serviceExposeMap(serviceId=u_svc.id, state="active", upgrade=False) for initial_map in initial_maps: found = False for final_map in final_maps: if final_map.id == initial_map.id: found = True break assert found is True def test_upgrade_env(client): env = client.create_environment(name="env-" + random_str()) env = client.wait_success(env) assert env.state == "active" env = env.upgrade() assert env.state == "upgrading" env = client.wait_success(env) assert env.state == "upgraded" def test_upgrade_rollback_env(client): env = client.create_environment(name="env-" + random_str()) env = client.wait_success(env) assert env.state == "active" assert "upgrade" in env env = env.upgrade() assert env.state == "upgrading" env = client.wait_success(env) assert env.state == "upgraded" assert "rollback" in env env = env.rollback() assert env.state == "rolling-back" env = client.wait_success(env) assert env.state == "active" def _run_insvc_upgrade(svc, **kw): kw["intervalMillis"] = 100 svc = svc.upgrade_action(inServiceStrategy=kw) assert svc.state == "upgrading" return svc def _insvc_upgrade(context, client, super_client, finish_upgrade, activate=True, **kw): env, svc = _create_multi_lc_svc(super_client, client, context, activate) _run_insvc_upgrade(svc, **kw) def upgrade_not_null(): return _validate_in_svc_upgrade(client, svc) u_svc = wait_for(upgrade_not_null) u_svc = client.wait_success(u_svc, timeout=DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" if finish_upgrade: u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) assert u_svc.state == "active" return env, svc, u_svc def _validate_in_svc_upgrade(client, svc): s = client.reload(svc) upgrade = s.upgrade if upgrade is not None: strategy = upgrade.inServiceStrategy c1 = strategy.previousLaunchConfig is not None c2 = strategy.previousSecondaryLaunchConfigs is not None if c1 or c2: return s def _wait_for_instance_start(super_client, id): wait_for(lambda: len(super_client.by_id("container", id)) > 0) return super_client.by_id("container", id) def _wait_for_map_count(super_client, service, launchConfig=None): def get_active_launch_config_instances(): match = [] instance_maps = super_client.list_serviceExposeMap(serviceId=service.id, state="active", upgrade=False) for instance_map in instance_maps: if launchConfig is not None: if instance_map.dnsPrefix == launchConfig: match.append(instance_map) else: if instance_map.dnsPrefix is None: match.append(instance_map) return match def active_len(): match = get_active_launch_config_instances() if len(match) == service.scale: return match wait_for(active_len) return get_active_launch_config_instances() def _validate_upgraded_instances_count(super_client, svc, primary=0, secondary1=0, secondary2=0): if primary == 1: lc = svc.launchConfig _validate_launch_config(super_client, lc, svc) if secondary1 == 1: lc = svc.secondaryLaunchConfigs[0] _validate_launch_config(super_client, lc, svc) if secondary2 == 1: lc = svc.secondaryLaunchConfigs[1] _validate_launch_config(super_client, lc, svc) def _validate_launch_config(super_client, launchConfig, svc): match = _get_upgraded_instances(super_client, launchConfig, svc) if len(match) == svc.scale: return match def _get_upgraded_instances(super_client, launchConfig, svc): c_name = svc.name if hasattr(launchConfig, "name"): c_name = svc.name + "-" + launchConfig.name match = [] instances = super_client.list_container(state="running", accountId=svc.accountId) for instance in instances: if instance.name is not None and c_name in instance.name and instance.version == launchConfig.version: labels = {"foo": "bar"} assert all(item in instance.labels for item in labels) is True match.append(instance) return match def _create_env_and_services(context, client, from_scale=1, to_scale=1): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == "active" image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": None} service = client.create_service(name=random_str(), environmentId=env.id, scale=from_scale, launchConfig=launch_config) service = client.wait_success(service) service = client.wait_success(service.activate(), timeout=DEFAULT_TIMEOUT) assert service.state == "active" assert service.upgrade is None service2 = client.create_service(name=random_str(), environmentId=env.id, scale=to_scale, launchConfig=launch_config) service2 = client.wait_success(service2) service2 = client.wait_success(service2.activate(), timeout=DEFAULT_TIMEOUT) assert service2.state == "active" assert service2.upgrade is None return service, service2, env def _run_tosvc_upgrade(service, service2, **kw): kw["toServiceId"] = service2.id service = service.upgrade_action(toServiceStrategy=kw) assert service.state == "upgrading" return service def _run_upgrade(context, client, from_scale, to_scale, **kw): service, service2, env = _create_env_and_services(context, client, from_scale, to_scale) _run_tosvc_upgrade(service, service2, **kw) def upgrade_not_null(): s = client.reload(service) if s.upgrade is not None: return s service = wait_for(upgrade_not_null) service = client.wait_success(service, timeout=DEFAULT_TIMEOUT) assert service.state == "upgraded" assert service.scale == 0 service2 = client.wait_success(service2) assert service2.state == "active" assert service2.scale == kw["finalScale"] service = client.wait_success(service.finishupgrade(), DEFAULT_TIMEOUT) assert service.state == "active" def _create_multi_lc_svc(super_client, client, context, activate=True): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == "active" image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": None} secondary_lc1 = {"imageUuid": image_uuid, "name": "secondary1", "dataVolumesFromLaunchConfigs": ["secondary2"]} secondary_lc2 = {"imageUuid": image_uuid, "name": "secondary2"} secondary = [secondary_lc1, secondary_lc2] svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=secondary) svc = client.wait_success(svc) if activate: svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) assert svc.state == "active" c11, c11_sec1, c11_sec2, c12, c12_sec1, c12_sec2 = _get_containers(super_client, svc) assert svc.launchConfig.version is not None assert svc.secondaryLaunchConfigs[0].version is not None assert svc.secondaryLaunchConfigs[1].version is not None assert c11.version == svc.launchConfig.version assert c12.version == svc.launchConfig.version assert c11_sec1.version == svc.secondaryLaunchConfigs[0].version assert c12_sec1.version == svc.secondaryLaunchConfigs[0].version assert c11_sec2.version == svc.secondaryLaunchConfigs[1].version assert c12_sec2.version == svc.secondaryLaunchConfigs[1].version return env, svc def _get_containers(super_client, service): i_maps = _wait_for_map_count(super_client, service) c11 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12 = _wait_for_instance_start(super_client, i_maps[1].instanceId) i_maps = _wait_for_map_count(super_client, service, "secondary1") c11_sec1 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12_sec1 = _wait_for_instance_start(super_client, i_maps[1].instanceId) i_maps = _wait_for_map_count(super_client, service, "secondary2") c11_sec2 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12_sec2 = _wait_for_instance_start(super_client, i_maps[1].instanceId) return c11, c11_sec1, c11_sec2, c12, c12_sec1, c12_sec2 def _validate_upgrade(super_client, svc, upgraded_svc, primary="0", secondary1="0", secondary2="0"): _validate_upgraded_instances_count(super_client, upgraded_svc, primary, secondary1, secondary2) primary_v = svc.launchConfig.version sec1_v = svc.secondaryLaunchConfigs[0].version sec2_v = svc.secondaryLaunchConfigs[1].version primary_upgraded_v = primary_v sec1_upgraded_v = sec1_v sec2_upgraded_v = sec2_v strategy = upgraded_svc.upgrade.inServiceStrategy if primary == "1": primary_upgraded_v = upgraded_svc.launchConfig.version primary_prev_v = strategy.previousLaunchConfig.version assert primary_v != primary_upgraded_v assert primary_prev_v == primary_v if secondary1 == "1": sec1_upgraded_v = upgraded_svc.secondaryLaunchConfigs[0].version sec1_prev_v = strategy.previousSecondaryLaunchConfigs[0].version assert sec1_v != sec1_upgraded_v assert sec1_prev_v == sec1_v if secondary2 == "1": sec2_upgraded_v = upgraded_svc.secondaryLaunchConfigs[1].version sec2_prev_v = strategy.previousSecondaryLaunchConfigs[1].version assert sec2_v != sec2_upgraded_v assert sec2_prev_v == sec2_v c21, c21_sec1, c21_sec2, c22, c22_sec1, c22_sec2 = _get_containers(super_client, upgraded_svc) assert upgraded_svc.launchConfig.version == primary_upgraded_v assert upgraded_svc.secondaryLaunchConfigs[0].version == sec1_upgraded_v assert upgraded_svc.secondaryLaunchConfigs[1].version == sec2_upgraded_v assert c21.version == upgraded_svc.launchConfig.version assert c22.version == upgraded_svc.launchConfig.version assert c21_sec1.version == upgraded_svc.secondaryLaunchConfigs[0].version assert c22_sec1.version == upgraded_svc.secondaryLaunchConfigs[0].version assert c21_sec2.version == upgraded_svc.secondaryLaunchConfigs[1].version assert c22_sec2.version == upgraded_svc.secondaryLaunchConfigs[1].version def _validate_rollback(super_client, svc, rolledback_svc, primary=0, secondary1=0, secondary2=0): _validate_upgraded_instances_count(super_client, svc, primary, secondary1, secondary2) strategy = svc.upgrade.inServiceStrategy if primary == 1: primary_v = rolledback_svc.launchConfig.version primary_prev_v = strategy.previousLaunchConfig.version assert primary_prev_v == primary_v maps = _wait_for_map_count(super_client, rolledback_svc) for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == primary_v if secondary1 == 1: sec1_v = rolledback_svc.secondaryLaunchConfigs[0].version sec1_prev_v = strategy.previousSecondaryLaunchConfigs[0].version assert sec1_prev_v == sec1_v maps = _wait_for_map_count(super_client, rolledback_svc, "secondary1") for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == sec1_v if secondary2 == 1: sec2_v = rolledback_svc.secondaryLaunchConfigs[1].version sec2_prev_v = strategy.previousSecondaryLaunchConfigs[1].version assert sec2_prev_v == sec2_v maps = _wait_for_map_count(super_client, rolledback_svc, "secondary2") for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == sec2_v def _cancel_upgrade(client, svc): svc.cancelupgrade() wait_for(lambda: client.reload(svc).state == "canceled-upgrade") svc = client.reload(svc) strategy = svc.upgrade.inServiceStrategy assert strategy.previousLaunchConfig is not None assert strategy.previousSecondaryLaunchConfigs is not None return svc def _rollback(client, super_client, svc, primary=0, secondary1=0, secondary2=0): rolledback_svc = client.wait_success(svc.rollback(), DEFAULT_TIMEOUT) assert rolledback_svc.state == "active" roll_v = rolledback_svc.launchConfig.version strategy = svc.upgrade.inServiceStrategy assert roll_v == strategy.previousLaunchConfig.version _validate_rollback(super_client, svc, rolledback_svc, primary, secondary1, secondary2) def test_rollback_id(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == "active" image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "networkMode": None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, image=image_uuid) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) maps = _wait_for_map_count(super_client, svc) expose_map = maps[0] c1 = super_client.reload(expose_map.instance()) svc = _run_insvc_upgrade(svc, batchSize=2, launchConfig=launch_config, startFirst=False, intervalMillis=100) svc = client.wait_success(svc) svc = client.wait_success(svc.rollback(), DEFAULT_TIMEOUT) maps = _wait_for_map_count(super_client, svc) expose_map = maps[0] c2 = super_client.reload(expose_map.instance()) assert c1.uuid == c2.uuid def test_in_service_upgrade_port_mapping(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid, "ports": ["80", "82/tcp"]} secondary1 = {"imageUuid": image_uuid, "name": "secondary1", "ports": ["90"]} secondary2 = {"imageUuid": image_uuid, "name": "secondary2", "ports": ["100"]} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) launch_config = {"imageUuid": image_uuid, "ports": ["80", "82/tcp", "8083:83/udp"]} u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) svc.launchConfig.ports.append(unicode("8083:83/udp")) assert u_svc.launchConfig.ports == svc.launchConfig.ports assert u_svc.secondaryLaunchConfigs[0].ports == svc.secondaryLaunchConfigs[0].ports assert u_svc.secondaryLaunchConfigs[1].ports == svc.secondaryLaunchConfigs[1].ports def test_sidekick_addition(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c2_pre = _validate_compose_instance_start(client, svc, env, "1", "secondary1") u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, "1") assert c1.version != "0" c2 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c2.version == "0" assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, "1", "secondary2") assert c3.version != "0" def test_sidekick_addition_rollback(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c11_pre = _validate_compose_instance_start(client, svc, env, "1") c12_pre = _validate_compose_instance_start(client, svc, env, "2") c21_pre = _validate_compose_instance_start(client, svc, env, "1", "secondary1") c22_pre = _validate_compose_instance_start(client, svc, env, "2", "secondary1") u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 4, client) c11 = _validate_compose_instance_start(client, svc, env, "1") assert c11.version == "0" assert c11.id == c11_pre.id c12 = _validate_compose_instance_start(client, svc, env, "2") assert c12.version == "0" assert c12.id == c12_pre.id c21 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c21.version == "0" assert c21.id == c21_pre.id c22 = _validate_compose_instance_start(client, svc, env, "2", "secondary1") assert c22.version == "0" assert c22.id == c22_pre.id def test_sidekick_addition_wo_primary(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, "1") c2_pre = _validate_compose_instance_start(client, svc, env, "1", "secondary1") u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, "1") assert c1.version == "0" assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c2.version == "0" assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, "1", "secondary2") assert c3.version != "0" def test_sidekick_addition_two_sidekicks(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, "1") u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, "1") assert c1.version == "0" assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c2.version != "0" c3 = _validate_compose_instance_start(client, svc, env, "1", "secondary2") assert c3.version != "0" def test_sidekick_removal(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, "1") secondary2 = {"imageUuid": image_uuid, "name": "secondary2", "imageUuid": "rancher/none"} u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 2, client) c1 = _validate_compose_instance_start(client, svc, env, "1") assert c1.version == "0" assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c2.version != "0" def test_sidekick_removal_rollback(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {"imageUuid": image_uuid} secondary1 = {"imageUuid": image_uuid, "name": "secondary1"} secondary2 = {"imageUuid": image_uuid, "name": "secondary2"} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, "1") c2_pre = _validate_compose_instance_start(client, svc, env, "1", "secondary1") c3_pre = _validate_compose_instance_start(client, svc, env, "1", "secondary2") secondary2 = {"imageUuid": image_uuid, "name": "secondary2", "imageUuid": "rancher/none"} u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == "upgraded" u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, "1") assert c1.version == "0" assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, "1", "secondary1") assert c2.version == "0" assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, "1", "secondary2") assert c3.version == "0" assert c3.id == c3_pre.id def _wait_until_active_map_count(service, count, client): def wait_for_map_count(service): m = client.list_serviceExposeMap(serviceId=service.id, state="active") return len(m) == count wait_for(lambda: wait_for_condition(client, service, wait_for_map_count)) return client.list_serviceExposeMap(serviceId=service.id, state="active") def _validate_compose_instance_start(client, service, env, number, launch_config_name=None): cn = launch_config_name + "-" if launch_config_name is not None else "" name = env.name + "-" + service.name + "-" + cn + number def wait_for_map_count(service): instances = client.list_container(name=name, state="running") return len(instances) == 1 wait_for(lambda: wait_for_condition(client, service, wait_for_map_count)) instances = client.list_container(name=name, state="running") return instances[0] def test_upgrade_global_service(new_context): client = new_context.client host1 = new_context.host host2 = register_simulated_host(new_context) host3 = register_simulated_host(new_context) client.wait_success(host1) client.wait_success(host2) client.wait_success(host3) env = _create_stack(client) image_uuid = new_context.image_uuid launch_config = {"imageUuid": image_uuid, "labels": {"io.rancher.scheduler.global": "true"}} service = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config) service = client.wait_success(service) assert service.state == "inactive" service = client.wait_success(service.activate(), 120) assert service.state == "active" c = client.list_serviceExposeMap(serviceId=service.id, state="active") strategy = {"launchConfig": launch_config, "intervalMillis": 100} service.upgrade_action(inServiceStrategy=strategy) wait_for(lambda: client.reload(service).state == "upgraded") service = client.reload(service) service = client.wait_success(service.rollback()) _wait_until_active_map_count(service, len(c), client)
default_timeout = 120 def test_upgrade_simple(context, client): _run_upgrade(context, client, 1, 1, finalScale=2, intervalMillis=100) def test_upgrade_odd_numbers(context, client): _run_upgrade(context, client, 5, 2, batchSize=100, finalScale=3, intervalMillis=100) def test_upgrade_to_too_high(context, client): _run_upgrade(context, client, 1, 5, batchSize=2, finalScale=2, intervalMillis=100) def test_upgrade_relink(context, client): (service, service2, env) = _create_env_and_services(context, client) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} source = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) lb = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) source = client.wait_success(client.wait_success(source).activate()) assert source.state == 'active' lb = client.wait_success(client.wait_success(lb).activate()) assert lb.state == 'active' service_link = {'serviceId': service.id, 'name': 'link1'} source.setservicelinks(serviceLinks=[service_link]) lb.setservicelinks(serviceLinks=[service_link]) source = client.wait_success(source) assert source.state == 'active' lb = client.wait_success(lb) assert lb.state == 'active' assert len(source.consumedservices()) == 1 assert len(lb.consumedservices()) == 1 assert len(service.consumedbyservices()) == 2 assert len(service2.consumedbyservices()) == 0 strategy = {'finalScale': 1, 'toServiceId': service2.id, 'updateLinks': True, 'intervalMillis': 100} service = service.upgrade_action(toServiceStrategy=strategy) service = client.wait_success(service, timeout=DEFAULT_TIMEOUT) assert service.state == 'upgraded' assert len(source.consumedservices()) == 2 assert len(lb.consumedservices()) == 2 assert len(service.consumedbyservices()) == 2 assert len(service2.consumedbyservices()) == 2 links = client.list_service_consume_map(serviceId=lb.id) assert len(links) == 2 def test_in_service_upgrade_primary(context, client, super_client): (env, svc, up_svc) = _insvc_upgrade(context, client, super_client, True, launchConfig={'labels': {'foo': 'bar'}}, startFirst=True) _validate_upgrade(super_client, svc, up_svc, primary='1', secondary1='0', secondary2='0') def test_in_service_upgrade_inactive(context, client, super_client): (env, svc, up_svc) = _insvc_upgrade(context, client, super_client, True, activate=False, launchConfig={'labels': {'foo': 'bar'}}, startFirst=True) _validate_upgrade(super_client, svc, up_svc, primary='1', secondary1='0', secondary2='0') def test_in_service_upgrade_all(context, client, super_client): secondary = [{'name': 'secondary1', 'labels': {'foo': 'bar'}}, {'name': 'secondary2', 'labels': {'foo': 'bar'}}] (env, svc, up_svc) = _insvc_upgrade(context, client, super_client, True, launchConfig={'labels': {'foo': 'bar'}}, secondaryLaunchConfigs=secondary, batchSize=3, intervalMillis=100) _validate_upgrade(super_client, svc, up_svc, primary='1', secondary1='1', secondary2='1') def test_in_service_upgrade_one_secondary(context, client, super_client): secondary = [{'name': 'secondary1', 'labels': {'foo': 'bar'}}] (env, svc, upgraded_svc) = _insvc_upgrade(context, client, super_client, True, secondaryLaunchConfigs=secondary, batchSize=2, intervalMillis=100) _validate_upgrade(super_client, svc, upgraded_svc, primary='0', secondary1='1', secondary2='0') def test_in_service_upgrade_mix(context, client, super_client): secondary = [{'name': 'secondary1', 'labels': {'foo': 'bar'}}] (env, svc, up_svc) = _insvc_upgrade(context, client, super_client, True, launchConfig={'labels': {'foo': 'bar'}}, secondaryLaunchConfigs=secondary, batchSize=1) _validate_upgrade(super_client, svc, up_svc, primary='1', secondary1='1', secondary2='0') def test_big_scale(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == 'active' image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=10, launchConfig=launch_config, intervalMillis=100) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), DEFAULT_TIMEOUT) svc = _run_insvc_upgrade(svc, batchSize=1, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) svc = client.wait_success(svc.finishupgrade()) svc = _run_insvc_upgrade(svc, batchSize=5, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) client.wait_success(svc.finishupgrade()) def test_rollback_regular_upgrade(context, client, super_client): (svc, service2, env) = _create_env_and_services(context, client, 4, 4) svc = _run_tosvc_upgrade(svc, service2, toServiceId=service2.id, finalScale=4) time.sleep(1) svc = wait_state(client, svc.cancelupgrade(), 'canceled-upgrade') svc = wait_state(client, svc.rollback(), 'active') _wait_for_map_count(super_client, svc) def _create_and_schedule_inservice_upgrade(client, context, startFirst=False): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == 'active' image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=4, launchConfig=launch_config, image=image_uuid) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) svc = _run_insvc_upgrade(svc, batchSize=2, launchConfig=launch_config, startFirst=startFirst, intervalMillis=100) def upgrade_not_null(): return _validate_in_svc_upgrade(client, svc) svc = wait_for(upgrade_not_null, DEFAULT_TIMEOUT) return svc def test_rollback_inservice_upgrade(context, client, super_client): svc = _create_and_schedule_inservice_upgrade(client, context) time.sleep(1) svc = _cancel_upgrade(client, svc) _rollback(client, super_client, svc, 1, 0, 0) def test_cancelupgrade_remove(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc.remove() def test_cancelupgrade_rollback(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc = client.wait_success(svc.rollback()) svc.remove() def test_cancelupgrade_finish(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = _cancel_upgrade(client, svc) svc.continueupgrade() def test_upgrade_finish_cancel_rollback(context, client): svc = _create_and_schedule_inservice_upgrade(client, context) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'upgraded' svc = svc.finishupgrade() wait_for(lambda : client.reload(svc).state == 'finishing-upgrade') svc = _cancel_upgrade(client, svc) assert svc.state == 'canceled-upgrade' svc = client.wait_success(svc.rollback()) def test_state_transition_start_first(context, client): svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=False) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'upgraded' svc = svc.rollback() svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'active' return svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=True) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'upgraded' svc = svc.rollback() svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'active' svc = _create_and_schedule_inservice_upgrade(client, context, startFirst=False) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.state == 'upgraded' client.wait_success(svc.remove()) def test_in_service_upgrade_networks_from(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': 'container', 'networkLaunchConfig': 'secondary1'} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _validate_upgrade(super_client, svc, u_svc, primary='1', secondary1='1', secondary2='0') def test_in_service_upgrade_volumes_from(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1', 'dataVolumesFromLaunchConfigs': ['secondary2']} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _validate_upgrade(super_client, svc, u_svc, primary='1', secondary1='1', secondary2='1') def _create_stack(client): env = client.create_environment(name=random_str()) env = client.wait_success(env) return env def test_dns_service_upgrade(client): env = _create_stack(client) labels = {'foo': 'bar'} launch_config = {'labels': labels} dns = client.create_dnsService(name=random_str(), environmentId=env.id, launchConfig=launch_config) dns = client.wait_success(dns) assert dns.launchConfig is not None assert dns.launchConfig.labels == labels dns = client.wait_success(dns.activate()) labels = {'bar': 'foo'} launch_config = {'labels': labels} dns = _run_insvc_upgrade(dns, batchSize=1, launchConfig=launch_config) dns = client.wait_success(dns, DEFAULT_TIMEOUT) assert dns.launchConfig is not None assert dns.launchConfig.labels == labels def test_external_service_upgrade(client): env = _create_stack(client) labels = {'foo': 'bar'} launch_config = {'labels': labels} ips = ['72.22.16.5', '192.168.0.10'] svc = client.create_externalService(name=random_str(), environmentId=env.id, externalIpAddresses=ips, launchConfig=launch_config) svc = client.wait_success(svc) assert svc.launchConfig is not None assert svc.launchConfig.labels == labels svc = client.wait_success(svc.activate()) labels = {'bar': 'foo'} launch_config = {'labels': labels} svc = _run_insvc_upgrade(svc, batchSize=1, launchConfig=launch_config) svc = client.wait_success(svc, DEFAULT_TIMEOUT) assert svc.launchConfig is not None assert svc.launchConfig.labels == labels def test_service_upgrade_no_image_selector(client): env = _create_stack(client) launch_config = {'imageUuid': 'rancher/none'} svc1 = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config, selectorContainer='foo=barbar') svc1 = client.wait_success(svc1) svc1 = client.wait_success(svc1.activate()) strategy = {'intervalMillis': 100, 'launchConfig': {}} svc1.upgrade_action(launchConfig=launch_config, inServiceStrategy=strategy) def test_service_upgrade_mixed_selector(client, context): env = _create_stack(client) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} svc2 = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config, selectorContainer='foo=barbar') svc2 = client.wait_success(svc2) svc2 = client.wait_success(svc2.activate()) _run_insvc_upgrade(svc2, launchConfig=launch_config) def test_rollback_sidekicks(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=3, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) initial_maps = super_client.list_serviceExposeMap(serviceId=svc.id, state='active', upgrade=False) u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1], batchSize=2) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) assert u_svc.state == 'active' final_maps = super_client.list_serviceExposeMap(serviceId=u_svc.id, state='active', upgrade=False) for initial_map in initial_maps: found = False for final_map in final_maps: if final_map.id == initial_map.id: found = True break assert found is True def test_upgrade_env(client): env = client.create_environment(name='env-' + random_str()) env = client.wait_success(env) assert env.state == 'active' env = env.upgrade() assert env.state == 'upgrading' env = client.wait_success(env) assert env.state == 'upgraded' def test_upgrade_rollback_env(client): env = client.create_environment(name='env-' + random_str()) env = client.wait_success(env) assert env.state == 'active' assert 'upgrade' in env env = env.upgrade() assert env.state == 'upgrading' env = client.wait_success(env) assert env.state == 'upgraded' assert 'rollback' in env env = env.rollback() assert env.state == 'rolling-back' env = client.wait_success(env) assert env.state == 'active' def _run_insvc_upgrade(svc, **kw): kw['intervalMillis'] = 100 svc = svc.upgrade_action(inServiceStrategy=kw) assert svc.state == 'upgrading' return svc def _insvc_upgrade(context, client, super_client, finish_upgrade, activate=True, **kw): (env, svc) = _create_multi_lc_svc(super_client, client, context, activate) _run_insvc_upgrade(svc, **kw) def upgrade_not_null(): return _validate_in_svc_upgrade(client, svc) u_svc = wait_for(upgrade_not_null) u_svc = client.wait_success(u_svc, timeout=DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' if finish_upgrade: u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) assert u_svc.state == 'active' return (env, svc, u_svc) def _validate_in_svc_upgrade(client, svc): s = client.reload(svc) upgrade = s.upgrade if upgrade is not None: strategy = upgrade.inServiceStrategy c1 = strategy.previousLaunchConfig is not None c2 = strategy.previousSecondaryLaunchConfigs is not None if c1 or c2: return s def _wait_for_instance_start(super_client, id): wait_for(lambda : len(super_client.by_id('container', id)) > 0) return super_client.by_id('container', id) def _wait_for_map_count(super_client, service, launchConfig=None): def get_active_launch_config_instances(): match = [] instance_maps = super_client.list_serviceExposeMap(serviceId=service.id, state='active', upgrade=False) for instance_map in instance_maps: if launchConfig is not None: if instance_map.dnsPrefix == launchConfig: match.append(instance_map) elif instance_map.dnsPrefix is None: match.append(instance_map) return match def active_len(): match = get_active_launch_config_instances() if len(match) == service.scale: return match wait_for(active_len) return get_active_launch_config_instances() def _validate_upgraded_instances_count(super_client, svc, primary=0, secondary1=0, secondary2=0): if primary == 1: lc = svc.launchConfig _validate_launch_config(super_client, lc, svc) if secondary1 == 1: lc = svc.secondaryLaunchConfigs[0] _validate_launch_config(super_client, lc, svc) if secondary2 == 1: lc = svc.secondaryLaunchConfigs[1] _validate_launch_config(super_client, lc, svc) def _validate_launch_config(super_client, launchConfig, svc): match = _get_upgraded_instances(super_client, launchConfig, svc) if len(match) == svc.scale: return match def _get_upgraded_instances(super_client, launchConfig, svc): c_name = svc.name if hasattr(launchConfig, 'name'): c_name = svc.name + '-' + launchConfig.name match = [] instances = super_client.list_container(state='running', accountId=svc.accountId) for instance in instances: if instance.name is not None and c_name in instance.name and (instance.version == launchConfig.version): labels = {'foo': 'bar'} assert all((item in instance.labels for item in labels)) is True match.append(instance) return match def _create_env_and_services(context, client, from_scale=1, to_scale=1): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == 'active' image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': None} service = client.create_service(name=random_str(), environmentId=env.id, scale=from_scale, launchConfig=launch_config) service = client.wait_success(service) service = client.wait_success(service.activate(), timeout=DEFAULT_TIMEOUT) assert service.state == 'active' assert service.upgrade is None service2 = client.create_service(name=random_str(), environmentId=env.id, scale=to_scale, launchConfig=launch_config) service2 = client.wait_success(service2) service2 = client.wait_success(service2.activate(), timeout=DEFAULT_TIMEOUT) assert service2.state == 'active' assert service2.upgrade is None return (service, service2, env) def _run_tosvc_upgrade(service, service2, **kw): kw['toServiceId'] = service2.id service = service.upgrade_action(toServiceStrategy=kw) assert service.state == 'upgrading' return service def _run_upgrade(context, client, from_scale, to_scale, **kw): (service, service2, env) = _create_env_and_services(context, client, from_scale, to_scale) _run_tosvc_upgrade(service, service2, **kw) def upgrade_not_null(): s = client.reload(service) if s.upgrade is not None: return s service = wait_for(upgrade_not_null) service = client.wait_success(service, timeout=DEFAULT_TIMEOUT) assert service.state == 'upgraded' assert service.scale == 0 service2 = client.wait_success(service2) assert service2.state == 'active' assert service2.scale == kw['finalScale'] service = client.wait_success(service.finishupgrade(), DEFAULT_TIMEOUT) assert service.state == 'active' def _create_multi_lc_svc(super_client, client, context, activate=True): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == 'active' image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': None} secondary_lc1 = {'imageUuid': image_uuid, 'name': 'secondary1', 'dataVolumesFromLaunchConfigs': ['secondary2']} secondary_lc2 = {'imageUuid': image_uuid, 'name': 'secondary2'} secondary = [secondary_lc1, secondary_lc2] svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=secondary) svc = client.wait_success(svc) if activate: svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) assert svc.state == 'active' (c11, c11_sec1, c11_sec2, c12, c12_sec1, c12_sec2) = _get_containers(super_client, svc) assert svc.launchConfig.version is not None assert svc.secondaryLaunchConfigs[0].version is not None assert svc.secondaryLaunchConfigs[1].version is not None assert c11.version == svc.launchConfig.version assert c12.version == svc.launchConfig.version assert c11_sec1.version == svc.secondaryLaunchConfigs[0].version assert c12_sec1.version == svc.secondaryLaunchConfigs[0].version assert c11_sec2.version == svc.secondaryLaunchConfigs[1].version assert c12_sec2.version == svc.secondaryLaunchConfigs[1].version return (env, svc) def _get_containers(super_client, service): i_maps = _wait_for_map_count(super_client, service) c11 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12 = _wait_for_instance_start(super_client, i_maps[1].instanceId) i_maps = _wait_for_map_count(super_client, service, 'secondary1') c11_sec1 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12_sec1 = _wait_for_instance_start(super_client, i_maps[1].instanceId) i_maps = _wait_for_map_count(super_client, service, 'secondary2') c11_sec2 = _wait_for_instance_start(super_client, i_maps[0].instanceId) c12_sec2 = _wait_for_instance_start(super_client, i_maps[1].instanceId) return (c11, c11_sec1, c11_sec2, c12, c12_sec1, c12_sec2) def _validate_upgrade(super_client, svc, upgraded_svc, primary='0', secondary1='0', secondary2='0'): _validate_upgraded_instances_count(super_client, upgraded_svc, primary, secondary1, secondary2) primary_v = svc.launchConfig.version sec1_v = svc.secondaryLaunchConfigs[0].version sec2_v = svc.secondaryLaunchConfigs[1].version primary_upgraded_v = primary_v sec1_upgraded_v = sec1_v sec2_upgraded_v = sec2_v strategy = upgraded_svc.upgrade.inServiceStrategy if primary == '1': primary_upgraded_v = upgraded_svc.launchConfig.version primary_prev_v = strategy.previousLaunchConfig.version assert primary_v != primary_upgraded_v assert primary_prev_v == primary_v if secondary1 == '1': sec1_upgraded_v = upgraded_svc.secondaryLaunchConfigs[0].version sec1_prev_v = strategy.previousSecondaryLaunchConfigs[0].version assert sec1_v != sec1_upgraded_v assert sec1_prev_v == sec1_v if secondary2 == '1': sec2_upgraded_v = upgraded_svc.secondaryLaunchConfigs[1].version sec2_prev_v = strategy.previousSecondaryLaunchConfigs[1].version assert sec2_v != sec2_upgraded_v assert sec2_prev_v == sec2_v (c21, c21_sec1, c21_sec2, c22, c22_sec1, c22_sec2) = _get_containers(super_client, upgraded_svc) assert upgraded_svc.launchConfig.version == primary_upgraded_v assert upgraded_svc.secondaryLaunchConfigs[0].version == sec1_upgraded_v assert upgraded_svc.secondaryLaunchConfigs[1].version == sec2_upgraded_v assert c21.version == upgraded_svc.launchConfig.version assert c22.version == upgraded_svc.launchConfig.version assert c21_sec1.version == upgraded_svc.secondaryLaunchConfigs[0].version assert c22_sec1.version == upgraded_svc.secondaryLaunchConfigs[0].version assert c21_sec2.version == upgraded_svc.secondaryLaunchConfigs[1].version assert c22_sec2.version == upgraded_svc.secondaryLaunchConfigs[1].version def _validate_rollback(super_client, svc, rolledback_svc, primary=0, secondary1=0, secondary2=0): _validate_upgraded_instances_count(super_client, svc, primary, secondary1, secondary2) strategy = svc.upgrade.inServiceStrategy if primary == 1: primary_v = rolledback_svc.launchConfig.version primary_prev_v = strategy.previousLaunchConfig.version assert primary_prev_v == primary_v maps = _wait_for_map_count(super_client, rolledback_svc) for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == primary_v if secondary1 == 1: sec1_v = rolledback_svc.secondaryLaunchConfigs[0].version sec1_prev_v = strategy.previousSecondaryLaunchConfigs[0].version assert sec1_prev_v == sec1_v maps = _wait_for_map_count(super_client, rolledback_svc, 'secondary1') for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == sec1_v if secondary2 == 1: sec2_v = rolledback_svc.secondaryLaunchConfigs[1].version sec2_prev_v = strategy.previousSecondaryLaunchConfigs[1].version assert sec2_prev_v == sec2_v maps = _wait_for_map_count(super_client, rolledback_svc, 'secondary2') for map in maps: i = _wait_for_instance_start(super_client, map.instanceId) assert i.version == sec2_v def _cancel_upgrade(client, svc): svc.cancelupgrade() wait_for(lambda : client.reload(svc).state == 'canceled-upgrade') svc = client.reload(svc) strategy = svc.upgrade.inServiceStrategy assert strategy.previousLaunchConfig is not None assert strategy.previousSecondaryLaunchConfigs is not None return svc def _rollback(client, super_client, svc, primary=0, secondary1=0, secondary2=0): rolledback_svc = client.wait_success(svc.rollback(), DEFAULT_TIMEOUT) assert rolledback_svc.state == 'active' roll_v = rolledback_svc.launchConfig.version strategy = svc.upgrade.inServiceStrategy assert roll_v == strategy.previousLaunchConfig.version _validate_rollback(super_client, svc, rolledback_svc, primary, secondary1, secondary2) def test_rollback_id(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) assert env.state == 'active' image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'networkMode': None} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, image=image_uuid) svc = client.wait_success(svc) svc = client.wait_success(svc.activate(), timeout=DEFAULT_TIMEOUT) maps = _wait_for_map_count(super_client, svc) expose_map = maps[0] c1 = super_client.reload(expose_map.instance()) svc = _run_insvc_upgrade(svc, batchSize=2, launchConfig=launch_config, startFirst=False, intervalMillis=100) svc = client.wait_success(svc) svc = client.wait_success(svc.rollback(), DEFAULT_TIMEOUT) maps = _wait_for_map_count(super_client, svc) expose_map = maps[0] c2 = super_client.reload(expose_map.instance()) assert c1.uuid == c2.uuid def test_in_service_upgrade_port_mapping(context, client, super_client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid, 'ports': ['80', '82/tcp']} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1', 'ports': ['90']} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2', 'ports': ['100']} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) launch_config = {'imageUuid': image_uuid, 'ports': ['80', '82/tcp', '8083:83/udp']} u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) svc.launchConfig.ports.append(unicode('8083:83/udp')) assert u_svc.launchConfig.ports == svc.launchConfig.ports assert u_svc.secondaryLaunchConfigs[0].ports == svc.secondaryLaunchConfigs[0].ports assert u_svc.secondaryLaunchConfigs[1].ports == svc.secondaryLaunchConfigs[1].ports def test_sidekick_addition(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c2_pre = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, '1') assert c1.version != '0' c2 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c2.version == '0' assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, '1', 'secondary2') assert c3.version != '0' def test_sidekick_addition_rollback(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=2, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c11_pre = _validate_compose_instance_start(client, svc, env, '1') c12_pre = _validate_compose_instance_start(client, svc, env, '2') c21_pre = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') c22_pre = _validate_compose_instance_start(client, svc, env, '2', 'secondary1') u_svc = _run_insvc_upgrade(svc, launchConfig=launch_config, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 4, client) c11 = _validate_compose_instance_start(client, svc, env, '1') assert c11.version == '0' assert c11.id == c11_pre.id c12 = _validate_compose_instance_start(client, svc, env, '2') assert c12.version == '0' assert c12.id == c12_pre.id c21 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c21.version == '0' assert c21.id == c21_pre.id c22 = _validate_compose_instance_start(client, svc, env, '2', 'secondary1') assert c22.version == '0' assert c22.id == c22_pre.id def test_sidekick_addition_wo_primary(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, '1') c2_pre = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, '1') assert c1.version == '0' assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c2.version == '0' assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, '1', 'secondary2') assert c3.version != '0' def test_sidekick_addition_two_sidekicks(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, '1') u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, '1') assert c1.version == '0' assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c2.version != '0' c3 = _validate_compose_instance_start(client, svc, env, '1', 'secondary2') assert c3.version != '0' def test_sidekick_removal(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, '1') secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2', 'imageUuid': 'rancher/none'} u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.finishupgrade(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 2, client) c1 = _validate_compose_instance_start(client, svc, env, '1') assert c1.version == '0' assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c2.version != '0' def test_sidekick_removal_rollback(context, client): env = client.create_environment(name=random_str()) env = client.wait_success(env) image_uuid = context.image_uuid launch_config = {'imageUuid': image_uuid} secondary1 = {'imageUuid': image_uuid, 'name': 'secondary1'} secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2'} svc = client.create_service(name=random_str(), environmentId=env.id, scale=1, launchConfig=launch_config, secondaryLaunchConfigs=[secondary1, secondary2]) svc = client.wait_success(svc) svc = client.wait_success(svc.activate()) c1_pre = _validate_compose_instance_start(client, svc, env, '1') c2_pre = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') c3_pre = _validate_compose_instance_start(client, svc, env, '1', 'secondary2') secondary2 = {'imageUuid': image_uuid, 'name': 'secondary2', 'imageUuid': 'rancher/none'} u_svc = _run_insvc_upgrade(svc, secondaryLaunchConfigs=[secondary1, secondary2], batchSize=1) u_svc = client.wait_success(u_svc, DEFAULT_TIMEOUT) assert u_svc.state == 'upgraded' u_svc = client.wait_success(u_svc.rollback(), DEFAULT_TIMEOUT) _wait_until_active_map_count(u_svc, 3, client) c1 = _validate_compose_instance_start(client, svc, env, '1') assert c1.version == '0' assert c1.id == c1_pre.id c2 = _validate_compose_instance_start(client, svc, env, '1', 'secondary1') assert c2.version == '0' assert c2.id == c2_pre.id c3 = _validate_compose_instance_start(client, svc, env, '1', 'secondary2') assert c3.version == '0' assert c3.id == c3_pre.id def _wait_until_active_map_count(service, count, client): def wait_for_map_count(service): m = client.list_serviceExposeMap(serviceId=service.id, state='active') return len(m) == count wait_for(lambda : wait_for_condition(client, service, wait_for_map_count)) return client.list_serviceExposeMap(serviceId=service.id, state='active') def _validate_compose_instance_start(client, service, env, number, launch_config_name=None): cn = launch_config_name + '-' if launch_config_name is not None else '' name = env.name + '-' + service.name + '-' + cn + number def wait_for_map_count(service): instances = client.list_container(name=name, state='running') return len(instances) == 1 wait_for(lambda : wait_for_condition(client, service, wait_for_map_count)) instances = client.list_container(name=name, state='running') return instances[0] def test_upgrade_global_service(new_context): client = new_context.client host1 = new_context.host host2 = register_simulated_host(new_context) host3 = register_simulated_host(new_context) client.wait_success(host1) client.wait_success(host2) client.wait_success(host3) env = _create_stack(client) image_uuid = new_context.image_uuid launch_config = {'imageUuid': image_uuid, 'labels': {'io.rancher.scheduler.global': 'true'}} service = client.create_service(name=random_str(), environmentId=env.id, launchConfig=launch_config) service = client.wait_success(service) assert service.state == 'inactive' service = client.wait_success(service.activate(), 120) assert service.state == 'active' c = client.list_serviceExposeMap(serviceId=service.id, state='active') strategy = {'launchConfig': launch_config, 'intervalMillis': 100} service.upgrade_action(inServiceStrategy=strategy) wait_for(lambda : client.reload(service).state == 'upgraded') service = client.reload(service) service = client.wait_success(service.rollback()) _wait_until_active_map_count(service, len(c), client)
#========================= # Armor List #========================= clothArmor = {'name':'Cloth Armor', 'arm':1, 'description':'This is some cloth armor with a little extra padding.'} leatherArmor = {'name':'Leather Armor', 'arm':3, 'description':'This is some heavy chunks of leather that have been fashioned into armor.'} woodenPlateArmor = {'name':'Wooden Plate Armor', 'arm':7, 'description':'This is some plated armor made from pieces of wood, it seems to be pretty sturdy.'} steelPlateArmor = {'name':'Steel Plate Armor', 'arm':9, 'description':'This is some very strong plate armor made of steel, and the way it is polished makes you look great.'} chainMailArmor = {'name': 'Chain Mail Armor', 'arm':12, 'description':'This is some armor made of chain mail but it shines with a brilliance unfamiler to your knowledge of metals.'} armorList = [clothArmor, leatherArmor, woodenPlateArmor, steelPlateArmor, chainMailArmor]
cloth_armor = {'name': 'Cloth Armor', 'arm': 1, 'description': 'This is some cloth armor with a little extra padding.'} leather_armor = {'name': 'Leather Armor', 'arm': 3, 'description': 'This is some heavy chunks of leather that have been fashioned into armor.'} wooden_plate_armor = {'name': 'Wooden Plate Armor', 'arm': 7, 'description': 'This is some plated armor made from pieces of wood, it seems to be pretty sturdy.'} steel_plate_armor = {'name': 'Steel Plate Armor', 'arm': 9, 'description': 'This is some very strong plate armor made of steel, and the way it is polished makes you look great.'} chain_mail_armor = {'name': 'Chain Mail Armor', 'arm': 12, 'description': 'This is some armor made of chain mail but it shines with a brilliance unfamiler to your knowledge of metals.'} armor_list = [clothArmor, leatherArmor, woodenPlateArmor, steelPlateArmor, chainMailArmor]
#This program estimates a painting job cost_per_hour = 35.00 base_hours = 8 def main(): square_feet = float(input('Enter the number of square feet to be painted: ')) price_per_gallon = float(input('Enter the price of a paint per a gallon: ')) number_of_gallons = calculates_number_of_gallons(square_feet) hours_required = calculates_hours_required(square_feet) paint_cost = calculate_paint_cost(price_per_gallon,number_of_gallons) labor_charges = calculate_labor_charge(hours_required) grand_total = calculate_overal_total_cost(paint_cost,labor_charges) #Displaying the above data print('\nThe number of gallons of paint required = '\ ,format(number_of_gallons,'.2f'),\ ' gallons\nThe hours of labor required = '\ ,format(hours_required,'.2f'),' hours'\ '\nThe total cost of the paint = $',format(paint_cost,',.2f'),\ '\nThe labor charges = $',format(labor_charges,',.2f'),\ '\nThe total cost of the paint job = $',format(grand_total,',.2f')\ ,sep='') def calculates_number_of_gallons(square_feet): total_gallons = square_feet / 112 return total_gallons def calculates_hours_required(square_feet): hours = (square_feet * base_hours)/ 112 return hours def calculate_paint_cost(price_per_gallon,number_of_gallons): paint_cost = price_per_gallon * number_of_gallons return paint_cost def calculate_labor_charge(hours): labor_charges = hours * cost_per_hour return labor_charges def calculate_overal_total_cost(paint_cost,labour_charges): total_cost = paint_cost + labour_charges return total_cost main()
cost_per_hour = 35.0 base_hours = 8 def main(): square_feet = float(input('Enter the number of square feet to be painted: ')) price_per_gallon = float(input('Enter the price of a paint per a gallon: ')) number_of_gallons = calculates_number_of_gallons(square_feet) hours_required = calculates_hours_required(square_feet) paint_cost = calculate_paint_cost(price_per_gallon, number_of_gallons) labor_charges = calculate_labor_charge(hours_required) grand_total = calculate_overal_total_cost(paint_cost, labor_charges) print('\nThe number of gallons of paint required = ', format(number_of_gallons, '.2f'), ' gallons\nThe hours of labor required = ', format(hours_required, '.2f'), ' hours\nThe total cost of the paint = $', format(paint_cost, ',.2f'), '\nThe labor charges = $', format(labor_charges, ',.2f'), '\nThe total cost of the paint job = $', format(grand_total, ',.2f'), sep='') def calculates_number_of_gallons(square_feet): total_gallons = square_feet / 112 return total_gallons def calculates_hours_required(square_feet): hours = square_feet * base_hours / 112 return hours def calculate_paint_cost(price_per_gallon, number_of_gallons): paint_cost = price_per_gallon * number_of_gallons return paint_cost def calculate_labor_charge(hours): labor_charges = hours * cost_per_hour return labor_charges def calculate_overal_total_cost(paint_cost, labour_charges): total_cost = paint_cost + labour_charges return total_cost main()
# spam.py print('imported spam') def foo(): print('spam.foo') def bar(): print('spam.bar')
print('imported spam') def foo(): print('spam.foo') def bar(): print('spam.bar')
# https://leetcode.com/problems/largest-rectangle-in-histogram class Solution: def largestRectangleArea(self, heights): if not heights: return 0 st = [0] idx = 1 ans = 0 while idx < len(heights): while heights[idx] < heights[st[-1]]: if len(st) == 1: l_idx = st.pop(-1) ans = max(ans, idx * heights[l_idx]) break l_idx = st.pop(-1) ans = max(ans, (idx - (st[-1] + 1)) * heights[l_idx]) st.append(idx) idx += 1 while 1 < len(st): l_idx = st.pop(-1) ans = max(ans, (len(heights) - (st[-1] + 1)) * heights[l_idx]) ans = max(ans, heights[st[0]] * len(heights)) return ans
class Solution: def largest_rectangle_area(self, heights): if not heights: return 0 st = [0] idx = 1 ans = 0 while idx < len(heights): while heights[idx] < heights[st[-1]]: if len(st) == 1: l_idx = st.pop(-1) ans = max(ans, idx * heights[l_idx]) break l_idx = st.pop(-1) ans = max(ans, (idx - (st[-1] + 1)) * heights[l_idx]) st.append(idx) idx += 1 while 1 < len(st): l_idx = st.pop(-1) ans = max(ans, (len(heights) - (st[-1] + 1)) * heights[l_idx]) ans = max(ans, heights[st[0]] * len(heights)) return ans
# Las tuplas no son mutables nombres = ("Ana", "Maria", "Rodrigo") try: nombres.append("Anita") except: print("No se puede nombres.append('Anita')") try: nombres[0]=("Anita") except: print("No se puede nombres[0]=('Anita')")
nombres = ('Ana', 'Maria', 'Rodrigo') try: nombres.append('Anita') except: print("No se puede nombres.append('Anita')") try: nombres[0] = 'Anita' except: print("No se puede nombres[0]=('Anita')")
""" Python program to find the largest element and its location. """ def largest_element(a, loc = False): """ Return the largest element of a sequence a. """ try: maxval = a[0] location = 0 for (i,e) in enumerate(a): if e > maxval: maxval = e location = i if loc == True: return maxval, location else: return maxval except ValueError: return "Value Error" except TypeError: return "Type error, my dude. You can't compare those." except: return "Unforseen error! What did you do?" if __name__ == "__main__": a = ["a","b","c",2,1] print("Largest element is {:}".format(largest_element(a, loc=True)))
""" Python program to find the largest element and its location. """ def largest_element(a, loc=False): """ Return the largest element of a sequence a. """ try: maxval = a[0] location = 0 for (i, e) in enumerate(a): if e > maxval: maxval = e location = i if loc == True: return (maxval, location) else: return maxval except ValueError: return 'Value Error' except TypeError: return "Type error, my dude. You can't compare those." except: return 'Unforseen error! What did you do?' if __name__ == '__main__': a = ['a', 'b', 'c', 2, 1] print('Largest element is {:}'.format(largest_element(a, loc=True)))
def check(exampleGraph,startPoint,endPoint): global currentPath global final global string if bool(currentPath) == False: currentPath.append(startPoint) for p in exampleGraph: if p[0] == currentPath[-1]: if p[1] not in currentPath: currentPath.append(p[1]) if p[1] == endPoint: for i in currentPath: string += str(i) final.append(string) string = '' currentPath.pop() else: check(exampleGraph,startPoint,endPoint) currentPath.pop() else: for p in exampleGraph: if p[0] == currentPath[-1]: if p[1] not in currentPath: currentPath.append(p[1]) if currentPath[-1] == endPoint: for i in currentPath: string += str(i) final.append(string) string = '' currentPath.pop() else: check(exampleGraph,startPoint,endPoint) currentPath.pop() def finalCheck(exampleGraph,startPoint,endPoint): global finalfinal global currentPath global final global string finalfinal = [] final = [] currentPath = [] string = '' check(exampleGraph,startPoint,endPoint) for p in range(len(final)): pastPoint = final[p][0] currentRoad = '' finalfinal.append([]) for i in range(1,len(final[p])): currentRoad = pastPoint + final[p][i] pastPoint = final[p][i] finalfinal[p].append(currentRoad) return finalfinal #~~~~~~~~~~~~~~~~~~~~~~~~~let's see how it works for test~~~~~~~~~~~~~~~~~~~~~# # exampleGraph = ['ae','ab','ac','ad','cd','db','cb'] # print(finalCheck(exampleGraph,'a','b')) # # outPut ---> [['ab'], ['ac', 'cd', 'db'], ['ac', 'cb'], ['ad', 'db']] #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
def check(exampleGraph, startPoint, endPoint): global currentPath global final global string if bool(currentPath) == False: currentPath.append(startPoint) for p in exampleGraph: if p[0] == currentPath[-1]: if p[1] not in currentPath: currentPath.append(p[1]) if p[1] == endPoint: for i in currentPath: string += str(i) final.append(string) string = '' currentPath.pop() else: check(exampleGraph, startPoint, endPoint) currentPath.pop() else: for p in exampleGraph: if p[0] == currentPath[-1]: if p[1] not in currentPath: currentPath.append(p[1]) if currentPath[-1] == endPoint: for i in currentPath: string += str(i) final.append(string) string = '' currentPath.pop() else: check(exampleGraph, startPoint, endPoint) currentPath.pop() def final_check(exampleGraph, startPoint, endPoint): global finalfinal global currentPath global final global string finalfinal = [] final = [] current_path = [] string = '' check(exampleGraph, startPoint, endPoint) for p in range(len(final)): past_point = final[p][0] current_road = '' finalfinal.append([]) for i in range(1, len(final[p])): current_road = pastPoint + final[p][i] past_point = final[p][i] finalfinal[p].append(currentRoad) return finalfinal
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return a boolean def hasCycle(self, head): d = dict() h = head while h != None: if h in d: return True else: d[h] = 1 h = h.next return False #another # class Solution: # # @param head, a ListNode # # @return a boolean # def hasCycle(self, head): # if not head: # return False # # slow = fast = head # while fast and fast.next: # slow = slow.next # fast = fast.next.next # if slow is fast: # return True # # return False
class Solution: def has_cycle(self, head): d = dict() h = head while h != None: if h in d: return True else: d[h] = 1 h = h.next return False
# Simon says # Do you know the game "Simon says?" The # instructor, "Simon", says what the players should # do, e.g. "jump in the air" or "close your eyes". The # players should follow the instructions only if the # phrase starts with "Simon says". Now let's # implement a digital version of this game! We will # modify it a bit: the correct instructions may not only # start but also end with the words "Simon says". # But be careful, instructions can be only at the # beginning, or at the end, but not in the middle! # Write a function that takes a string with # instructions: if it starts or ends with the words # "Simon says", your function should return the # string "I ", plus what you would do: the # instructions themselves. Otherwise, return "I # won't do it!". # You are NOT supposed to handle input or call your # function, just implement it. def what_to_do(instructions): return "I " + instructions.replace("Simon says", "").strip(" ") if instructions.startswith("Simon says") or instructions.endswith("Simon says") else "I won't do it!" print(what_to_do("Simon says make a wish"))
def what_to_do(instructions): return 'I ' + instructions.replace('Simon says', '').strip(' ') if instructions.startswith('Simon says') or instructions.endswith('Simon says') else "I won't do it!" print(what_to_do('Simon says make a wish'))
def test_get_atom1(case_data): """ Test :meth:`.Bond.get_atom1`. Parameters ---------- case_data : :class:`.CaseData` A test case. Holds the bond to test and the correct *atom1*. Returns ------- None : :class:`NoneType` """ assert case_data.bond.get_atom1() is case_data.atom1
def test_get_atom1(case_data): """ Test :meth:`.Bond.get_atom1`. Parameters ---------- case_data : :class:`.CaseData` A test case. Holds the bond to test and the correct *atom1*. Returns ------- None : :class:`NoneType` """ assert case_data.bond.get_atom1() is case_data.atom1
# lec10.3-binary_search.py # Binary Search # Can we do better than O(len(L)) for search? # If know nothing about values of elements in list, then no # Worst case have to look at every values # What if list is ordered? Suppose elements are sorted? # Example of searching an ordered list def search(L, e): for i in range (len(L)): if L[i] == e: return True # if element in list is bigger than item looking for, # know that element is not in an ordered list, return False # Improves complexity, but worst case still need to look at # every element if L[i] > e: return False return False # Use binary search to create a divide and conquer algorithm # Pick an index i that divides list in half # if L[i] == e, then found value # If not, ask if L[i] larger or smaller, set to new i def search(L, e): def bSearch(L, e, low, high): if high == low: return L[low] == c mid = low + int((high - low)/2) if L[mid] == e: return True if L[mid] > e: # Incorrect line from slides, corrected below # return bSearch(L, e, low, mid - 1) # If value we are seaching for is less than curent value, # set a new range from low to mid return bSearch(L, e, low, mid) else: # Otherwise, if value search for is higher, then a new # range from mid + 1 (so we don't look at same value again, to high) return bSearch(l, e, mid + 1, high) # If list is empty, return False if len(L) == 0: return False # Otherwise, call bSearch, low = 0, high set to len(L) - 1 else: return bSearch(L, e, 0, len(L) - 1) """ Analyzing binary search Does the recursion halt? - Decrementing function 1. Maps values to which formal parameters are bound to non-negative integer 2. When value <= 0, recursion terminates 3. For each recursive call, value of function is strictly less then value on entry to instance of function - Here function is high - low - At least 0 first time called (1) - When exactly 0, no recursive calls, returns (2) - Otherwise, halt or recursively call with value halved (3) What is complexity? - How many recursive calls? (work within each call is constant) - How many times can we divide high - 1ow in half before reaches 0? - log2 (high - low) - Thus search complexity is O(log(len(L))) Is a very efficient algorithm, much better than linear """
def search(L, e): for i in range(len(L)): if L[i] == e: return True if L[i] > e: return False return False def search(L, e): def b_search(L, e, low, high): if high == low: return L[low] == c mid = low + int((high - low) / 2) if L[mid] == e: return True if L[mid] > e: return b_search(L, e, low, mid) else: return b_search(l, e, mid + 1, high) if len(L) == 0: return False else: return b_search(L, e, 0, len(L) - 1) '\nAnalyzing binary search\n Does the recursion halt?\n - Decrementing function\n 1. Maps values to which formal parameters are bound to\n non-negative integer\n 2. When value <= 0, recursion terminates\n 3. For each recursive call, value of function is strictly less then\n value on entry to instance of function\n - Here function is high - low\n - At least 0 first time called (1)\n - When exactly 0, no recursive calls, returns (2)\n - Otherwise, halt or recursively call with value halved (3)\n\n What is complexity?\n - How many recursive calls? (work within each call\n is constant)\n - How many times can we divide high - 1ow in\n half before reaches 0?\n - log2 (high - low)\n - Thus search complexity is O(log(len(L)))\n\n Is a very efficient algorithm, much better than linear\n'
class OutputHelper: colors = { 'default_foreground': 39, 'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36, 'light_gray': 37, 'dark_gray': 90, 'light_red': 91, 'light_green': 92, 'light_yellow': 93, 'light_blue': 94, 'light_magenta': 95, 'light_cyan': 96, 'white': 97, } @staticmethod def colorize(text, color): if color in OutputHelper.colors: return "\033[" + str(OutputHelper.colors[color]) + "m" + text + "\033[0m" return text
class Outputhelper: colors = {'default_foreground': 39, 'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36, 'light_gray': 37, 'dark_gray': 90, 'light_red': 91, 'light_green': 92, 'light_yellow': 93, 'light_blue': 94, 'light_magenta': 95, 'light_cyan': 96, 'white': 97} @staticmethod def colorize(text, color): if color in OutputHelper.colors: return '\x1b[' + str(OutputHelper.colors[color]) + 'm' + text + '\x1b[0m' return text
# Determine if String Halves Are Alike # Runtime: 39 ms, faster than 82.91% of Python3 online submissions for Determine if String Halves Are Alike. # Memory Usage: 13.8 MB, less than 98.41% of Python3 online submissions for Determine if String Halves Are Alike. # https://leetcode.com/submissions/detail/714796669/ class Solution: def halvesAreAlike(self, s): return len([char for char in s[:len(s)//2] if char.lower() in "aeiou"]) == len([char for char in s[len(s)//2:] if char.lower() in "aeiou"]) print(Solution().halvesAreAlike("book"))
class Solution: def halves_are_alike(self, s): return len([char for char in s[:len(s) // 2] if char.lower() in 'aeiou']) == len([char for char in s[len(s) // 2:] if char.lower() in 'aeiou']) print(solution().halvesAreAlike('book'))
class Solution: # @param A : list of integers # @return a list of list of integers def twosum(self, arr, index, target): i = index j = len(arr) - 1 while i<j: if arr[i] + arr[j] == target: temp = [arr[index-1], arr[i], arr[j]] if len(self.res)>0: if self.res[0] != temp: self.res.insert(0, temp) else: self.res.insert(0, temp) i += 1 j -= 1 elif arr[i] + arr[j] < target: i += 1 else: j -= 1 def threeSum(self, arr): self.res = [] arr.sort() for i in range(len(arr)-2): if (i==0) or (i and arr[i] != arr[i-1]): self.twosum(arr, i+1, -arr[i]) return self.res if __name__ == '__main__': arr = [-1, 0, 1, 2, -1, -4] sol = Solution() print(sol.threeSum(arr))
class Solution: def twosum(self, arr, index, target): i = index j = len(arr) - 1 while i < j: if arr[i] + arr[j] == target: temp = [arr[index - 1], arr[i], arr[j]] if len(self.res) > 0: if self.res[0] != temp: self.res.insert(0, temp) else: self.res.insert(0, temp) i += 1 j -= 1 elif arr[i] + arr[j] < target: i += 1 else: j -= 1 def three_sum(self, arr): self.res = [] arr.sort() for i in range(len(arr) - 2): if i == 0 or (i and arr[i] != arr[i - 1]): self.twosum(arr, i + 1, -arr[i]) return self.res if __name__ == '__main__': arr = [-1, 0, 1, 2, -1, -4] sol = solution() print(sol.threeSum(arr))
""" Very simple, given a number, find its opposite. Examples: 1: -1 14: -14 -34: 34 """ # OPTION 1 # def opposite(number): # return number - number * 2 # OPTION 2 def opposite(number): return -number print(opposite(1))
""" Very simple, given a number, find its opposite. Examples: 1: -1 14: -14 -34: 34 """ def opposite(number): return -number print(opposite(1))
#!/usr/bin/env python # Settings for synthesis.py (test cases) # Input files Processing path INPUTFILES_PATH = "/home/user/Documents/Development/AlexandriaConsulting/repos/trunk/synthesis/Staging" OUTPUTFILES_PATH = "/home/user/Documents/Development/AlexandriaConsulting/repos/trunk/synthesis/Staging" TEST_FILE = "anyfile" # Validation and processing of XML files XML_FILE_VALID = "Example_HUD_HMIS_2_8_Instance.xml" XML_FILE_INVALID = "coastal_sheila_invalid.xml" XML_FILE_MALFORMED = "coastal_sheila_malformed.xml" # Encryption Tests XML_ENCRYPTED_FILE = "BASE_Example_HUD_HMIS_2_8_Instance.xml.pgp" XML_DECRYPTED_FILE = "BASE_Example_HUD_HMIS_2_8_Instance.xml" XML_ENCRYPT_FINGERPRINT = "97A798CF9E8D9F470292975E70DE787C6B57800F" XML_DECRYPT_PASSPHRASE = "passwordlaumeyer#"
inputfiles_path = '/home/user/Documents/Development/AlexandriaConsulting/repos/trunk/synthesis/Staging' outputfiles_path = '/home/user/Documents/Development/AlexandriaConsulting/repos/trunk/synthesis/Staging' test_file = 'anyfile' xml_file_valid = 'Example_HUD_HMIS_2_8_Instance.xml' xml_file_invalid = 'coastal_sheila_invalid.xml' xml_file_malformed = 'coastal_sheila_malformed.xml' xml_encrypted_file = 'BASE_Example_HUD_HMIS_2_8_Instance.xml.pgp' xml_decrypted_file = 'BASE_Example_HUD_HMIS_2_8_Instance.xml' xml_encrypt_fingerprint = '97A798CF9E8D9F470292975E70DE787C6B57800F' xml_decrypt_passphrase = 'passwordlaumeyer#'
""" Simple Utilities. """ def _mod(_dividend: int, _divisor: int) -> int: """ Computes the modulo of the given values. _dividend % _divisor :param _dividend: The value of the dividend. :param _divisor: The value of the divisor. :return: The Modulo. """ _q = (_dividend // _divisor) _d = _q * _divisor return _dividend - _d def _is_prime(_number: int) -> bool: """ Checks if a given number is a prime number. :param _number: The value to be tested. :return: True if the given number is prime number, False otherwise. """ if _number < 2: return False for _x in range(2, _number): if _mod(_number, _x) == 0: return False return True def _ascii(_message: str) -> list: """ Computes and returns the ascii list of of given the given string. :param _message: The string whose ascii values are needed. :return: The list of ascii values. """ return [ord(__c) for __c in _message] def _from_ascii(_message: list) -> str: """ Computes and returns the characters of the given ascii values. :param _message: A list of ascii values. :return: The string message """ return "".join(chr(__i) for __i in _message) def _split(_message: str) -> list: """ Splits the given string. :param _message: The string to be split. :return: The list of values. """ if _message.find('-') > 0: _m = _message.split('-') _m = [int(__i) for __i in _m] else: _m = [int(_message)] return _m
""" Simple Utilities. """ def _mod(_dividend: int, _divisor: int) -> int: """ Computes the modulo of the given values. _dividend % _divisor :param _dividend: The value of the dividend. :param _divisor: The value of the divisor. :return: The Modulo. """ _q = _dividend // _divisor _d = _q * _divisor return _dividend - _d def _is_prime(_number: int) -> bool: """ Checks if a given number is a prime number. :param _number: The value to be tested. :return: True if the given number is prime number, False otherwise. """ if _number < 2: return False for _x in range(2, _number): if _mod(_number, _x) == 0: return False return True def _ascii(_message: str) -> list: """ Computes and returns the ascii list of of given the given string. :param _message: The string whose ascii values are needed. :return: The list of ascii values. """ return [ord(__c) for __c in _message] def _from_ascii(_message: list) -> str: """ Computes and returns the characters of the given ascii values. :param _message: A list of ascii values. :return: The string message """ return ''.join((chr(__i) for __i in _message)) def _split(_message: str) -> list: """ Splits the given string. :param _message: The string to be split. :return: The list of values. """ if _message.find('-') > 0: _m = _message.split('-') _m = [int(__i) for __i in _m] else: _m = [int(_message)] return _m
# Variables can store data a = 10 # Assigns the integer 10 to the variable a # In Python variables do not have one fixed type a = "hello" # Assigns the string "hello" to the variable a print(a) # Prints the value of a which is now "hello"
a = 10 a = 'hello' print(a)
#!/usr/bin/env python3 poly_derivative = __import__('10-matisse').poly_derivative poly = [5, 3, 0, 1] print(poly_derivative(poly))
poly_derivative = __import__('10-matisse').poly_derivative poly = [5, 3, 0, 1] print(poly_derivative(poly))
for x in range(16): with open(f'..\\data\\cpu\\functions\\opcode_switch\\opcode_8xx4\\opcode_8xx4_{x}.mcfunction', 'w') as f: for i in range(16): f.write(f'execute if score Global PC_nibble_3 matches {i} run scoreboard players operation Global V{hex(x)[2:].upper()} += Global V{hex(i)[2:].upper()}\n') f.write(f'execute if score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players set Global VF 1\n' f'execute unless score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players set Global VF 0\n' f'execute if score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players remove Global V{hex(x)[2:].upper()} 256\n') with open('..\\data\\cpu\\functions\\opcode_switch\\opcode_8xx4.mcfunction', 'a') as f: for x in range(16): f.write(f'execute if score Global PC_nibble_2 matches {x} run function cpu:opcode_switch/opcode_8xx4/opcode_8xx4_{x}\n')
for x in range(16): with open(f'..\\data\\cpu\\functions\\opcode_switch\\opcode_8xx4\\opcode_8xx4_{x}.mcfunction', 'w') as f: for i in range(16): f.write(f'execute if score Global PC_nibble_3 matches {i} run scoreboard players operation Global V{hex(x)[2:].upper()} += Global V{hex(i)[2:].upper()}\n') f.write(f'execute if score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players set Global VF 1\nexecute unless score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players set Global VF 0\nexecute if score Global V{hex(x)[2:].upper()} matches 256.. run scoreboard players remove Global V{hex(x)[2:].upper()} 256\n') with open('..\\data\\cpu\\functions\\opcode_switch\\opcode_8xx4.mcfunction', 'a') as f: for x in range(16): f.write(f'execute if score Global PC_nibble_2 matches {x} run function cpu:opcode_switch/opcode_8xx4/opcode_8xx4_{x}\n')
valor = int(input()) contadorBixo = contadorCoelho = contadorRato = contadorSapo = 0 for c in range(0, valor): experiencia = str(input()) dividir = experiencia.split() quantidade = int(dividir[0]) tipo = dividir[1] if quantidade > 0 and 'C' in tipo: contadorCoelho += quantidade elif quantidade > 0 and 'R' in tipo: contadorRato += quantidade elif quantidade > 0 and 'S' in tipo: contadorSapo += quantidade contadorBixo = contadorCoelho + contadorRato + contadorSapo print(f'Total: {contadorBixo} cobaias') print(f'Total de coelhos: {contadorCoelho}') print(f'Total de ratos: {contadorRato}') print(f'Total de sapos: {contadorSapo}') print(f'Percentual de coelhos: {(contadorCoelho*100) / contadorBixo:.2f} %') print(f'Percentual de ratos: {(contadorRato*100) / contadorBixo:.2f} %') print(f'Percentual de sapos: {(contadorSapo*100) / contadorBixo:.2f} %')
valor = int(input()) contador_bixo = contador_coelho = contador_rato = contador_sapo = 0 for c in range(0, valor): experiencia = str(input()) dividir = experiencia.split() quantidade = int(dividir[0]) tipo = dividir[1] if quantidade > 0 and 'C' in tipo: contador_coelho += quantidade elif quantidade > 0 and 'R' in tipo: contador_rato += quantidade elif quantidade > 0 and 'S' in tipo: contador_sapo += quantidade contador_bixo = contadorCoelho + contadorRato + contadorSapo print(f'Total: {contadorBixo} cobaias') print(f'Total de coelhos: {contadorCoelho}') print(f'Total de ratos: {contadorRato}') print(f'Total de sapos: {contadorSapo}') print(f'Percentual de coelhos: {contadorCoelho * 100 / contadorBixo:.2f} %') print(f'Percentual de ratos: {contadorRato * 100 / contadorBixo:.2f} %') print(f'Percentual de sapos: {contadorSapo * 100 / contadorBixo:.2f} %')
class gamevals: def __init__(self): self.njp=["","Mark(merchant)","Precious Metal","George(knight)","Old Gem","Map","Gem of Man","Maria(Princess)","Herb","Mineral","Robin(thief)","Gem of Forest","Dragon","Dragon's Nail","Gem of Dragon","Gem of God","Gem of Sky","Gem of Earth","Coin","Vulture","Antique Merchant","Farmer","Priest","",""] self.plname=["Can't go","Entrance of The Town","Public Square","Antique Market","Inn","Highway","Highway","Entarnce of the Village","Vegitable Field","Farm House","Wilderness","Wilderness","Ruin","Wilderness","Cave","Highway","Entrance of the Mountain","Forest Path","Mountain Path","Pass","Shrine","Nest of Vulture","Cliff Path","Top of the Mountain","Forest","Forest","Forest","Forest","Forest","Forest","",""] """pos:99=hidden 50=players possesion""" self.pos=[0,15,99,4,99,99,99,18,99,99,29,99,14,99,99,99,99,99,99,21,3,9,20,0] self.mapfw=[0,5,0,0,2,6,15,0,0,0,0,13,11,14,0,24,17,18,0,22,0,0,23,0,25,29,28,0,0,0,0,0] self.maprt=[0,2,3,0,0,0,7,8,9,0,6,10,0,0,0,16,0,0,19,20,0,22,0,0,0,0,25,26,0,0,0,0] self.maplt=[0,0,1,2,0,0,10,6,7,8,11,0,0,0,0,0,15,0,0,18,19,0,21,0,0,26,27,0,0,0,0] self.mapbk=[0,0,4,0,0,1,5,0,0,0,0,12,0,11,13,6,0,16,17,0,0,0,19,22,15,24,0,0,26,25,0,0] self.person=[0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,1,1,1,0,0] self.pl=1 self.gold=0 self.gameflag=1 self.mapdisp=False def move(gs,func,dir): if func>0: print("You go "+str(dir)+".") gs.pl=func else: print("You can not go this direction.") return gs def search(gs): if gs.pl==28 and gs.pos[10]==50 and gs.pos[11]==99: print("Robin found a (Gem of forest).") gs.pos[11]=50 elif gs.pl==27 and gs.pos[7]==50 and gs.pos[8]==99: print("Maria found a (Herb).") gs.pos[8]=50 elif gs.pl==22 & gs.pos[9]==99: print("You found a piece of (Mineral).") gs.pos[9]=50 elif gs.pl==12 and gs.pos[10]==50 and gs.pos[4]==99: print("Robin found a (Old gem).") gs.pos[4]=50 elif gs.pl==12 and gs.pos[10]==50 and gs.pos[2]==99: print("Robin found a piece of (Precious matal).") gs.pos[2]=50 else: print("You can found nothing special.") if gs.pos[4]==50 and gs.pos[6]==50 and gs.pos[11]==50 and gs.pos[14]==50 and gs.pos[15]==50 and gs.pos[16]==50 and gs.pos[17]==50: print("You solve the game Anekgard!") gs.gameflag=0 return gs def report(gs): mes="Fellow:" for i in range(1,22): if gs.pos[i]==50 and gs.person[i]==1: mes=mes+ gs.njp[i]+" " print(mes) mes="Inventory:" for i in range(1,22): if gs.pos[i]==50 and gs.person[i]==0: mes=mes+gs.njp[i]+" " print(mes) mes="Coin " + str(gs.gold) +"" print(mes) return gs def map(gs): print("[ Map ]") print(" [North]:"+gs.plname[gs.mapfw[gs.pl]]) print("[West]:"+gs.plname[gs.maplt[gs.pl]]+" [East]:"+gs.plname[gs.maprt[gs.pl]]) print(" [South]:"+gs.plname[gs.mapbk[gs.pl]]) return gs def fight(gs): if gs.pl==14 and gs.pos[3]==50 and gs.pos[12]==14: print("Dragon flew away to avoid your attack.") print("It leaves a Nail of dragon and Gem of dragon.") gs.pos[12]=99 gs.pos[13]=50 gs.pos[14]=50 if gs.pl==14 and gs.pos[3]!=50: print("Enemy defences!") if gs.pl==21: print("Enemy defences!") if gs.pl==3 or gs.pl==9 or gs.pl==10 or gs.pl==4 and gs.pos[3]==4 or gs.pl==15 and gs.pos[1]==15 or gs.pl==29 and gs.pos[10]==29 or gs.pl==18 and gs.pos[7]==18: print("You don't permitted to attack an innocent people.") if gs.pos[4]==50 and gs.pos[6]==50 and gs.pos[11]==50 and gs.pos[14]==50 and gs.pos[15]==50 and gs.pos[16]==50 and gs.pos[17]==50: print("You solve game Anekgard!") gs.gameflag=0 return gs def talk(gs): if gs.pl==3 and gs.pos[2]==50: print("You sell a Precious metal.") gs.pos[2]=0 gs.gold=gs.gold+1 if gs.pl==3 and gs.pos[8]==50: print("You sell a Herb.") gs.pos[8]=0 gs.gold=gs.gold+1 if gs.pl==3 and gs.pos[9]==50: print("You sell a Mineral.") gs.pos[9]=0 gs.gold=gs.gold+1 if gs.pl==3 and gs.pos[13]==50: print("You sell a Nail of dragon.") gs.pos[13]=0 gs.gold=gs.gold+1 if gs.pl==3 and gs.pos[1]==50 and gs.pos[6]==99 and gs.gold>0 and gs.pos[1]==50: print("You get a Gem of man with Mark's negotiation.") gs.pos[6]=50 gs.gold=gs.gold-1 if gs.pl==4 and gs.pos[3]==4: print("George join you.") gs.pos[3]=50 if gs.pl==9 and gs.pos[17]==99 and gs.gold>0 and gs.pos[1]==50: print("You get a Gem of earth with Mark's negotiation.") gs.pos[17]=50 gs.gold=gs.gold-1 if gs.pl==15 and gs.pos[1]==15: print("Mark join you") gs.pos[1]=50 if gs.pl==18 and gs.pos[7]==18: print("Maria join you.") gs.pos[7]=50 if gs.pl==20 and gs.pos[15]==99 and gs.pos[7]==50: print("You get a Gem of god with Maria's negotiation.") gs.pos[15]=50 if gs.pl==21 and gs.pos[16]==99 and gs.pos[7]==50: print("You get a Gem of sky with Maria's negotiation.") gs.pos[16]=50 if gs.pl==29 and gs.pos[10]==29: print("Robin join you.") gs.pos[10]=50 if gs.pos[4]==50 and gs.pos[6]==50 and gs.pos[11]==50 and gs.pos[14]==50 and gs.pos[15]==50 and gs.pos[16]==50 and gs.pos[17]==50: print("You solve Game Anekgard !") gs.gameflag=0 return gs def cmdexe(gs,stginp): if stginp=="n": func=gs.mapfw[gs.pl] dir="north" gs=move(gs,func,dir) if stginp=="s": func=gs.mapbk[gs.pl] dir="south" gs=move(gs,func,dir) if stginp=="e": func=gs.maprt[gs.pl] dir="east" gs=move(gs,func,dir) if stginp=="w": func=gs.maplt[gs.pl] dir="west" gs=move(gs,func,dir) if stginp=="a": gs=fight(gs) if stginp=="r": gs=search(gs) if stginp=="t": gs=talk(gs) if stginp=="c": gs=report(gs) if stginp=="m": if gs.mapdisp==True: gs.mapdisp=False else: gs.mapdisp=True if stginp=="q": gs.gameflag=0 return gs def conds(gs): print("You are at the " + gs.plname[gs.pl]) for i in range(1,21): if gs.pos[i]==gs.pl: print("There is "+gs.njp[i] + "") mes="You can go [" if gs.mapfw[gs.pl]>0: mes+= "north " if gs.maprt[gs.pl]>0: mes+= "east " if gs.maplt[gs.pl]>0: mes+= "west " if gs.mapbk[gs.pl]>0: mes+= "south " mes=mes+"]" print(mes) gv=gamevals() while gv.gameflag==1: if gv.mapdisp==True: map(gv) conds(gv) print("command[nsew r:research a:attack t:talk c:condition m:map q:quit game]") inp=input(":") gv=cmdexe(gv,inp)
class Gamevals: def __init__(self): self.njp = ['', 'Mark(merchant)', 'Precious Metal', 'George(knight)', 'Old Gem', 'Map', 'Gem of Man', 'Maria(Princess)', 'Herb', 'Mineral', 'Robin(thief)', 'Gem of Forest', 'Dragon', "Dragon's Nail", 'Gem of Dragon', 'Gem of God', 'Gem of Sky', 'Gem of Earth', 'Coin', 'Vulture', 'Antique Merchant', 'Farmer', 'Priest', '', ''] self.plname = ["Can't go", 'Entrance of The Town', 'Public Square', 'Antique Market', 'Inn', 'Highway', 'Highway', 'Entarnce of the Village', 'Vegitable Field', 'Farm House', 'Wilderness', 'Wilderness', 'Ruin', 'Wilderness', 'Cave', 'Highway', 'Entrance of the Mountain', 'Forest Path', 'Mountain Path', 'Pass', 'Shrine', 'Nest of Vulture', 'Cliff Path', 'Top of the Mountain', 'Forest', 'Forest', 'Forest', 'Forest', 'Forest', 'Forest', '', ''] 'pos:99=hidden 50=players possesion' self.pos = [0, 15, 99, 4, 99, 99, 99, 18, 99, 99, 29, 99, 14, 99, 99, 99, 99, 99, 99, 21, 3, 9, 20, 0] self.mapfw = [0, 5, 0, 0, 2, 6, 15, 0, 0, 0, 0, 13, 11, 14, 0, 24, 17, 18, 0, 22, 0, 0, 23, 0, 25, 29, 28, 0, 0, 0, 0, 0] self.maprt = [0, 2, 3, 0, 0, 0, 7, 8, 9, 0, 6, 10, 0, 0, 0, 16, 0, 0, 19, 20, 0, 22, 0, 0, 0, 0, 25, 26, 0, 0, 0, 0] self.maplt = [0, 0, 1, 2, 0, 0, 10, 6, 7, 8, 11, 0, 0, 0, 0, 0, 15, 0, 0, 18, 19, 0, 21, 0, 0, 26, 27, 0, 0, 0, 0] self.mapbk = [0, 0, 4, 0, 0, 1, 5, 0, 0, 0, 0, 12, 0, 11, 13, 6, 0, 16, 17, 0, 0, 0, 19, 22, 15, 24, 0, 0, 26, 25, 0, 0] self.person = [0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0] self.pl = 1 self.gold = 0 self.gameflag = 1 self.mapdisp = False def move(gs, func, dir): if func > 0: print('You go ' + str(dir) + '.') gs.pl = func else: print('You can not go this direction.') return gs def search(gs): if gs.pl == 28 and gs.pos[10] == 50 and (gs.pos[11] == 99): print('Robin found a (Gem of forest).') gs.pos[11] = 50 elif gs.pl == 27 and gs.pos[7] == 50 and (gs.pos[8] == 99): print('Maria found a (Herb).') gs.pos[8] = 50 elif gs.pl == 22 & gs.pos[9] == 99: print('You found a piece of (Mineral).') gs.pos[9] = 50 elif gs.pl == 12 and gs.pos[10] == 50 and (gs.pos[4] == 99): print('Robin found a (Old gem).') gs.pos[4] = 50 elif gs.pl == 12 and gs.pos[10] == 50 and (gs.pos[2] == 99): print('Robin found a piece of (Precious matal).') gs.pos[2] = 50 else: print('You can found nothing special.') if gs.pos[4] == 50 and gs.pos[6] == 50 and (gs.pos[11] == 50) and (gs.pos[14] == 50) and (gs.pos[15] == 50) and (gs.pos[16] == 50) and (gs.pos[17] == 50): print('You solve the game Anekgard!') gs.gameflag = 0 return gs def report(gs): mes = 'Fellow:' for i in range(1, 22): if gs.pos[i] == 50 and gs.person[i] == 1: mes = mes + gs.njp[i] + ' ' print(mes) mes = 'Inventory:' for i in range(1, 22): if gs.pos[i] == 50 and gs.person[i] == 0: mes = mes + gs.njp[i] + ' ' print(mes) mes = 'Coin ' + str(gs.gold) + '' print(mes) return gs def map(gs): print('[ Map ]') print(' [North]:' + gs.plname[gs.mapfw[gs.pl]]) print('[West]:' + gs.plname[gs.maplt[gs.pl]] + ' [East]:' + gs.plname[gs.maprt[gs.pl]]) print(' [South]:' + gs.plname[gs.mapbk[gs.pl]]) return gs def fight(gs): if gs.pl == 14 and gs.pos[3] == 50 and (gs.pos[12] == 14): print('Dragon flew away to avoid your attack.') print('It leaves a Nail of dragon and Gem of dragon.') gs.pos[12] = 99 gs.pos[13] = 50 gs.pos[14] = 50 if gs.pl == 14 and gs.pos[3] != 50: print('Enemy defences!') if gs.pl == 21: print('Enemy defences!') if gs.pl == 3 or gs.pl == 9 or gs.pl == 10 or (gs.pl == 4 and gs.pos[3] == 4) or (gs.pl == 15 and gs.pos[1] == 15) or (gs.pl == 29 and gs.pos[10] == 29) or (gs.pl == 18 and gs.pos[7] == 18): print("You don't permitted to attack an innocent people.") if gs.pos[4] == 50 and gs.pos[6] == 50 and (gs.pos[11] == 50) and (gs.pos[14] == 50) and (gs.pos[15] == 50) and (gs.pos[16] == 50) and (gs.pos[17] == 50): print('You solve game Anekgard!') gs.gameflag = 0 return gs def talk(gs): if gs.pl == 3 and gs.pos[2] == 50: print('You sell a Precious metal.') gs.pos[2] = 0 gs.gold = gs.gold + 1 if gs.pl == 3 and gs.pos[8] == 50: print('You sell a Herb.') gs.pos[8] = 0 gs.gold = gs.gold + 1 if gs.pl == 3 and gs.pos[9] == 50: print('You sell a Mineral.') gs.pos[9] = 0 gs.gold = gs.gold + 1 if gs.pl == 3 and gs.pos[13] == 50: print('You sell a Nail of dragon.') gs.pos[13] = 0 gs.gold = gs.gold + 1 if gs.pl == 3 and gs.pos[1] == 50 and (gs.pos[6] == 99) and (gs.gold > 0) and (gs.pos[1] == 50): print("You get a Gem of man with Mark's negotiation.") gs.pos[6] = 50 gs.gold = gs.gold - 1 if gs.pl == 4 and gs.pos[3] == 4: print('George join you.') gs.pos[3] = 50 if gs.pl == 9 and gs.pos[17] == 99 and (gs.gold > 0) and (gs.pos[1] == 50): print("You get a Gem of earth with Mark's negotiation.") gs.pos[17] = 50 gs.gold = gs.gold - 1 if gs.pl == 15 and gs.pos[1] == 15: print('Mark join you') gs.pos[1] = 50 if gs.pl == 18 and gs.pos[7] == 18: print('Maria join you.') gs.pos[7] = 50 if gs.pl == 20 and gs.pos[15] == 99 and (gs.pos[7] == 50): print("You get a Gem of god with Maria's negotiation.") gs.pos[15] = 50 if gs.pl == 21 and gs.pos[16] == 99 and (gs.pos[7] == 50): print("You get a Gem of sky with Maria's negotiation.") gs.pos[16] = 50 if gs.pl == 29 and gs.pos[10] == 29: print('Robin join you.') gs.pos[10] = 50 if gs.pos[4] == 50 and gs.pos[6] == 50 and (gs.pos[11] == 50) and (gs.pos[14] == 50) and (gs.pos[15] == 50) and (gs.pos[16] == 50) and (gs.pos[17] == 50): print('You solve Game Anekgard !') gs.gameflag = 0 return gs def cmdexe(gs, stginp): if stginp == 'n': func = gs.mapfw[gs.pl] dir = 'north' gs = move(gs, func, dir) if stginp == 's': func = gs.mapbk[gs.pl] dir = 'south' gs = move(gs, func, dir) if stginp == 'e': func = gs.maprt[gs.pl] dir = 'east' gs = move(gs, func, dir) if stginp == 'w': func = gs.maplt[gs.pl] dir = 'west' gs = move(gs, func, dir) if stginp == 'a': gs = fight(gs) if stginp == 'r': gs = search(gs) if stginp == 't': gs = talk(gs) if stginp == 'c': gs = report(gs) if stginp == 'm': if gs.mapdisp == True: gs.mapdisp = False else: gs.mapdisp = True if stginp == 'q': gs.gameflag = 0 return gs def conds(gs): print('You are at the ' + gs.plname[gs.pl]) for i in range(1, 21): if gs.pos[i] == gs.pl: print('There is ' + gs.njp[i] + '') mes = 'You can go [' if gs.mapfw[gs.pl] > 0: mes += 'north ' if gs.maprt[gs.pl] > 0: mes += 'east ' if gs.maplt[gs.pl] > 0: mes += 'west ' if gs.mapbk[gs.pl] > 0: mes += 'south ' mes = mes + ']' print(mes) gv = gamevals() while gv.gameflag == 1: if gv.mapdisp == True: map(gv) conds(gv) print('command[nsew r:research a:attack t:talk c:condition m:map q:quit game]') inp = input(':') gv = cmdexe(gv, inp)
""" String utilities. """ def camelize(value): """ Return the camel-cased version of a string. Used for analysis class names. """ def _camelcase(): while True: yield type(value).capitalize c = _camelcase() return "".join(next(c)(x) if x else '_' for x in value.split("_"))
""" String utilities. """ def camelize(value): """ Return the camel-cased version of a string. Used for analysis class names. """ def _camelcase(): while True: yield type(value).capitalize c = _camelcase() return ''.join((next(c)(x) if x else '_' for x in value.split('_')))
class Project: def __init__(self, id=None, x=None): self.x = x self.id = id def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.x == other.x
class Project: def __init__(self, id=None, x=None): self.x = x self.id = id def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.x == other.x
class bot_constant: bot_version: str = "0.0.1" bot_token: str = "<Replace token in here>" bot_author: str = "NgLam2911" bot_prefix: str = "?" bot_description: str = "Just a very simple discord bot that say Hi if you say Hello..."
class Bot_Constant: bot_version: str = '0.0.1' bot_token: str = '<Replace token in here>' bot_author: str = 'NgLam2911' bot_prefix: str = '?' bot_description: str = 'Just a very simple discord bot that say Hi if you say Hello...'
# # PySNMP MIB module HPN-ICF-RS485-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-RS485-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:29:05 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, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion") hpnicfCommon, = mibBuilder.importSymbols("HPN-ICF-OID-MIB", "hpnicfCommon") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") InetAddressType, InetAddress = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddressType", "InetAddress") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") ObjectIdentity, TimeTicks, NotificationType, Integer32, IpAddress, Bits, Unsigned32, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Gauge32, iso, Counter32, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "TimeTicks", "NotificationType", "Integer32", "IpAddress", "Bits", "Unsigned32", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Gauge32", "iso", "Counter32", "MibIdentifier") DisplayString, TextualConvention, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "RowStatus") hpnicfRS485 = ModuleIdentity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109)) if mibBuilder.loadTexts: hpnicfRS485.setLastUpdated('200910210000Z') if mibBuilder.loadTexts: hpnicfRS485.setOrganization('') hpnicfRS485Properties = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1)) hpnicfRS485PropertiesTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1), ) if mibBuilder.loadTexts: hpnicfRS485PropertiesTable.setStatus('current') hpnicfRS485PropertiesEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: hpnicfRS485PropertiesEntry.setStatus('current') hpnicfRS485RawSessionNextIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 64))).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485RawSessionNextIndex.setStatus('current') hpnicfRS485BaudRate = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("bautRate300", 1), ("bautRate600", 2), ("bautRate1200", 3), ("bautRate2400", 4), ("bautRate4800", 5), ("bautRate9600", 6), ("bautRate19200", 7), ("bautRate38400", 8), ("bautRate57600", 9), ("bautRate115200", 10))).clone('bautRate9600')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485BaudRate.setStatus('current') hpnicfRS485DataBits = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("five", 1), ("six", 2), ("seven", 3), ("eight", 4))).clone('eight')).setUnits('bit').setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485DataBits.setStatus('current') hpnicfRS485Parity = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("none", 1), ("odd", 2), ("even", 3), ("mark", 4), ("space", 5))).clone('none')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485Parity.setStatus('current') hpnicfRS485StopBits = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("one", 1), ("two", 2), ("oneAndHalf", 3))).clone('one')).setUnits('bit').setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485StopBits.setStatus('current') hpnicfRS485FlowControl = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("hardware", 2), ("xonOrxoff", 3))).clone('none')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485FlowControl.setStatus('current') hpnicfRS485TXCharacters = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485TXCharacters.setStatus('current') hpnicfRS485RXCharacters = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485RXCharacters.setStatus('current') hpnicfRS485TXErrCharacters = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 9), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485TXErrCharacters.setStatus('current') hpnicfRS485RXErrCharacters = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 10), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485RXErrCharacters.setStatus('current') hpnicfRS485ResetCharacters = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("counting", 1), ("clear", 2))).clone('counting')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485ResetCharacters.setStatus('current') hpnicfRS485RawSessions = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2)) hpnicfRS485RawSessionSummary = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 1)) hpnicfRS485RawSessionMaxNum = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 64))).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485RawSessionMaxNum.setStatus('current') hpnicfRS485RawSessionTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2), ) if mibBuilder.loadTexts: hpnicfRS485RawSessionTable.setStatus('current') hpnicfRS485RawSessionEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "HPN-ICF-RS485-MIB", "hpnicfRS485SessionIndex")) if mibBuilder.loadTexts: hpnicfRS485RawSessionEntry.setStatus('current') hpnicfRS485SessionIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 64))) if mibBuilder.loadTexts: hpnicfRS485SessionIndex.setStatus('current') hpnicfRS485SessionType = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("udp", 1), ("tcpClient", 2), ("tcpServer", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485SessionType.setStatus('current') hpnicfRS485SessionAddType = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 3), InetAddressType().clone('ipv4')).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpnicfRS485SessionAddType.setStatus('current') hpnicfRS485SessionRemoteIP = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 4), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hpnicfRS485SessionRemoteIP.setStatus('current') hpnicfRS485SessionRemotePort = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1024, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hpnicfRS485SessionRemotePort.setStatus('current') hpnicfRS485SessionLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1024, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hpnicfRS485SessionLocalPort.setStatus('current') hpnicfRS485SessionStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hpnicfRS485SessionStatus.setStatus('current') hpnicfRS485RawSessionErrInfoTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3), ) if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfoTable.setStatus('current') hpnicfRS485RawSessionErrInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "HPN-ICF-RS485-MIB", "hpnicfRS485SessionIndex")) if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfoEntry.setStatus('current') hpnicfRS485RawSessionErrInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3, 1, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfo.setStatus('current') mibBuilder.exportSymbols("HPN-ICF-RS485-MIB", hpnicfRS485RawSessionSummary=hpnicfRS485RawSessionSummary, hpnicfRS485StopBits=hpnicfRS485StopBits, hpnicfRS485RawSessionEntry=hpnicfRS485RawSessionEntry, hpnicfRS485RawSessionErrInfoTable=hpnicfRS485RawSessionErrInfoTable, hpnicfRS485RawSessions=hpnicfRS485RawSessions, hpnicfRS485=hpnicfRS485, PYSNMP_MODULE_ID=hpnicfRS485, hpnicfRS485SessionRemotePort=hpnicfRS485SessionRemotePort, hpnicfRS485ResetCharacters=hpnicfRS485ResetCharacters, hpnicfRS485SessionLocalPort=hpnicfRS485SessionLocalPort, hpnicfRS485RXErrCharacters=hpnicfRS485RXErrCharacters, hpnicfRS485RawSessionTable=hpnicfRS485RawSessionTable, hpnicfRS485RXCharacters=hpnicfRS485RXCharacters, hpnicfRS485SessionStatus=hpnicfRS485SessionStatus, hpnicfRS485TXErrCharacters=hpnicfRS485TXErrCharacters, hpnicfRS485PropertiesTable=hpnicfRS485PropertiesTable, hpnicfRS485PropertiesEntry=hpnicfRS485PropertiesEntry, hpnicfRS485RawSessionErrInfo=hpnicfRS485RawSessionErrInfo, hpnicfRS485Parity=hpnicfRS485Parity, hpnicfRS485TXCharacters=hpnicfRS485TXCharacters, hpnicfRS485RawSessionNextIndex=hpnicfRS485RawSessionNextIndex, hpnicfRS485RawSessionMaxNum=hpnicfRS485RawSessionMaxNum, hpnicfRS485Properties=hpnicfRS485Properties, hpnicfRS485SessionRemoteIP=hpnicfRS485SessionRemoteIP, hpnicfRS485SessionType=hpnicfRS485SessionType, hpnicfRS485SessionAddType=hpnicfRS485SessionAddType, hpnicfRS485BaudRate=hpnicfRS485BaudRate, hpnicfRS485DataBits=hpnicfRS485DataBits, hpnicfRS485FlowControl=hpnicfRS485FlowControl, hpnicfRS485RawSessionErrInfoEntry=hpnicfRS485RawSessionErrInfoEntry, hpnicfRS485SessionIndex=hpnicfRS485SessionIndex)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsUnion') (hpnicf_common,) = mibBuilder.importSymbols('HPN-ICF-OID-MIB', 'hpnicfCommon') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (inet_address_type, inet_address) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddressType', 'InetAddress') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (object_identity, time_ticks, notification_type, integer32, ip_address, bits, unsigned32, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, gauge32, iso, counter32, mib_identifier) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'TimeTicks', 'NotificationType', 'Integer32', 'IpAddress', 'Bits', 'Unsigned32', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'Gauge32', 'iso', 'Counter32', 'MibIdentifier') (display_string, textual_convention, row_status) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention', 'RowStatus') hpnicf_rs485 = module_identity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109)) if mibBuilder.loadTexts: hpnicfRS485.setLastUpdated('200910210000Z') if mibBuilder.loadTexts: hpnicfRS485.setOrganization('') hpnicf_rs485_properties = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1)) hpnicf_rs485_properties_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1)) if mibBuilder.loadTexts: hpnicfRS485PropertiesTable.setStatus('current') hpnicf_rs485_properties_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: hpnicfRS485PropertiesEntry.setStatus('current') hpnicf_rs485_raw_session_next_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 64))).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485RawSessionNextIndex.setStatus('current') hpnicf_rs485_baud_rate = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('bautRate300', 1), ('bautRate600', 2), ('bautRate1200', 3), ('bautRate2400', 4), ('bautRate4800', 5), ('bautRate9600', 6), ('bautRate19200', 7), ('bautRate38400', 8), ('bautRate57600', 9), ('bautRate115200', 10))).clone('bautRate9600')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485BaudRate.setStatus('current') hpnicf_rs485_data_bits = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('five', 1), ('six', 2), ('seven', 3), ('eight', 4))).clone('eight')).setUnits('bit').setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485DataBits.setStatus('current') hpnicf_rs485_parity = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('none', 1), ('odd', 2), ('even', 3), ('mark', 4), ('space', 5))).clone('none')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485Parity.setStatus('current') hpnicf_rs485_stop_bits = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('one', 1), ('two', 2), ('oneAndHalf', 3))).clone('one')).setUnits('bit').setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485StopBits.setStatus('current') hpnicf_rs485_flow_control = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('none', 1), ('hardware', 2), ('xonOrxoff', 3))).clone('none')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485FlowControl.setStatus('current') hpnicf_rs485_tx_characters = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 7), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485TXCharacters.setStatus('current') hpnicf_rs485_rx_characters = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485RXCharacters.setStatus('current') hpnicf_rs485_tx_err_characters = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 9), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485TXErrCharacters.setStatus('current') hpnicf_rs485_rx_err_characters = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 10), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485RXErrCharacters.setStatus('current') hpnicf_rs485_reset_characters = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 1, 1, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('counting', 1), ('clear', 2))).clone('counting')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485ResetCharacters.setStatus('current') hpnicf_rs485_raw_sessions = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2)) hpnicf_rs485_raw_session_summary = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 1)) hpnicf_rs485_raw_session_max_num = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 64))).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485RawSessionMaxNum.setStatus('current') hpnicf_rs485_raw_session_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2)) if mibBuilder.loadTexts: hpnicfRS485RawSessionTable.setStatus('current') hpnicf_rs485_raw_session_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'), (0, 'HPN-ICF-RS485-MIB', 'hpnicfRS485SessionIndex')) if mibBuilder.loadTexts: hpnicfRS485RawSessionEntry.setStatus('current') hpnicf_rs485_session_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 64))) if mibBuilder.loadTexts: hpnicfRS485SessionIndex.setStatus('current') hpnicf_rs485_session_type = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('udp', 1), ('tcpClient', 2), ('tcpServer', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485SessionType.setStatus('current') hpnicf_rs485_session_add_type = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 3), inet_address_type().clone('ipv4')).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpnicfRS485SessionAddType.setStatus('current') hpnicf_rs485_session_remote_ip = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 4), inet_address()).setMaxAccess('readcreate') if mibBuilder.loadTexts: hpnicfRS485SessionRemoteIP.setStatus('current') hpnicf_rs485_session_remote_port = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(1024, 65535))).setMaxAccess('readcreate') if mibBuilder.loadTexts: hpnicfRS485SessionRemotePort.setStatus('current') hpnicf_rs485_session_local_port = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(1024, 65535))).setMaxAccess('readcreate') if mibBuilder.loadTexts: hpnicfRS485SessionLocalPort.setStatus('current') hpnicf_rs485_session_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 2, 1, 7), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: hpnicfRS485SessionStatus.setStatus('current') hpnicf_rs485_raw_session_err_info_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3)) if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfoTable.setStatus('current') hpnicf_rs485_raw_session_err_info_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'), (0, 'HPN-ICF-RS485-MIB', 'hpnicfRS485SessionIndex')) if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfoEntry.setStatus('current') hpnicf_rs485_raw_session_err_info = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 109, 2, 3, 1, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpnicfRS485RawSessionErrInfo.setStatus('current') mibBuilder.exportSymbols('HPN-ICF-RS485-MIB', hpnicfRS485RawSessionSummary=hpnicfRS485RawSessionSummary, hpnicfRS485StopBits=hpnicfRS485StopBits, hpnicfRS485RawSessionEntry=hpnicfRS485RawSessionEntry, hpnicfRS485RawSessionErrInfoTable=hpnicfRS485RawSessionErrInfoTable, hpnicfRS485RawSessions=hpnicfRS485RawSessions, hpnicfRS485=hpnicfRS485, PYSNMP_MODULE_ID=hpnicfRS485, hpnicfRS485SessionRemotePort=hpnicfRS485SessionRemotePort, hpnicfRS485ResetCharacters=hpnicfRS485ResetCharacters, hpnicfRS485SessionLocalPort=hpnicfRS485SessionLocalPort, hpnicfRS485RXErrCharacters=hpnicfRS485RXErrCharacters, hpnicfRS485RawSessionTable=hpnicfRS485RawSessionTable, hpnicfRS485RXCharacters=hpnicfRS485RXCharacters, hpnicfRS485SessionStatus=hpnicfRS485SessionStatus, hpnicfRS485TXErrCharacters=hpnicfRS485TXErrCharacters, hpnicfRS485PropertiesTable=hpnicfRS485PropertiesTable, hpnicfRS485PropertiesEntry=hpnicfRS485PropertiesEntry, hpnicfRS485RawSessionErrInfo=hpnicfRS485RawSessionErrInfo, hpnicfRS485Parity=hpnicfRS485Parity, hpnicfRS485TXCharacters=hpnicfRS485TXCharacters, hpnicfRS485RawSessionNextIndex=hpnicfRS485RawSessionNextIndex, hpnicfRS485RawSessionMaxNum=hpnicfRS485RawSessionMaxNum, hpnicfRS485Properties=hpnicfRS485Properties, hpnicfRS485SessionRemoteIP=hpnicfRS485SessionRemoteIP, hpnicfRS485SessionType=hpnicfRS485SessionType, hpnicfRS485SessionAddType=hpnicfRS485SessionAddType, hpnicfRS485BaudRate=hpnicfRS485BaudRate, hpnicfRS485DataBits=hpnicfRS485DataBits, hpnicfRS485FlowControl=hpnicfRS485FlowControl, hpnicfRS485RawSessionErrInfoEntry=hpnicfRS485RawSessionErrInfoEntry, hpnicfRS485SessionIndex=hpnicfRS485SessionIndex)
# message = 'umetumiwa kisi cha tsh2000 kutoka kwa JOSEPH ALEX salio lako ni ths 9000 kujua bonyeza *148*99# ili ' \ # 'kujiunga na salio ' # if message.strip(".islower()"): # print(message) # sentence = "XYThis is an example sentence.XY" # print(message.strip('')) number = input('enter dial codes') if number == '*142*99#': print('Karibu Tigo Chagua kifurushi chako') li = ['Ofa Maalum', 'Zawadi kwa Rafiki', 'Dakika & SMS', 'Internet & 4G', 'Royal', 'Kimataifa', 'Kisichoisha Muda', 'Burudani', 'Tunashea Bando', 'Salio & Language'] for i in range(len(li)): print(f'{i} {li[i]}') choice = input('chagua kifurushi unachotaka') while True: if choice == '0': print('your in one') elif choice == '1': print('your in 1') else: print('done') else: print('wrong dial')
number = input('enter dial codes') if number == '*142*99#': print('Karibu Tigo Chagua kifurushi chako') li = ['Ofa Maalum', 'Zawadi kwa Rafiki', 'Dakika & SMS', 'Internet & 4G', 'Royal', 'Kimataifa', 'Kisichoisha Muda', 'Burudani', 'Tunashea Bando', 'Salio & Language'] for i in range(len(li)): print(f'{i} {li[i]}') choice = input('chagua kifurushi unachotaka') while True: if choice == '0': print('your in one') elif choice == '1': print('your in 1') else: print('done') else: print('wrong dial')
dias = int(input()) ano = dias // 365 dias = dias - ano * 365 mes = dias // 30 dias = dias - mes * 30 print("%.0f ano(s)" % ano) print("%.0f mes(es)" % mes) print("%.0f dia(s)" % dias)
dias = int(input()) ano = dias // 365 dias = dias - ano * 365 mes = dias // 30 dias = dias - mes * 30 print('%.0f ano(s)' % ano) print('%.0f mes(es)' % mes) print('%.0f dia(s)' % dias)
SECRET_KEY = "secret", INSTALLED_APPS = [ 'sampleproject.sample', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME':':memory:' } }
secret_key = ('secret',) installed_apps = ['sampleproject.sample'] databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
# -*- coding: utf-8 -*- # item pipelines # # See documentation in: # http://doc.scrapy.org/en/latest/topics/items.html class ScrapydemoPipeline(object): # item pipelines def process_item(self, item, spider): return item
class Scrapydemopipeline(object): def process_item(self, item, spider): return item
''' Min XOR value Asked in: Booking.com https://www.interviewbit.com/problems/min-xor-value/ Problem Setter: mihai.gheorghe Problem Tester: archit.rai Given an integer array A of N integers, find the pair of integers in the array which have minimum XOR value. Report the minimum XOR value. Input Format: First and only argument of input contains an integer array A Output Format: return a single integer denoting minimum xor value Constraints: 2 <= N <= 100 000 0 <= A[i] <= 1 000 000 000 For Examples : Example Input 1: A = [0, 2, 5, 7] Example Output 1: 2 Explanation: 0 xor 2 = 2 Example Input 2: A = [0, 4, 7, 9] Example Output 2: 3 ''' # @param A : list of integers # @return an integer def findMinXor(A): A = sorted(A) min_xor = A[-1] for i in range(1, len(A)): xor = A[i-1]^A[i] if min_xor>xor: min_xor = xor return min_xor if __name__ == "__main__": data = [ [[0, 2, 5, 7], 2] ] for d in data: print('input', d[0], 'output', findMinXor(d[0]))
""" Min XOR value Asked in: Booking.com https://www.interviewbit.com/problems/min-xor-value/ Problem Setter: mihai.gheorghe Problem Tester: archit.rai Given an integer array A of N integers, find the pair of integers in the array which have minimum XOR value. Report the minimum XOR value. Input Format: First and only argument of input contains an integer array A Output Format: return a single integer denoting minimum xor value Constraints: 2 <= N <= 100 000 0 <= A[i] <= 1 000 000 000 For Examples : Example Input 1: A = [0, 2, 5, 7] Example Output 1: 2 Explanation: 0 xor 2 = 2 Example Input 2: A = [0, 4, 7, 9] Example Output 2: 3 """ def find_min_xor(A): a = sorted(A) min_xor = A[-1] for i in range(1, len(A)): xor = A[i - 1] ^ A[i] if min_xor > xor: min_xor = xor return min_xor if __name__ == '__main__': data = [[[0, 2, 5, 7], 2]] for d in data: print('input', d[0], 'output', find_min_xor(d[0]))
load( "@d2l_rules_csharp//csharp/private:common.bzl", "collect_transitive_info", "get_analyzer_dll", ) load("@d2l_rules_csharp//csharp/private:providers.bzl", "CSharpAssembly") def _format_ref_arg(assembly): return "/r:" + assembly.path def _format_analyzer_arg(analyzer): return "/analyzer:" + analyzer def _format_additionalfile_arg(additionalfile): return "/additionalfile:" + additionalfile.path def _format_resource_arg(resource): return "/resource:" + resource.path def AssemblyAction( actions, name, additionalfiles, analyzers, debug, deps, langversion, resources, srcs, target, target_framework, toolchain): out_ext = "dll" if target == "library" else "exe" out = actions.declare_file("%s.%s" % (name, out_ext)) refout = actions.declare_file("%s.ref.%s" % (name, out_ext)) pdb = actions.declare_file(name + ".pdb") # Our goal is to match msbuild as much as reasonable # https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-alphabetically args = actions.args() args.add("/unsafe-") args.add("/checked-") args.add("/nostdlib+") # mscorlib will get added due to our transitive deps args.add("/utf8output") args.add("/deterministic+") args.add("/filealign:512") args.add("/nologo") args.add("/highentropyva") args.add("/warn:0") # TODO: this stuff ought to be configurable args.add("/target:" + target) args.add("/langversion:" + langversion) if debug: args.add("/debug+") args.add("/optimize-") else: args.add("/optimize+") # TODO: .NET core projects use debug:portable. Investigate this, maybe move # some of this into the toolchain later. args.add("/debug:pdbonly") # outputs args.add("/out:" + out.path) args.add("/refout:" + refout.path) args.add("/pdb:" + pdb.path) # assembly references refs = collect_transitive_info(deps, target_framework) args.add_all(refs, map_each = _format_ref_arg) # analyzers analyzer_assemblies = [get_analyzer_dll(a) for a in analyzers] args.add_all(analyzer_assemblies, map_each = _format_analyzer_arg) args.add_all(additionalfiles, map_each = _format_additionalfile_arg) # .cs files args.add_all([cs.path for cs in srcs]) # resources args.add_all(resources, map_each = _format_resource_arg) # TODO: # - appconfig(?) # - define # * Need to audit D2L defines # * msbuild adds some by default depending on your TF; we should too # - doc (d2l can probably skip this?) # - main (probably not a high priority for d2l) # - pathmap (needed for deterministic pdbs across hosts): this will # probably need to be done in a wrapper because of the difference between # the analysis phase (when this code runs) and execution phase. # - various code signing args (not needed for d2l) # - COM-related args like /link # - allow warnings to be configured # - unsafe (not needed for d2l) # - win32 args like /win32icon # spill to a "response file" when the argument list gets too big (Bazel # makes that call based on limitations of the OS). args.set_param_file_format("multiline") args.use_param_file("@%s") # dotnet.exe csc.dll /noconfig <other csc args> # https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe actions.run( mnemonic = "CSharpCompile", progress_message = "Compiling " + name, inputs = depset( direct = srcs + resources + analyzer_assemblies + additionalfiles + [toolchain.compiler], transitive = [refs], ), outputs = [out, refout, pdb], executable = toolchain.runtime, arguments = [ toolchain.compiler.path, # This can't go in the response file (if it does it won't be seen # until it's too late). "/noconfig", args, ], ) return CSharpAssembly[target_framework]( out = out, refout = refout, pdb = pdb, deps = deps, transitive_refs = refs, )
load('@d2l_rules_csharp//csharp/private:common.bzl', 'collect_transitive_info', 'get_analyzer_dll') load('@d2l_rules_csharp//csharp/private:providers.bzl', 'CSharpAssembly') def _format_ref_arg(assembly): return '/r:' + assembly.path def _format_analyzer_arg(analyzer): return '/analyzer:' + analyzer def _format_additionalfile_arg(additionalfile): return '/additionalfile:' + additionalfile.path def _format_resource_arg(resource): return '/resource:' + resource.path def assembly_action(actions, name, additionalfiles, analyzers, debug, deps, langversion, resources, srcs, target, target_framework, toolchain): out_ext = 'dll' if target == 'library' else 'exe' out = actions.declare_file('%s.%s' % (name, out_ext)) refout = actions.declare_file('%s.ref.%s' % (name, out_ext)) pdb = actions.declare_file(name + '.pdb') args = actions.args() args.add('/unsafe-') args.add('/checked-') args.add('/nostdlib+') args.add('/utf8output') args.add('/deterministic+') args.add('/filealign:512') args.add('/nologo') args.add('/highentropyva') args.add('/warn:0') args.add('/target:' + target) args.add('/langversion:' + langversion) if debug: args.add('/debug+') args.add('/optimize-') else: args.add('/optimize+') args.add('/debug:pdbonly') args.add('/out:' + out.path) args.add('/refout:' + refout.path) args.add('/pdb:' + pdb.path) refs = collect_transitive_info(deps, target_framework) args.add_all(refs, map_each=_format_ref_arg) analyzer_assemblies = [get_analyzer_dll(a) for a in analyzers] args.add_all(analyzer_assemblies, map_each=_format_analyzer_arg) args.add_all(additionalfiles, map_each=_format_additionalfile_arg) args.add_all([cs.path for cs in srcs]) args.add_all(resources, map_each=_format_resource_arg) args.set_param_file_format('multiline') args.use_param_file('@%s') actions.run(mnemonic='CSharpCompile', progress_message='Compiling ' + name, inputs=depset(direct=srcs + resources + analyzer_assemblies + additionalfiles + [toolchain.compiler], transitive=[refs]), outputs=[out, refout, pdb], executable=toolchain.runtime, arguments=[toolchain.compiler.path, '/noconfig', args]) return CSharpAssembly[target_framework](out=out, refout=refout, pdb=pdb, deps=deps, transitive_refs=refs)
# This file is part of the airslate. # # Copyright (c) 2021 airSlate, Inc. # # For the full copyright and license information, please view # the LICENSE file that was distributed with this source code. """The top-level module for request models."""
"""The top-level module for request models."""
""" Using a read7() method that returns 7 characters from a file, implement readN(n) which reads n characters. For example, given a file with the content "Hello world", three read7() returns "Hello w", "orld" and then "". """ class FileReader: def __init__(self, content: str) -> None: self.content = content self.index = 0 self.length = len(content) def read7(self) -> str: if self.index + 7 < self.length: res = self.content[self.index:self.index + 7] self.index += 7 else: res = self.content[self.index:] self.index = self.length return res def read_n(self, n: int) -> str: char_count = 0 buffer = "" res = "" while self.index < self.length: if char_count >= n: res = buffer[:n] buffer = buffer[n:] char_count -= n else: buffer += self.read7() char_count += 7 if res: yield res res = "" if buffer and self.index >= self.length: yield buffer if __name__ == '__main__': f = FileReader("Hello World") assert f.read7() == "Hello W" assert f.read7() == "orld" assert f.read7() == "" f = FileReader("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " "tempor incididunt") gen = f.read_n(20) assert next(gen) == "Lorem ipsum dolor si" assert next(gen) == "t amet, consectetur " assert next(gen) == "adipiscing elit, sed" assert next(gen) == " do eiusmod tempor i" assert next(gen) == "ncididunt" try: next(gen) except StopIteration: pass
""" Using a read7() method that returns 7 characters from a file, implement readN(n) which reads n characters. For example, given a file with the content "Hello world", three read7() returns "Hello w", "orld" and then "". """ class Filereader: def __init__(self, content: str) -> None: self.content = content self.index = 0 self.length = len(content) def read7(self) -> str: if self.index + 7 < self.length: res = self.content[self.index:self.index + 7] self.index += 7 else: res = self.content[self.index:] self.index = self.length return res def read_n(self, n: int) -> str: char_count = 0 buffer = '' res = '' while self.index < self.length: if char_count >= n: res = buffer[:n] buffer = buffer[n:] char_count -= n else: buffer += self.read7() char_count += 7 if res: yield res res = '' if buffer and self.index >= self.length: yield buffer if __name__ == '__main__': f = file_reader('Hello World') assert f.read7() == 'Hello W' assert f.read7() == 'orld' assert f.read7() == '' f = file_reader('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt') gen = f.read_n(20) assert next(gen) == 'Lorem ipsum dolor si' assert next(gen) == 't amet, consectetur ' assert next(gen) == 'adipiscing elit, sed' assert next(gen) == ' do eiusmod tempor i' assert next(gen) == 'ncididunt' try: next(gen) except StopIteration: pass
def get_coefficients(Xs, Ys): if len(Xs) != len(Ys): raise ValueError("X and Y series has different lengths") if not isinstance(Xs[0], (int, float)) and not isinstance(Ys[0], (int, float)): raise ValueError("X or Y are not 1D list with numbers") n = len(Xs) X_sum = sum(Xs) X_squared_sum = 0 for x in Xs: X_squared_sum += x**2 Y_sum = sum(Ys) X_by_Y_sum = 0 for i in range(len(Xs)): X_by_Y_sum += (Xs[i]*Ys[i]) m = float((n * X_by_Y_sum) - (X_sum * Y_sum)) / float((n * X_squared_sum) - (X_sum**2)) b = float((Y_sum * X_squared_sum) - (X_sum * X_by_Y_sum)) / float((n * X_squared_sum) - (X_sum**2)) return m, b def r_correlation(Xs, Ys): if len(Xs) != len(Ys): raise ValueError("X and Y series has different lengths") if not isinstance(Xs[0], (int, float)) and not isinstance(Ys[0], (int, float)): raise ValueError("X or Y are not 1D list with numbers") n = len(Xs) X_sum = sum(Xs) X_squared_sum = 0.0 for x in Xs: X_squared_sum += x**2 Y_sum = sum(Ys) Y_squared_sum = 0.0 for y in Ys: Y_squared_sum += y**2 X_by_Y_sum = 0.0 for i in range(len(Xs)): X_by_Y_sum += (Xs[i]*Ys[i]) r_numerator = (n * X_by_Y_sum) - (X_sum * Y_sum) r_denominator = ( (n * X_squared_sum) - (X_sum**2) ) * ( (n * Y_squared_sum) - (Y_sum ** 2) ) r_denominator = pow(r_denominator, 0.5) return float(r_numerator) / float(r_denominator) def r2_correlation(Xs, Ys): return pow(r_correlation(Xs, Ys), 2)
def get_coefficients(Xs, Ys): if len(Xs) != len(Ys): raise value_error('X and Y series has different lengths') if not isinstance(Xs[0], (int, float)) and (not isinstance(Ys[0], (int, float))): raise value_error('X or Y are not 1D list with numbers') n = len(Xs) x_sum = sum(Xs) x_squared_sum = 0 for x in Xs: x_squared_sum += x ** 2 y_sum = sum(Ys) x_by_y_sum = 0 for i in range(len(Xs)): x_by_y_sum += Xs[i] * Ys[i] m = float(n * X_by_Y_sum - X_sum * Y_sum) / float(n * X_squared_sum - X_sum ** 2) b = float(Y_sum * X_squared_sum - X_sum * X_by_Y_sum) / float(n * X_squared_sum - X_sum ** 2) return (m, b) def r_correlation(Xs, Ys): if len(Xs) != len(Ys): raise value_error('X and Y series has different lengths') if not isinstance(Xs[0], (int, float)) and (not isinstance(Ys[0], (int, float))): raise value_error('X or Y are not 1D list with numbers') n = len(Xs) x_sum = sum(Xs) x_squared_sum = 0.0 for x in Xs: x_squared_sum += x ** 2 y_sum = sum(Ys) y_squared_sum = 0.0 for y in Ys: y_squared_sum += y ** 2 x_by_y_sum = 0.0 for i in range(len(Xs)): x_by_y_sum += Xs[i] * Ys[i] r_numerator = n * X_by_Y_sum - X_sum * Y_sum r_denominator = (n * X_squared_sum - X_sum ** 2) * (n * Y_squared_sum - Y_sum ** 2) r_denominator = pow(r_denominator, 0.5) return float(r_numerator) / float(r_denominator) def r2_correlation(Xs, Ys): return pow(r_correlation(Xs, Ys), 2)
def init_celery(app, celery): """Configure celery.Task to run within app context.""" class ContextTask(celery.Task): def __call__(self, *args, **kwargs): with app.app_context(): return self.run(*args, **kwargs) celery.Task = ContextTask
def init_celery(app, celery): """Configure celery.Task to run within app context.""" class Contexttask(celery.Task): def __call__(self, *args, **kwargs): with app.app_context(): return self.run(*args, **kwargs) celery.Task = ContextTask
class Solution: def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ node.val = node.next.val node.next = node.next.next
class Solution: def delete_node(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ node.val = node.next.val node.next = node.next.next
s = "Guido van Rossum heeft programmeertaal Python bedacht." for letter in s: if letter in 'aeiou': print(letter)
s = 'Guido van Rossum heeft programmeertaal Python bedacht.' for letter in s: if letter in 'aeiou': print(letter)
class stub: def __init__(self, root): self.dirmap = {root:[]} self.state = 'stopped' def mkdir(self, containing_dir, name): self.dirmap[containing_dir] += [name] path = containing_dir + '/' + name self.dirmap[path] = [] return path def add_file(self, containing_dir, name): self.dirmap[containing_dir] += [name] def query_play_state(self): return self.state def listdir(self, path): return self.dirmap[path] def isdir(self, path): return path in self.dirmap def launch_player(self, path): self.state = 'playing' def pause_player(self): self.state = 'paused' def stop_player(self): self.state = 'stopped' def rewind_player(self): pass def resume_player(self): self.state = 'playing'
class Stub: def __init__(self, root): self.dirmap = {root: []} self.state = 'stopped' def mkdir(self, containing_dir, name): self.dirmap[containing_dir] += [name] path = containing_dir + '/' + name self.dirmap[path] = [] return path def add_file(self, containing_dir, name): self.dirmap[containing_dir] += [name] def query_play_state(self): return self.state def listdir(self, path): return self.dirmap[path] def isdir(self, path): return path in self.dirmap def launch_player(self, path): self.state = 'playing' def pause_player(self): self.state = 'paused' def stop_player(self): self.state = 'stopped' def rewind_player(self): pass def resume_player(self): self.state = 'playing'
# # PySNMP MIB module PEAKFLOW-TMS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PEAKFLOW-TMS-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:40:01 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) # arbornetworksProducts, = mibBuilder.importSymbols("ARBOR-SMI", "arbornetworksProducts") Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint") ifName, = mibBuilder.importSymbols("IF-MIB", "ifName") Ipv6AddressPrefix, Ipv6Address = mibBuilder.importSymbols("IPV6-TC", "Ipv6AddressPrefix", "Ipv6Address") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") sysName, = mibBuilder.importSymbols("SNMPv2-MIB", "sysName") Integer32, Bits, ObjectIdentity, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, NotificationType, Counter64, Unsigned32, iso, MibIdentifier, TimeTicks, Counter32, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Bits", "ObjectIdentity", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "NotificationType", "Counter64", "Unsigned32", "iso", "MibIdentifier", "TimeTicks", "Counter32", "IpAddress") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") peakflowTmsMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9694, 1, 5)) peakflowTmsMIB.setRevisions(('2013-08-19 00:00', '2012-03-29 12:00', '2012-01-12 12:00', '2011-06-14 16:00', '2011-06-03 16:00', '2011-06-03 00:00', '2011-05-23 00:00', '2011-01-21 00:00', '2010-10-28 00:00', '2010-09-07 00:00', '2009-05-27 00:00', '2009-05-08 00:00', '2009-03-11 00:00', '2009-02-13 00:00', '2008-11-13 00:00', '2008-04-07 00:00', '2007-11-20 00:00', '2007-04-27 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: peakflowTmsMIB.setRevisionsDescriptions(('Updated contact information', 'Bug#50908: Fix reversed tmsSpCommunication enumerations.', 'Added tmsSystemPrefixesOk and tmsSystemPrefixesMissing traps.', 'Fix stray quote that was causing a syntax error.', 'Added performnace traps.', 'Fixed some typos and grammar problems.', 'Added IPv6 versions of existing IPv4 objects.', 'Added new traps (tmsAutomitigationBgp {Enabled/Disabled/Suspended}) for traffic-triggered automitigation BGP announcements.', 'Added new traps (tmsSpCommunicationDown and tmsSpCommunicationUp) for alerting about failed communication with Peakflow SP.', 'Added new traps (tmsFilesystemCritical and tmsFilesystemNominal) for new filesystem monitoring feature.', 'The March 11 2009 revision had accidentally obsoleted the tmsHostFault OID, rather than the hostFault trap. This is now fixed. The tmsHostFault OID is restored to current status and the hostFault trap is marked obsolete.', 'Update contact group name and company address.', 'Obsoleted the tmsHostFault trap.', 'Added new objects to support TMS 5.0', 'Update contact info.', "Prefixed Textual Conventions with 'Tms' for uniqueness", 'Removed unused Textual Conventions, added display hints', 'Initial revision',)) if mibBuilder.loadTexts: peakflowTmsMIB.setLastUpdated('201308190000Z') if mibBuilder.loadTexts: peakflowTmsMIB.setOrganization('Arbor Networks, Inc.') if mibBuilder.loadTexts: peakflowTmsMIB.setContactInfo(' Arbor Networks, Inc. Arbor Technical Assistance Center Postal: 76 Blanchard Road Burlington, MA 01803 USA Tel: +1 866 212 7267 (toll free) +1 781 362 4300 Email: support@arbor.net ') if mibBuilder.loadTexts: peakflowTmsMIB.setDescription('Peakflow TMS MIB') class TmsTableIndex(TextualConvention, Integer32): description = 'Used for an index into a table' status = 'current' displayHint = 'd' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(1, 2147483647) class TmsTableIndexOrZero(TextualConvention, Integer32): description = 'The number of items in a table. May be zero if the table is empty.' status = 'current' displayHint = 'd' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) class TmsPercentage(TextualConvention, Integer32): description = 'A percentage value (0% - 100%)' status = 'current' displayHint = 'd' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 100) class TmsHundredths(TextualConvention, Integer32): description = 'An integer representing hundredths of a unit' status = 'current' displayHint = 'd-2' peakflowTmsMgr = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2)) tmsHostFault = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsHostFault.setStatus('current') if mibBuilder.loadTexts: tmsHostFault.setDescription('state of faults within a TMS device') tmsHostUpTime = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 2), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsHostUpTime.setStatus('current') if mibBuilder.loadTexts: tmsHostUpTime.setDescription('uptime of this host') deviceCpuLoadAvg1min = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 3), TmsHundredths()).setMaxAccess("readonly") if mibBuilder.loadTexts: deviceCpuLoadAvg1min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg1min.setDescription('Average number of processes in run queue during last 1 min.') deviceCpuLoadAvg5min = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 4), TmsHundredths()).setMaxAccess("readonly") if mibBuilder.loadTexts: deviceCpuLoadAvg5min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg5min.setDescription('Average number of processes in run queue during last 5 min.') deviceCpuLoadAvg15min = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 5), TmsHundredths()).setMaxAccess("readonly") if mibBuilder.loadTexts: deviceCpuLoadAvg15min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg15min.setDescription('Average number of processes in run queue during last 15 min.') deviceDiskUsage = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 6), TmsPercentage()).setMaxAccess("readonly") if mibBuilder.loadTexts: deviceDiskUsage.setStatus('current') if mibBuilder.loadTexts: deviceDiskUsage.setDescription('Percentage of primary data partition used.') devicePhysicalMemoryUsage = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 7), TmsPercentage()).setMaxAccess("readonly") if mibBuilder.loadTexts: devicePhysicalMemoryUsage.setStatus('current') if mibBuilder.loadTexts: devicePhysicalMemoryUsage.setDescription('Percentage of physical memory used.') deviceSwapSpaceUsage = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 8), TmsPercentage()).setMaxAccess("readonly") if mibBuilder.loadTexts: deviceSwapSpaceUsage.setStatus('current') if mibBuilder.loadTexts: deviceSwapSpaceUsage.setDescription('Percentage of swap space used.') tmsTrapString = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 9), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapString.setStatus('current') if mibBuilder.loadTexts: tmsTrapString.setDescription('Temporary string for reporting information in traps') tmsTrapDetail = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 10), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapDetail.setStatus('current') if mibBuilder.loadTexts: tmsTrapDetail.setDescription('Temporary string for reporting additional detail (if any) about a trap') tmsTrapSubhostName = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 11), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapSubhostName.setStatus('current') if mibBuilder.loadTexts: tmsTrapSubhostName.setDescription('Temporary string for reporting the name of a subhost') tmsTrapComponentName = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 12), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapComponentName.setStatus('current') if mibBuilder.loadTexts: tmsTrapComponentName.setDescription('Temporary string for reporting the name of a program or device') tmsTrapBgpPeer = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 13), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapBgpPeer.setStatus('current') if mibBuilder.loadTexts: tmsTrapBgpPeer.setDescription('IP address of a BGP peer') tmsTrapGreSource = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 14), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapGreSource.setStatus('current') if mibBuilder.loadTexts: tmsTrapGreSource.setDescription('GRE source IP address') tmsTrapGreDestination = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 15), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapGreDestination.setStatus('current') if mibBuilder.loadTexts: tmsTrapGreDestination.setDescription('GRE destination IP address') tmsTrapNexthop = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 16), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapNexthop.setStatus('current') if mibBuilder.loadTexts: tmsTrapNexthop.setDescription('Nexthop IP address') tmsTrapIpv6BgpPeer = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 17), Ipv6Address()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapIpv6BgpPeer.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6BgpPeer.setDescription('IPv6 address of a BGP peer') tmsTrapIpv6GreSource = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 18), Ipv6Address()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapIpv6GreSource.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6GreSource.setDescription('GRE source IPv6 address') tmsTrapIpv6GreDestination = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 19), Ipv6Address()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapIpv6GreDestination.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6GreDestination.setDescription('GRE destination IPv6 address') tmsTrapIpv6Nexthop = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 20), Ipv6Address()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsTrapIpv6Nexthop.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6Nexthop.setDescription('Nexthop IPv6 address') peakflowTmsTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3)) peakflowTmsTrapsEnumerate = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0)) hostFault = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 1)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsHostFault")) if mibBuilder.loadTexts: hostFault.setStatus('obsolete') if mibBuilder.loadTexts: hostFault.setDescription('Obsolete; replaced by a number of more specific traps.') greTunnelDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 2)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapGreSource"), ("PEAKFLOW-TMS-MIB", "tmsTrapGreDestination")) if mibBuilder.loadTexts: greTunnelDown.setStatus('current') if mibBuilder.loadTexts: greTunnelDown.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') greTunnelUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 3)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapGreSource"), ("PEAKFLOW-TMS-MIB", "tmsTrapGreDestination")) if mibBuilder.loadTexts: greTunnelUp.setStatus('current') if mibBuilder.loadTexts: greTunnelUp.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tmsLinkUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 4)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString")) if mibBuilder.loadTexts: tmsLinkUp.setStatus('obsolete') if mibBuilder.loadTexts: tmsLinkUp.setDescription('Obsolete; IF-MIB::linkUp is now used instead') tmsLinkDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 5)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString")) if mibBuilder.loadTexts: tmsLinkDown.setStatus('obsolete') if mibBuilder.loadTexts: tmsLinkDown.setDescription('Obsolete; IF-MIB::linkDown is now used instead') subHostUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 6)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapSubhostName")) if mibBuilder.loadTexts: subHostUp.setStatus('current') if mibBuilder.loadTexts: subHostUp.setDescription('Generated when a subhost transitions to active') subHostDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 7)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapSubhostName")) if mibBuilder.loadTexts: subHostDown.setStatus('current') if mibBuilder.loadTexts: subHostDown.setDescription('Generated when a subhost transitions to inactive') tmsBgpNeighborDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 8)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapBgpPeer")) if mibBuilder.loadTexts: tmsBgpNeighborDown.setStatus('current') if mibBuilder.loadTexts: tmsBgpNeighborDown.setDescription('Generated when a BGP neighbor transitions out of the ESTABLISHED state') tmsBgpNeighborUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 9)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapBgpPeer")) if mibBuilder.loadTexts: tmsBgpNeighborUp.setStatus('current') if mibBuilder.loadTexts: tmsBgpNeighborUp.setDescription('Generated when a BGP neighbor transitions into the ESTABLISHED state') tmsNexthopDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 10)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapNexthop"), ("IF-MIB", "ifName")) if mibBuilder.loadTexts: tmsNexthopDown.setStatus('current') if mibBuilder.loadTexts: tmsNexthopDown.setDescription('Generated when the nexthop host cannot be contacted') tmsNexthopUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 11)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapNexthop"), ("IF-MIB", "ifName")) if mibBuilder.loadTexts: tmsNexthopUp.setStatus('current') if mibBuilder.loadTexts: tmsNexthopUp.setDescription('Generated when the nexthop host cannot be contacted') tmsMitigationError = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 12)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsMitigationIndex"), ("PEAKFLOW-TMS-MIB", "tmsMitigationName")) if mibBuilder.loadTexts: tmsMitigationError.setStatus('current') if mibBuilder.loadTexts: tmsMitigationError.setDescription('A mitigation cannot run because of a configuration error') tmsMitigationSuspended = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 13)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsMitigationIndex"), ("PEAKFLOW-TMS-MIB", "tmsMitigationName")) if mibBuilder.loadTexts: tmsMitigationSuspended.setStatus('current') if mibBuilder.loadTexts: tmsMitigationSuspended.setDescription('A mitigation has been suspended due to some external problem (nexthop not reachable, BGP down, etc.)') tmsMitigationRunning = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 14)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsMitigationIndex"), ("PEAKFLOW-TMS-MIB", "tmsMitigationName")) if mibBuilder.loadTexts: tmsMitigationRunning.setStatus('current') if mibBuilder.loadTexts: tmsMitigationRunning.setDescription('A previously-detected mitigation problem has been cleared and the mitigation is now running') tmsConfigMissing = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 15)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsConfigMissing.setStatus('current') if mibBuilder.loadTexts: tmsConfigMissing.setDescription('Generated when a TMS configuration file cannot be found.') tmsConfigError = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 16)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsConfigError.setStatus('current') if mibBuilder.loadTexts: tmsConfigError.setDescription('Generated when an error in a TMS configuration file is detected.') tmsConfigOk = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 17)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsConfigOk.setStatus('current') if mibBuilder.loadTexts: tmsConfigOk.setDescription('All configuration problems have been corrected.') tmsHwDeviceDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 18)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsHwDeviceDown.setStatus('current') if mibBuilder.loadTexts: tmsHwDeviceDown.setDescription('A hardware device has failed.') tmsHwDeviceUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 19)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsHwDeviceUp.setStatus('current') if mibBuilder.loadTexts: tmsHwDeviceUp.setDescription('A hardware device failure has been corrected.') tmsHwSensorCritical = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 20)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsHwSensorCritical.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorCritical.setDescription('A hardware sensor is reading an alarm condition.') tmsHwSensorOk = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 21)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsHwSensorOk.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorOk.setDescription('A hardware sensor is no longer reading an alarm condition.') tmsSwComponentDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 22)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapSubhostName"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSwComponentDown.setStatus('current') if mibBuilder.loadTexts: tmsSwComponentDown.setDescription('A software program has failed.') tmsSwComponentUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 23)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapSubhostName"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSwComponentUp.setStatus('current') if mibBuilder.loadTexts: tmsSwComponentUp.setDescription('A software program failure has been corrected.') tmsSystemStatusCritical = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 24)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemStatusCritical.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusCritical.setDescription('The TMS system is experiencing a critical failure.') tmsSystemStatusDegraded = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 25)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemStatusDegraded.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusDegraded.setDescription('The TMS system is experiencing degraded performance.') tmsSystemStatusNominal = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 26)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemStatusNominal.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusNominal.setDescription('The TMS system has returned to normal behavior.') tmsFilesystemCritical = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 27)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsFilesystemCritical.setStatus('current') if mibBuilder.loadTexts: tmsFilesystemCritical.setDescription('A filesystem is near capacity.') tmsFilesystemNominal = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 28)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsFilesystemNominal.setStatus('current') if mibBuilder.loadTexts: tmsFilesystemNominal.setDescription('A filesystem is back below capacity alarm threshold.') tmsHwSensorUnknown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 29)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsHwSensorUnknown.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorUnknown.setDescription('A hardware sensor is in an unknown state.') tmsSpCommunicationUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 30)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSpCommunicationUp.setStatus('current') if mibBuilder.loadTexts: tmsSpCommunicationUp.setDescription('Communication with SP host is up.') tmsSpCommunicationDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 31)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSpCommunicationDown.setStatus('current') if mibBuilder.loadTexts: tmsSpCommunicationDown.setDescription('Communication with SP host is down.') tmsSystemStatusError = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 32)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemStatusError.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusError.setDescription('The TMS system is experiencing an error.') tmsAutomitigationBgpEnabled = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 33)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsAutomitigationBgpEnabled.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpEnabled.setDescription('A previously-detected automitigation problem has been cleared and the automitigation BGP announcements have resumed.') tmsAutomitigationBgpDisabled = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 34)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsAutomitigationBgpDisabled.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpDisabled.setDescription('Automitigation BGP announcements have been administratively disabled.') tmsAutomitigationBgpSuspended = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 35)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsAutomitigationBgpSuspended.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpSuspended.setDescription('Automitigation BGP announcements have been suspended due to some external problem (nexthop not reachable, BGP down, etc.)') tmsIpv6GreTunnelDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 36)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6GreSource"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6GreDestination")) if mibBuilder.loadTexts: tmsIpv6GreTunnelDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6GreTunnelDown.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tmsIpv6GreTunnelUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 37)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6GreSource"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6GreDestination")) if mibBuilder.loadTexts: tmsIpv6GreTunnelUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6GreTunnelUp.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tmsIpv6BgpNeighborDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 38)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6BgpPeer")) if mibBuilder.loadTexts: tmsIpv6BgpNeighborDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6BgpNeighborDown.setDescription('Generated when a BGP neighbor transitions out of the ESTABLISHED state.') tmsIpv6BgpNeighborUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 39)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6BgpPeer")) if mibBuilder.loadTexts: tmsIpv6BgpNeighborUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6BgpNeighborUp.setDescription('Generated when a BGP neighbor transitions into the ESTABLISHED state.') tmsIpv6NexthopDown = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 40)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6Nexthop"), ("IF-MIB", "ifName")) if mibBuilder.loadTexts: tmsIpv6NexthopDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6NexthopDown.setDescription('Generated when the nexthop host becomes unreachable.') tmsIpv6NexthopUp = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 41)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapIpv6Nexthop"), ("IF-MIB", "ifName")) if mibBuilder.loadTexts: tmsIpv6NexthopUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6NexthopUp.setDescription('Generated when the nexthop host becomes reachable.') tmsPerformanceOk = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 42)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsPerformanceOk.setStatus('current') if mibBuilder.loadTexts: tmsPerformanceOk.setDescription('Generated when the processed traffic rate matches the offered traffic rate.') tmsPerformanceLossy = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 43)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsPerformanceLossy.setStatus('current') if mibBuilder.loadTexts: tmsPerformanceLossy.setDescription('Generated when the processed traffic rate is lower than the offered traffic rate.') tmsSystemPrefixesOk = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 44)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemPrefixesOk.setStatus('current') if mibBuilder.loadTexts: tmsSystemPrefixesOk.setDescription('BGP is currently advertising all mitigation prefixes.') tmsSystemPrefixesMissing = NotificationType((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 45)).setObjects(("SNMPv2-MIB", "sysName"), ("PEAKFLOW-TMS-MIB", "tmsTrapString"), ("PEAKFLOW-TMS-MIB", "tmsTrapDetail"), ("PEAKFLOW-TMS-MIB", "tmsTrapComponentName")) if mibBuilder.loadTexts: tmsSystemPrefixesMissing.setStatus('current') if mibBuilder.loadTexts: tmsSystemPrefixesMissing.setDescription('BGP is not currently advertising all mitigation prefixes.') peakflowTmsObj = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5)) tmsDpiConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1)) tmsVersion = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsVersion.setStatus('current') if mibBuilder.loadTexts: tmsVersion.setDescription('TMS software version') tmsLastUpdate = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsLastUpdate.setStatus('current') if mibBuilder.loadTexts: tmsLastUpdate.setDescription('Time of the last configuration change') tmsMitigationConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2)) tmsMitigationLastUpdate = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsMitigationLastUpdate.setStatus('current') if mibBuilder.loadTexts: tmsMitigationLastUpdate.setDescription('Last time Mitigation configuration was updated') tmsMitigationNumber = MibScalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 2), TmsTableIndexOrZero()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsMitigationNumber.setStatus('current') if mibBuilder.loadTexts: tmsMitigationNumber.setDescription('Number of entries in the tmsMitigation table') tmsMitigationTable = MibTable((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3), ) if mibBuilder.loadTexts: tmsMitigationTable.setStatus('current') if mibBuilder.loadTexts: tmsMitigationTable.setDescription('Table of all mitigations in the TMS system') tmsMitigationEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1), ).setIndexNames((0, "PEAKFLOW-TMS-MIB", "tmsMitigationIndex")) if mibBuilder.loadTexts: tmsMitigationEntry.setStatus('current') if mibBuilder.loadTexts: tmsMitigationEntry.setDescription('Information about a single mitigation') tmsMitigationIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 1), TmsTableIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsMitigationIndex.setStatus('current') if mibBuilder.loadTexts: tmsMitigationIndex.setDescription('Index in the tmsMitigation table. As of release 5.0 this is the same as the tmsMitigationId.') tmsMitigationId = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsMitigationId.setStatus('current') if mibBuilder.loadTexts: tmsMitigationId.setDescription('ID number of this mitigation') tmsDestinationPrefix = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 3), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsDestinationPrefix.setStatus('current') if mibBuilder.loadTexts: tmsDestinationPrefix.setDescription('Destination IPv4 prefix to which this mitigation applies. The value 0.0.0.0/32 indicates that the mitigation has no IPv4 prefix.') tmsDestinationPrefixMask = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 32))).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsDestinationPrefixMask.setStatus('current') if mibBuilder.loadTexts: tmsDestinationPrefixMask.setDescription('Destination IPv4 prefix to which this mitigation applies. The value 0.0.0.0/32 indicates that the mitigation has no IPv4 prefix.') tmsMitigationName = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsMitigationName.setStatus('current') if mibBuilder.loadTexts: tmsMitigationName.setDescription('Name of this mitigation') tmsIpv6DestinationPrefix = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 6), Ipv6AddressPrefix()).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsIpv6DestinationPrefix.setStatus('current') if mibBuilder.loadTexts: tmsIpv6DestinationPrefix.setDescription('Destination IPv6 prefix to which this mitigation applies. The value 0::/128 indicates that the mitigation has no IPv6 prefix.') tmsIpv6DestinationPrefixMask = MibTableColumn((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 7), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 128))).setMaxAccess("readonly") if mibBuilder.loadTexts: tmsIpv6DestinationPrefixMask.setStatus('current') if mibBuilder.loadTexts: tmsIpv6DestinationPrefixMask.setDescription('Destination IPv6 prefix to which this mitigation applies. The value 0::/128 indicates that the mitigation has no IPv6 prefix.') mibBuilder.exportSymbols("PEAKFLOW-TMS-MIB", tmsConfigError=tmsConfigError, tmsTrapNexthop=tmsTrapNexthop, devicePhysicalMemoryUsage=devicePhysicalMemoryUsage, tmsTrapString=tmsTrapString, tmsIpv6DestinationPrefixMask=tmsIpv6DestinationPrefixMask, tmsNexthopUp=tmsNexthopUp, tmsPerformanceLossy=tmsPerformanceLossy, tmsConfigOk=tmsConfigOk, tmsTrapGreDestination=tmsTrapGreDestination, tmsHostFault=tmsHostFault, tmsFilesystemNominal=tmsFilesystemNominal, tmsSpCommunicationDown=tmsSpCommunicationDown, tmsSystemPrefixesMissing=tmsSystemPrefixesMissing, tmsTrapIpv6Nexthop=tmsTrapIpv6Nexthop, peakflowTmsObj=peakflowTmsObj, tmsLastUpdate=tmsLastUpdate, tmsMitigationId=tmsMitigationId, tmsMitigationConfig=tmsMitigationConfig, tmsMitigationLastUpdate=tmsMitigationLastUpdate, tmsMitigationError=tmsMitigationError, deviceDiskUsage=deviceDiskUsage, tmsMitigationIndex=tmsMitigationIndex, peakflowTmsTrapsEnumerate=peakflowTmsTrapsEnumerate, tmsIpv6GreTunnelUp=tmsIpv6GreTunnelUp, tmsBgpNeighborUp=tmsBgpNeighborUp, tmsMitigationEntry=tmsMitigationEntry, deviceCpuLoadAvg1min=deviceCpuLoadAvg1min, tmsMitigationNumber=tmsMitigationNumber, peakflowTmsMgr=peakflowTmsMgr, tmsSystemPrefixesOk=tmsSystemPrefixesOk, greTunnelDown=greTunnelDown, subHostUp=subHostUp, tmsLinkUp=tmsLinkUp, tmsBgpNeighborDown=tmsBgpNeighborDown, tmsLinkDown=tmsLinkDown, tmsMitigationTable=tmsMitigationTable, tmsSwComponentDown=tmsSwComponentDown, tmsIpv6NexthopUp=tmsIpv6NexthopUp, tmsTrapComponentName=tmsTrapComponentName, tmsIpv6BgpNeighborDown=tmsIpv6BgpNeighborDown, hostFault=hostFault, tmsPerformanceOk=tmsPerformanceOk, tmsHostUpTime=tmsHostUpTime, tmsVersion=tmsVersion, tmsIpv6GreTunnelDown=tmsIpv6GreTunnelDown, tmsTrapGreSource=tmsTrapGreSource, tmsAutomitigationBgpSuspended=tmsAutomitigationBgpSuspended, tmsHwDeviceDown=tmsHwDeviceDown, tmsMitigationSuspended=tmsMitigationSuspended, PYSNMP_MODULE_ID=peakflowTmsMIB, tmsAutomitigationBgpDisabled=tmsAutomitigationBgpDisabled, tmsTrapIpv6GreSource=tmsTrapIpv6GreSource, tmsNexthopDown=tmsNexthopDown, greTunnelUp=greTunnelUp, tmsSwComponentUp=tmsSwComponentUp, tmsSystemStatusNominal=tmsSystemStatusNominal, tmsHwDeviceUp=tmsHwDeviceUp, TmsTableIndexOrZero=TmsTableIndexOrZero, tmsTrapIpv6BgpPeer=tmsTrapIpv6BgpPeer, deviceSwapSpaceUsage=deviceSwapSpaceUsage, tmsSystemStatusDegraded=tmsSystemStatusDegraded, peakflowTmsTraps=peakflowTmsTraps, tmsDestinationPrefixMask=tmsDestinationPrefixMask, tmsHwSensorCritical=tmsHwSensorCritical, peakflowTmsMIB=peakflowTmsMIB, tmsDpiConfig=tmsDpiConfig, tmsFilesystemCritical=tmsFilesystemCritical, tmsIpv6NexthopDown=tmsIpv6NexthopDown, tmsConfigMissing=tmsConfigMissing, tmsTrapBgpPeer=tmsTrapBgpPeer, deviceCpuLoadAvg15min=deviceCpuLoadAvg15min, tmsIpv6DestinationPrefix=tmsIpv6DestinationPrefix, tmsTrapDetail=tmsTrapDetail, deviceCpuLoadAvg5min=deviceCpuLoadAvg5min, tmsIpv6BgpNeighborUp=tmsIpv6BgpNeighborUp, TmsPercentage=TmsPercentage, tmsSystemStatusError=tmsSystemStatusError, tmsSystemStatusCritical=tmsSystemStatusCritical, tmsTrapSubhostName=tmsTrapSubhostName, TmsTableIndex=TmsTableIndex, tmsHwSensorOk=tmsHwSensorOk, tmsMitigationName=tmsMitigationName, tmsMitigationRunning=tmsMitigationRunning, TmsHundredths=TmsHundredths, tmsTrapIpv6GreDestination=tmsTrapIpv6GreDestination, tmsDestinationPrefix=tmsDestinationPrefix, tmsAutomitigationBgpEnabled=tmsAutomitigationBgpEnabled, tmsSpCommunicationUp=tmsSpCommunicationUp, tmsHwSensorUnknown=tmsHwSensorUnknown, subHostDown=subHostDown)
(arbornetworks_products,) = mibBuilder.importSymbols('ARBOR-SMI', 'arbornetworksProducts') (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, constraints_union, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueSizeConstraint', 'ValueRangeConstraint') (if_name,) = mibBuilder.importSymbols('IF-MIB', 'ifName') (ipv6_address_prefix, ipv6_address) = mibBuilder.importSymbols('IPV6-TC', 'Ipv6AddressPrefix', 'Ipv6Address') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (sys_name,) = mibBuilder.importSymbols('SNMPv2-MIB', 'sysName') (integer32, bits, object_identity, module_identity, mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, notification_type, counter64, unsigned32, iso, mib_identifier, time_ticks, counter32, ip_address) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'Bits', 'ObjectIdentity', 'ModuleIdentity', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'NotificationType', 'Counter64', 'Unsigned32', 'iso', 'MibIdentifier', 'TimeTicks', 'Counter32', 'IpAddress') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') peakflow_tms_mib = module_identity((1, 3, 6, 1, 4, 1, 9694, 1, 5)) peakflowTmsMIB.setRevisions(('2013-08-19 00:00', '2012-03-29 12:00', '2012-01-12 12:00', '2011-06-14 16:00', '2011-06-03 16:00', '2011-06-03 00:00', '2011-05-23 00:00', '2011-01-21 00:00', '2010-10-28 00:00', '2010-09-07 00:00', '2009-05-27 00:00', '2009-05-08 00:00', '2009-03-11 00:00', '2009-02-13 00:00', '2008-11-13 00:00', '2008-04-07 00:00', '2007-11-20 00:00', '2007-04-27 00:00')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: peakflowTmsMIB.setRevisionsDescriptions(('Updated contact information', 'Bug#50908: Fix reversed tmsSpCommunication enumerations.', 'Added tmsSystemPrefixesOk and tmsSystemPrefixesMissing traps.', 'Fix stray quote that was causing a syntax error.', 'Added performnace traps.', 'Fixed some typos and grammar problems.', 'Added IPv6 versions of existing IPv4 objects.', 'Added new traps (tmsAutomitigationBgp {Enabled/Disabled/Suspended}) for traffic-triggered automitigation BGP announcements.', 'Added new traps (tmsSpCommunicationDown and tmsSpCommunicationUp) for alerting about failed communication with Peakflow SP.', 'Added new traps (tmsFilesystemCritical and tmsFilesystemNominal) for new filesystem monitoring feature.', 'The March 11 2009 revision had accidentally obsoleted the tmsHostFault OID, rather than the hostFault trap. This is now fixed. The tmsHostFault OID is restored to current status and the hostFault trap is marked obsolete.', 'Update contact group name and company address.', 'Obsoleted the tmsHostFault trap.', 'Added new objects to support TMS 5.0', 'Update contact info.', "Prefixed Textual Conventions with 'Tms' for uniqueness", 'Removed unused Textual Conventions, added display hints', 'Initial revision')) if mibBuilder.loadTexts: peakflowTmsMIB.setLastUpdated('201308190000Z') if mibBuilder.loadTexts: peakflowTmsMIB.setOrganization('Arbor Networks, Inc.') if mibBuilder.loadTexts: peakflowTmsMIB.setContactInfo(' Arbor Networks, Inc. Arbor Technical Assistance Center Postal: 76 Blanchard Road Burlington, MA 01803 USA Tel: +1 866 212 7267 (toll free) +1 781 362 4300 Email: support@arbor.net ') if mibBuilder.loadTexts: peakflowTmsMIB.setDescription('Peakflow TMS MIB') class Tmstableindex(TextualConvention, Integer32): description = 'Used for an index into a table' status = 'current' display_hint = 'd' subtype_spec = Integer32.subtypeSpec + value_range_constraint(1, 2147483647) class Tmstableindexorzero(TextualConvention, Integer32): description = 'The number of items in a table. May be zero if the table is empty.' status = 'current' display_hint = 'd' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 2147483647) class Tmspercentage(TextualConvention, Integer32): description = 'A percentage value (0% - 100%)' status = 'current' display_hint = 'd' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 100) class Tmshundredths(TextualConvention, Integer32): description = 'An integer representing hundredths of a unit' status = 'current' display_hint = 'd-2' peakflow_tms_mgr = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2)) tms_host_fault = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsHostFault.setStatus('current') if mibBuilder.loadTexts: tmsHostFault.setDescription('state of faults within a TMS device') tms_host_up_time = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 2), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsHostUpTime.setStatus('current') if mibBuilder.loadTexts: tmsHostUpTime.setDescription('uptime of this host') device_cpu_load_avg1min = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 3), tms_hundredths()).setMaxAccess('readonly') if mibBuilder.loadTexts: deviceCpuLoadAvg1min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg1min.setDescription('Average number of processes in run queue during last 1 min.') device_cpu_load_avg5min = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 4), tms_hundredths()).setMaxAccess('readonly') if mibBuilder.loadTexts: deviceCpuLoadAvg5min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg5min.setDescription('Average number of processes in run queue during last 5 min.') device_cpu_load_avg15min = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 5), tms_hundredths()).setMaxAccess('readonly') if mibBuilder.loadTexts: deviceCpuLoadAvg15min.setStatus('current') if mibBuilder.loadTexts: deviceCpuLoadAvg15min.setDescription('Average number of processes in run queue during last 15 min.') device_disk_usage = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 6), tms_percentage()).setMaxAccess('readonly') if mibBuilder.loadTexts: deviceDiskUsage.setStatus('current') if mibBuilder.loadTexts: deviceDiskUsage.setDescription('Percentage of primary data partition used.') device_physical_memory_usage = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 7), tms_percentage()).setMaxAccess('readonly') if mibBuilder.loadTexts: devicePhysicalMemoryUsage.setStatus('current') if mibBuilder.loadTexts: devicePhysicalMemoryUsage.setDescription('Percentage of physical memory used.') device_swap_space_usage = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 8), tms_percentage()).setMaxAccess('readonly') if mibBuilder.loadTexts: deviceSwapSpaceUsage.setStatus('current') if mibBuilder.loadTexts: deviceSwapSpaceUsage.setDescription('Percentage of swap space used.') tms_trap_string = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 9), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapString.setStatus('current') if mibBuilder.loadTexts: tmsTrapString.setDescription('Temporary string for reporting information in traps') tms_trap_detail = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 10), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapDetail.setStatus('current') if mibBuilder.loadTexts: tmsTrapDetail.setDescription('Temporary string for reporting additional detail (if any) about a trap') tms_trap_subhost_name = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 11), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapSubhostName.setStatus('current') if mibBuilder.loadTexts: tmsTrapSubhostName.setDescription('Temporary string for reporting the name of a subhost') tms_trap_component_name = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 12), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapComponentName.setStatus('current') if mibBuilder.loadTexts: tmsTrapComponentName.setDescription('Temporary string for reporting the name of a program or device') tms_trap_bgp_peer = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 13), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapBgpPeer.setStatus('current') if mibBuilder.loadTexts: tmsTrapBgpPeer.setDescription('IP address of a BGP peer') tms_trap_gre_source = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 14), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapGreSource.setStatus('current') if mibBuilder.loadTexts: tmsTrapGreSource.setDescription('GRE source IP address') tms_trap_gre_destination = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 15), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapGreDestination.setStatus('current') if mibBuilder.loadTexts: tmsTrapGreDestination.setDescription('GRE destination IP address') tms_trap_nexthop = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 16), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapNexthop.setStatus('current') if mibBuilder.loadTexts: tmsTrapNexthop.setDescription('Nexthop IP address') tms_trap_ipv6_bgp_peer = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 17), ipv6_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapIpv6BgpPeer.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6BgpPeer.setDescription('IPv6 address of a BGP peer') tms_trap_ipv6_gre_source = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 18), ipv6_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapIpv6GreSource.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6GreSource.setDescription('GRE source IPv6 address') tms_trap_ipv6_gre_destination = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 19), ipv6_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapIpv6GreDestination.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6GreDestination.setDescription('GRE destination IPv6 address') tms_trap_ipv6_nexthop = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 2, 20), ipv6_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsTrapIpv6Nexthop.setStatus('current') if mibBuilder.loadTexts: tmsTrapIpv6Nexthop.setDescription('Nexthop IPv6 address') peakflow_tms_traps = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3)) peakflow_tms_traps_enumerate = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0)) host_fault = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 1)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsHostFault')) if mibBuilder.loadTexts: hostFault.setStatus('obsolete') if mibBuilder.loadTexts: hostFault.setDescription('Obsolete; replaced by a number of more specific traps.') gre_tunnel_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 2)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapGreSource'), ('PEAKFLOW-TMS-MIB', 'tmsTrapGreDestination')) if mibBuilder.loadTexts: greTunnelDown.setStatus('current') if mibBuilder.loadTexts: greTunnelDown.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') gre_tunnel_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 3)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapGreSource'), ('PEAKFLOW-TMS-MIB', 'tmsTrapGreDestination')) if mibBuilder.loadTexts: greTunnelUp.setStatus('current') if mibBuilder.loadTexts: greTunnelUp.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tms_link_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 4)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString')) if mibBuilder.loadTexts: tmsLinkUp.setStatus('obsolete') if mibBuilder.loadTexts: tmsLinkUp.setDescription('Obsolete; IF-MIB::linkUp is now used instead') tms_link_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 5)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString')) if mibBuilder.loadTexts: tmsLinkDown.setStatus('obsolete') if mibBuilder.loadTexts: tmsLinkDown.setDescription('Obsolete; IF-MIB::linkDown is now used instead') sub_host_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 6)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapSubhostName')) if mibBuilder.loadTexts: subHostUp.setStatus('current') if mibBuilder.loadTexts: subHostUp.setDescription('Generated when a subhost transitions to active') sub_host_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 7)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapSubhostName')) if mibBuilder.loadTexts: subHostDown.setStatus('current') if mibBuilder.loadTexts: subHostDown.setDescription('Generated when a subhost transitions to inactive') tms_bgp_neighbor_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 8)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapBgpPeer')) if mibBuilder.loadTexts: tmsBgpNeighborDown.setStatus('current') if mibBuilder.loadTexts: tmsBgpNeighborDown.setDescription('Generated when a BGP neighbor transitions out of the ESTABLISHED state') tms_bgp_neighbor_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 9)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapBgpPeer')) if mibBuilder.loadTexts: tmsBgpNeighborUp.setStatus('current') if mibBuilder.loadTexts: tmsBgpNeighborUp.setDescription('Generated when a BGP neighbor transitions into the ESTABLISHED state') tms_nexthop_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 10)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapNexthop'), ('IF-MIB', 'ifName')) if mibBuilder.loadTexts: tmsNexthopDown.setStatus('current') if mibBuilder.loadTexts: tmsNexthopDown.setDescription('Generated when the nexthop host cannot be contacted') tms_nexthop_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 11)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapNexthop'), ('IF-MIB', 'ifName')) if mibBuilder.loadTexts: tmsNexthopUp.setStatus('current') if mibBuilder.loadTexts: tmsNexthopUp.setDescription('Generated when the nexthop host cannot be contacted') tms_mitigation_error = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 12)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationIndex'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationName')) if mibBuilder.loadTexts: tmsMitigationError.setStatus('current') if mibBuilder.loadTexts: tmsMitigationError.setDescription('A mitigation cannot run because of a configuration error') tms_mitigation_suspended = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 13)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationIndex'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationName')) if mibBuilder.loadTexts: tmsMitigationSuspended.setStatus('current') if mibBuilder.loadTexts: tmsMitigationSuspended.setDescription('A mitigation has been suspended due to some external problem (nexthop not reachable, BGP down, etc.)') tms_mitigation_running = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 14)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationIndex'), ('PEAKFLOW-TMS-MIB', 'tmsMitigationName')) if mibBuilder.loadTexts: tmsMitigationRunning.setStatus('current') if mibBuilder.loadTexts: tmsMitigationRunning.setDescription('A previously-detected mitigation problem has been cleared and the mitigation is now running') tms_config_missing = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 15)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsConfigMissing.setStatus('current') if mibBuilder.loadTexts: tmsConfigMissing.setDescription('Generated when a TMS configuration file cannot be found.') tms_config_error = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 16)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsConfigError.setStatus('current') if mibBuilder.loadTexts: tmsConfigError.setDescription('Generated when an error in a TMS configuration file is detected.') tms_config_ok = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 17)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsConfigOk.setStatus('current') if mibBuilder.loadTexts: tmsConfigOk.setDescription('All configuration problems have been corrected.') tms_hw_device_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 18)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsHwDeviceDown.setStatus('current') if mibBuilder.loadTexts: tmsHwDeviceDown.setDescription('A hardware device has failed.') tms_hw_device_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 19)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsHwDeviceUp.setStatus('current') if mibBuilder.loadTexts: tmsHwDeviceUp.setDescription('A hardware device failure has been corrected.') tms_hw_sensor_critical = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 20)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsHwSensorCritical.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorCritical.setDescription('A hardware sensor is reading an alarm condition.') tms_hw_sensor_ok = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 21)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsHwSensorOk.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorOk.setDescription('A hardware sensor is no longer reading an alarm condition.') tms_sw_component_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 22)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapSubhostName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSwComponentDown.setStatus('current') if mibBuilder.loadTexts: tmsSwComponentDown.setDescription('A software program has failed.') tms_sw_component_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 23)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapSubhostName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSwComponentUp.setStatus('current') if mibBuilder.loadTexts: tmsSwComponentUp.setDescription('A software program failure has been corrected.') tms_system_status_critical = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 24)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemStatusCritical.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusCritical.setDescription('The TMS system is experiencing a critical failure.') tms_system_status_degraded = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 25)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemStatusDegraded.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusDegraded.setDescription('The TMS system is experiencing degraded performance.') tms_system_status_nominal = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 26)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemStatusNominal.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusNominal.setDescription('The TMS system has returned to normal behavior.') tms_filesystem_critical = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 27)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsFilesystemCritical.setStatus('current') if mibBuilder.loadTexts: tmsFilesystemCritical.setDescription('A filesystem is near capacity.') tms_filesystem_nominal = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 28)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsFilesystemNominal.setStatus('current') if mibBuilder.loadTexts: tmsFilesystemNominal.setDescription('A filesystem is back below capacity alarm threshold.') tms_hw_sensor_unknown = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 29)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsHwSensorUnknown.setStatus('current') if mibBuilder.loadTexts: tmsHwSensorUnknown.setDescription('A hardware sensor is in an unknown state.') tms_sp_communication_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 30)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSpCommunicationUp.setStatus('current') if mibBuilder.loadTexts: tmsSpCommunicationUp.setDescription('Communication with SP host is up.') tms_sp_communication_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 31)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSpCommunicationDown.setStatus('current') if mibBuilder.loadTexts: tmsSpCommunicationDown.setDescription('Communication with SP host is down.') tms_system_status_error = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 32)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemStatusError.setStatus('current') if mibBuilder.loadTexts: tmsSystemStatusError.setDescription('The TMS system is experiencing an error.') tms_automitigation_bgp_enabled = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 33)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsAutomitigationBgpEnabled.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpEnabled.setDescription('A previously-detected automitigation problem has been cleared and the automitigation BGP announcements have resumed.') tms_automitigation_bgp_disabled = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 34)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsAutomitigationBgpDisabled.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpDisabled.setDescription('Automitigation BGP announcements have been administratively disabled.') tms_automitigation_bgp_suspended = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 35)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsAutomitigationBgpSuspended.setStatus('current') if mibBuilder.loadTexts: tmsAutomitigationBgpSuspended.setDescription('Automitigation BGP announcements have been suspended due to some external problem (nexthop not reachable, BGP down, etc.)') tms_ipv6_gre_tunnel_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 36)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6GreSource'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6GreDestination')) if mibBuilder.loadTexts: tmsIpv6GreTunnelDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6GreTunnelDown.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tms_ipv6_gre_tunnel_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 37)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6GreSource'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6GreDestination')) if mibBuilder.loadTexts: tmsIpv6GreTunnelUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6GreTunnelUp.setDescription('The greTunnelDown/greTunnelUp traps are generated when a GRE tunnel changes state.') tms_ipv6_bgp_neighbor_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 38)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6BgpPeer')) if mibBuilder.loadTexts: tmsIpv6BgpNeighborDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6BgpNeighborDown.setDescription('Generated when a BGP neighbor transitions out of the ESTABLISHED state.') tms_ipv6_bgp_neighbor_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 39)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6BgpPeer')) if mibBuilder.loadTexts: tmsIpv6BgpNeighborUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6BgpNeighborUp.setDescription('Generated when a BGP neighbor transitions into the ESTABLISHED state.') tms_ipv6_nexthop_down = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 40)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6Nexthop'), ('IF-MIB', 'ifName')) if mibBuilder.loadTexts: tmsIpv6NexthopDown.setStatus('current') if mibBuilder.loadTexts: tmsIpv6NexthopDown.setDescription('Generated when the nexthop host becomes unreachable.') tms_ipv6_nexthop_up = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 41)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapIpv6Nexthop'), ('IF-MIB', 'ifName')) if mibBuilder.loadTexts: tmsIpv6NexthopUp.setStatus('current') if mibBuilder.loadTexts: tmsIpv6NexthopUp.setDescription('Generated when the nexthop host becomes reachable.') tms_performance_ok = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 42)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsPerformanceOk.setStatus('current') if mibBuilder.loadTexts: tmsPerformanceOk.setDescription('Generated when the processed traffic rate matches the offered traffic rate.') tms_performance_lossy = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 43)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsPerformanceLossy.setStatus('current') if mibBuilder.loadTexts: tmsPerformanceLossy.setDescription('Generated when the processed traffic rate is lower than the offered traffic rate.') tms_system_prefixes_ok = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 44)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemPrefixesOk.setStatus('current') if mibBuilder.loadTexts: tmsSystemPrefixesOk.setDescription('BGP is currently advertising all mitigation prefixes.') tms_system_prefixes_missing = notification_type((1, 3, 6, 1, 4, 1, 9694, 1, 5, 3, 0, 45)).setObjects(('SNMPv2-MIB', 'sysName'), ('PEAKFLOW-TMS-MIB', 'tmsTrapString'), ('PEAKFLOW-TMS-MIB', 'tmsTrapDetail'), ('PEAKFLOW-TMS-MIB', 'tmsTrapComponentName')) if mibBuilder.loadTexts: tmsSystemPrefixesMissing.setStatus('current') if mibBuilder.loadTexts: tmsSystemPrefixesMissing.setDescription('BGP is not currently advertising all mitigation prefixes.') peakflow_tms_obj = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5)) tms_dpi_config = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1)) tms_version = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsVersion.setStatus('current') if mibBuilder.loadTexts: tmsVersion.setDescription('TMS software version') tms_last_update = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsLastUpdate.setStatus('current') if mibBuilder.loadTexts: tmsLastUpdate.setDescription('Time of the last configuration change') tms_mitigation_config = mib_identifier((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2)) tms_mitigation_last_update = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsMitigationLastUpdate.setStatus('current') if mibBuilder.loadTexts: tmsMitigationLastUpdate.setDescription('Last time Mitigation configuration was updated') tms_mitigation_number = mib_scalar((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 2), tms_table_index_or_zero()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsMitigationNumber.setStatus('current') if mibBuilder.loadTexts: tmsMitigationNumber.setDescription('Number of entries in the tmsMitigation table') tms_mitigation_table = mib_table((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3)) if mibBuilder.loadTexts: tmsMitigationTable.setStatus('current') if mibBuilder.loadTexts: tmsMitigationTable.setDescription('Table of all mitigations in the TMS system') tms_mitigation_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1)).setIndexNames((0, 'PEAKFLOW-TMS-MIB', 'tmsMitigationIndex')) if mibBuilder.loadTexts: tmsMitigationEntry.setStatus('current') if mibBuilder.loadTexts: tmsMitigationEntry.setDescription('Information about a single mitigation') tms_mitigation_index = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 1), tms_table_index()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsMitigationIndex.setStatus('current') if mibBuilder.loadTexts: tmsMitigationIndex.setDescription('Index in the tmsMitigation table. As of release 5.0 this is the same as the tmsMitigationId.') tms_mitigation_id = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsMitigationId.setStatus('current') if mibBuilder.loadTexts: tmsMitigationId.setDescription('ID number of this mitigation') tms_destination_prefix = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 3), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsDestinationPrefix.setStatus('current') if mibBuilder.loadTexts: tmsDestinationPrefix.setDescription('Destination IPv4 prefix to which this mitigation applies. The value 0.0.0.0/32 indicates that the mitigation has no IPv4 prefix.') tms_destination_prefix_mask = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 32))).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsDestinationPrefixMask.setStatus('current') if mibBuilder.loadTexts: tmsDestinationPrefixMask.setDescription('Destination IPv4 prefix to which this mitigation applies. The value 0.0.0.0/32 indicates that the mitigation has no IPv4 prefix.') tms_mitigation_name = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 5), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsMitigationName.setStatus('current') if mibBuilder.loadTexts: tmsMitigationName.setDescription('Name of this mitigation') tms_ipv6_destination_prefix = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 6), ipv6_address_prefix()).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsIpv6DestinationPrefix.setStatus('current') if mibBuilder.loadTexts: tmsIpv6DestinationPrefix.setDescription('Destination IPv6 prefix to which this mitigation applies. The value 0::/128 indicates that the mitigation has no IPv6 prefix.') tms_ipv6_destination_prefix_mask = mib_table_column((1, 3, 6, 1, 4, 1, 9694, 1, 5, 5, 2, 3, 1, 7), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 128))).setMaxAccess('readonly') if mibBuilder.loadTexts: tmsIpv6DestinationPrefixMask.setStatus('current') if mibBuilder.loadTexts: tmsIpv6DestinationPrefixMask.setDescription('Destination IPv6 prefix to which this mitigation applies. The value 0::/128 indicates that the mitigation has no IPv6 prefix.') mibBuilder.exportSymbols('PEAKFLOW-TMS-MIB', tmsConfigError=tmsConfigError, tmsTrapNexthop=tmsTrapNexthop, devicePhysicalMemoryUsage=devicePhysicalMemoryUsage, tmsTrapString=tmsTrapString, tmsIpv6DestinationPrefixMask=tmsIpv6DestinationPrefixMask, tmsNexthopUp=tmsNexthopUp, tmsPerformanceLossy=tmsPerformanceLossy, tmsConfigOk=tmsConfigOk, tmsTrapGreDestination=tmsTrapGreDestination, tmsHostFault=tmsHostFault, tmsFilesystemNominal=tmsFilesystemNominal, tmsSpCommunicationDown=tmsSpCommunicationDown, tmsSystemPrefixesMissing=tmsSystemPrefixesMissing, tmsTrapIpv6Nexthop=tmsTrapIpv6Nexthop, peakflowTmsObj=peakflowTmsObj, tmsLastUpdate=tmsLastUpdate, tmsMitigationId=tmsMitigationId, tmsMitigationConfig=tmsMitigationConfig, tmsMitigationLastUpdate=tmsMitigationLastUpdate, tmsMitigationError=tmsMitigationError, deviceDiskUsage=deviceDiskUsage, tmsMitigationIndex=tmsMitigationIndex, peakflowTmsTrapsEnumerate=peakflowTmsTrapsEnumerate, tmsIpv6GreTunnelUp=tmsIpv6GreTunnelUp, tmsBgpNeighborUp=tmsBgpNeighborUp, tmsMitigationEntry=tmsMitigationEntry, deviceCpuLoadAvg1min=deviceCpuLoadAvg1min, tmsMitigationNumber=tmsMitigationNumber, peakflowTmsMgr=peakflowTmsMgr, tmsSystemPrefixesOk=tmsSystemPrefixesOk, greTunnelDown=greTunnelDown, subHostUp=subHostUp, tmsLinkUp=tmsLinkUp, tmsBgpNeighborDown=tmsBgpNeighborDown, tmsLinkDown=tmsLinkDown, tmsMitigationTable=tmsMitigationTable, tmsSwComponentDown=tmsSwComponentDown, tmsIpv6NexthopUp=tmsIpv6NexthopUp, tmsTrapComponentName=tmsTrapComponentName, tmsIpv6BgpNeighborDown=tmsIpv6BgpNeighborDown, hostFault=hostFault, tmsPerformanceOk=tmsPerformanceOk, tmsHostUpTime=tmsHostUpTime, tmsVersion=tmsVersion, tmsIpv6GreTunnelDown=tmsIpv6GreTunnelDown, tmsTrapGreSource=tmsTrapGreSource, tmsAutomitigationBgpSuspended=tmsAutomitigationBgpSuspended, tmsHwDeviceDown=tmsHwDeviceDown, tmsMitigationSuspended=tmsMitigationSuspended, PYSNMP_MODULE_ID=peakflowTmsMIB, tmsAutomitigationBgpDisabled=tmsAutomitigationBgpDisabled, tmsTrapIpv6GreSource=tmsTrapIpv6GreSource, tmsNexthopDown=tmsNexthopDown, greTunnelUp=greTunnelUp, tmsSwComponentUp=tmsSwComponentUp, tmsSystemStatusNominal=tmsSystemStatusNominal, tmsHwDeviceUp=tmsHwDeviceUp, TmsTableIndexOrZero=TmsTableIndexOrZero, tmsTrapIpv6BgpPeer=tmsTrapIpv6BgpPeer, deviceSwapSpaceUsage=deviceSwapSpaceUsage, tmsSystemStatusDegraded=tmsSystemStatusDegraded, peakflowTmsTraps=peakflowTmsTraps, tmsDestinationPrefixMask=tmsDestinationPrefixMask, tmsHwSensorCritical=tmsHwSensorCritical, peakflowTmsMIB=peakflowTmsMIB, tmsDpiConfig=tmsDpiConfig, tmsFilesystemCritical=tmsFilesystemCritical, tmsIpv6NexthopDown=tmsIpv6NexthopDown, tmsConfigMissing=tmsConfigMissing, tmsTrapBgpPeer=tmsTrapBgpPeer, deviceCpuLoadAvg15min=deviceCpuLoadAvg15min, tmsIpv6DestinationPrefix=tmsIpv6DestinationPrefix, tmsTrapDetail=tmsTrapDetail, deviceCpuLoadAvg5min=deviceCpuLoadAvg5min, tmsIpv6BgpNeighborUp=tmsIpv6BgpNeighborUp, TmsPercentage=TmsPercentage, tmsSystemStatusError=tmsSystemStatusError, tmsSystemStatusCritical=tmsSystemStatusCritical, tmsTrapSubhostName=tmsTrapSubhostName, TmsTableIndex=TmsTableIndex, tmsHwSensorOk=tmsHwSensorOk, tmsMitigationName=tmsMitigationName, tmsMitigationRunning=tmsMitigationRunning, TmsHundredths=TmsHundredths, tmsTrapIpv6GreDestination=tmsTrapIpv6GreDestination, tmsDestinationPrefix=tmsDestinationPrefix, tmsAutomitigationBgpEnabled=tmsAutomitigationBgpEnabled, tmsSpCommunicationUp=tmsSpCommunicationUp, tmsHwSensorUnknown=tmsHwSensorUnknown, subHostDown=subHostDown)
# # PySNMP MIB module ENTERASYS-ENCR-8021X-REKEYING-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-ENCR-8021X-REKEYING-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:48:58 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") ConstraintsUnion, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint") etsysModules, = mibBuilder.importSymbols("ENTERASYS-MIB-NAMES", "etsysModules") dot1xPaePortNumber, = mibBuilder.importSymbols("IEEE8021-PAE-MIB", "dot1xPaePortNumber") NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") Counter64, Integer32, Counter32, ObjectIdentity, NotificationType, iso, Unsigned32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, MibIdentifier, IpAddress, TimeTicks, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "Integer32", "Counter32", "ObjectIdentity", "NotificationType", "iso", "Unsigned32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "MibIdentifier", "IpAddress", "TimeTicks", "Gauge32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") etsysEncr8021xRekeyingMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20)) etsysEncr8021xRekeyingMIB.setRevisions(('2002-03-14 20:49',)) if mibBuilder.loadTexts: etsysEncr8021xRekeyingMIB.setLastUpdated('200203142049Z') if mibBuilder.loadTexts: etsysEncr8021xRekeyingMIB.setOrganization('Enterasys Networks, Inc') etsysEncrDot1xRekeyingObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1)) etsysEncrDot1xRekeyBaseBranch = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1)) etsysEncrDot1xRekeyConfigTable = MibTable((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1), ) if mibBuilder.loadTexts: etsysEncrDot1xRekeyConfigTable.setStatus('current') etsysEncrDot1xRekeyConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1), ).setIndexNames((0, "IEEE8021-PAE-MIB", "dot1xPaePortNumber")) if mibBuilder.loadTexts: etsysEncrDot1xRekeyConfigEntry.setStatus('current') etsysEncrDot1xRekeyEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: etsysEncrDot1xRekeyEnabled.setStatus('current') etsysEncrDot1xRekeyPeriod = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: etsysEncrDot1xRekeyPeriod.setStatus('current') etsysEncrDot1xRekeyLength = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: etsysEncrDot1xRekeyLength.setStatus('current') etsysEncrDot1xRekeyAsymmetric = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: etsysEncrDot1xRekeyAsymmetric.setStatus('current') etsysEncrDot1xRekeyingConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2)) etsysEncrDot1xRekeyingGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 1)) etsysEncrDot1xRekeyingCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 2)) etsysEncrDot1xRekeyingBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 1, 1)).setObjects(("ENTERASYS-ENCR-8021X-REKEYING-MIB", "etsysEncrDot1xRekeyPeriod"), ("ENTERASYS-ENCR-8021X-REKEYING-MIB", "etsysEncrDot1xRekeyEnabled"), ("ENTERASYS-ENCR-8021X-REKEYING-MIB", "etsysEncrDot1xRekeyLength"), ("ENTERASYS-ENCR-8021X-REKEYING-MIB", "etsysEncrDot1xRekeyAsymmetric")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): etsysEncrDot1xRekeyingBaseGroup = etsysEncrDot1xRekeyingBaseGroup.setStatus('current') etsysEncrDot1xRekeyingCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 2, 1)).setObjects(("ENTERASYS-ENCR-8021X-REKEYING-MIB", "etsysEncrDot1xRekeyingBaseGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): etsysEncrDot1xRekeyingCompliance = etsysEncrDot1xRekeyingCompliance.setStatus('current') mibBuilder.exportSymbols("ENTERASYS-ENCR-8021X-REKEYING-MIB", etsysEncrDot1xRekeyingCompliances=etsysEncrDot1xRekeyingCompliances, etsysEncrDot1xRekeyingGroups=etsysEncrDot1xRekeyingGroups, PYSNMP_MODULE_ID=etsysEncr8021xRekeyingMIB, etsysEncrDot1xRekeyPeriod=etsysEncrDot1xRekeyPeriod, etsysEncrDot1xRekeyingObjects=etsysEncrDot1xRekeyingObjects, etsysEncrDot1xRekeyingBaseGroup=etsysEncrDot1xRekeyingBaseGroup, etsysEncrDot1xRekeyConfigEntry=etsysEncrDot1xRekeyConfigEntry, etsysEncrDot1xRekeyingConformance=etsysEncrDot1xRekeyingConformance, etsysEncrDot1xRekeyEnabled=etsysEncrDot1xRekeyEnabled, etsysEncrDot1xRekeyingCompliance=etsysEncrDot1xRekeyingCompliance, etsysEncr8021xRekeyingMIB=etsysEncr8021xRekeyingMIB, etsysEncrDot1xRekeyAsymmetric=etsysEncrDot1xRekeyAsymmetric, etsysEncrDot1xRekeyLength=etsysEncrDot1xRekeyLength, etsysEncrDot1xRekeyBaseBranch=etsysEncrDot1xRekeyBaseBranch, etsysEncrDot1xRekeyConfigTable=etsysEncrDot1xRekeyConfigTable)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint') (etsys_modules,) = mibBuilder.importSymbols('ENTERASYS-MIB-NAMES', 'etsysModules') (dot1x_pae_port_number,) = mibBuilder.importSymbols('IEEE8021-PAE-MIB', 'dot1xPaePortNumber') (notification_group, object_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ObjectGroup', 'ModuleCompliance') (counter64, integer32, counter32, object_identity, notification_type, iso, unsigned32, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, mib_identifier, ip_address, time_ticks, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'Integer32', 'Counter32', 'ObjectIdentity', 'NotificationType', 'iso', 'Unsigned32', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'MibIdentifier', 'IpAddress', 'TimeTicks', 'Gauge32') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') etsys_encr8021x_rekeying_mib = module_identity((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20)) etsysEncr8021xRekeyingMIB.setRevisions(('2002-03-14 20:49',)) if mibBuilder.loadTexts: etsysEncr8021xRekeyingMIB.setLastUpdated('200203142049Z') if mibBuilder.loadTexts: etsysEncr8021xRekeyingMIB.setOrganization('Enterasys Networks, Inc') etsys_encr_dot1x_rekeying_objects = mib_identifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1)) etsys_encr_dot1x_rekey_base_branch = mib_identifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1)) etsys_encr_dot1x_rekey_config_table = mib_table((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1)) if mibBuilder.loadTexts: etsysEncrDot1xRekeyConfigTable.setStatus('current') etsys_encr_dot1x_rekey_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1)).setIndexNames((0, 'IEEE8021-PAE-MIB', 'dot1xPaePortNumber')) if mibBuilder.loadTexts: etsysEncrDot1xRekeyConfigEntry.setStatus('current') etsys_encr_dot1x_rekey_enabled = mib_table_column((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 1), octet_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: etsysEncrDot1xRekeyEnabled.setStatus('current') etsys_encr_dot1x_rekey_period = mib_table_column((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 2), octet_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: etsysEncrDot1xRekeyPeriod.setStatus('current') etsys_encr_dot1x_rekey_length = mib_table_column((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 3), octet_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: etsysEncrDot1xRekeyLength.setStatus('current') etsys_encr_dot1x_rekey_asymmetric = mib_table_column((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 1, 1, 1, 1, 4), octet_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: etsysEncrDot1xRekeyAsymmetric.setStatus('current') etsys_encr_dot1x_rekeying_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2)) etsys_encr_dot1x_rekeying_groups = mib_identifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 1)) etsys_encr_dot1x_rekeying_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 2)) etsys_encr_dot1x_rekeying_base_group = object_group((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 1, 1)).setObjects(('ENTERASYS-ENCR-8021X-REKEYING-MIB', 'etsysEncrDot1xRekeyPeriod'), ('ENTERASYS-ENCR-8021X-REKEYING-MIB', 'etsysEncrDot1xRekeyEnabled'), ('ENTERASYS-ENCR-8021X-REKEYING-MIB', 'etsysEncrDot1xRekeyLength'), ('ENTERASYS-ENCR-8021X-REKEYING-MIB', 'etsysEncrDot1xRekeyAsymmetric')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): etsys_encr_dot1x_rekeying_base_group = etsysEncrDot1xRekeyingBaseGroup.setStatus('current') etsys_encr_dot1x_rekeying_compliance = module_compliance((1, 3, 6, 1, 4, 1, 5624, 1, 2, 20, 2, 2, 1)).setObjects(('ENTERASYS-ENCR-8021X-REKEYING-MIB', 'etsysEncrDot1xRekeyingBaseGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): etsys_encr_dot1x_rekeying_compliance = etsysEncrDot1xRekeyingCompliance.setStatus('current') mibBuilder.exportSymbols('ENTERASYS-ENCR-8021X-REKEYING-MIB', etsysEncrDot1xRekeyingCompliances=etsysEncrDot1xRekeyingCompliances, etsysEncrDot1xRekeyingGroups=etsysEncrDot1xRekeyingGroups, PYSNMP_MODULE_ID=etsysEncr8021xRekeyingMIB, etsysEncrDot1xRekeyPeriod=etsysEncrDot1xRekeyPeriod, etsysEncrDot1xRekeyingObjects=etsysEncrDot1xRekeyingObjects, etsysEncrDot1xRekeyingBaseGroup=etsysEncrDot1xRekeyingBaseGroup, etsysEncrDot1xRekeyConfigEntry=etsysEncrDot1xRekeyConfigEntry, etsysEncrDot1xRekeyingConformance=etsysEncrDot1xRekeyingConformance, etsysEncrDot1xRekeyEnabled=etsysEncrDot1xRekeyEnabled, etsysEncrDot1xRekeyingCompliance=etsysEncrDot1xRekeyingCompliance, etsysEncr8021xRekeyingMIB=etsysEncr8021xRekeyingMIB, etsysEncrDot1xRekeyAsymmetric=etsysEncrDot1xRekeyAsymmetric, etsysEncrDot1xRekeyLength=etsysEncrDot1xRekeyLength, etsysEncrDot1xRekeyBaseBranch=etsysEncrDot1xRekeyBaseBranch, etsysEncrDot1xRekeyConfigTable=etsysEncrDot1xRekeyConfigTable)
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-05-24 18:24:44 # Description: class Solution(object): def findLadders(self, beginWord, endWord, wordList): wordList = set(wordList) res = [] layer = {} layer[beginWord] = [[beginWord]] while layer: newlayer = collections.defaultdict(list) for w in layer: if w == endWord: res.extend(k for k in layer[w]) else: for i in range(len(w)): for c in 'abcdefghijklmnopqrstuvwxyz': neww = w[:i] + c + w[i + 1:] if neww in wordList: newlayer[neww] += [ j + [neww] for j in layer[w] ] wordList -= set(newlayer.keys()) layer = newlayer return res if __name__ == "__main__": pass
class Solution(object): def find_ladders(self, beginWord, endWord, wordList): word_list = set(wordList) res = [] layer = {} layer[beginWord] = [[beginWord]] while layer: newlayer = collections.defaultdict(list) for w in layer: if w == endWord: res.extend((k for k in layer[w])) else: for i in range(len(w)): for c in 'abcdefghijklmnopqrstuvwxyz': neww = w[:i] + c + w[i + 1:] if neww in wordList: newlayer[neww] += [j + [neww] for j in layer[w]] word_list -= set(newlayer.keys()) layer = newlayer return res if __name__ == '__main__': pass
# -*- coding: utf-8 -*- class Attendance(object): def __init__(self, user_id, timestamp, status, punch=0, uid=0): self.uid = uid # not really used any more self.user_id = user_id self.timestamp = timestamp self.status = status self.punch = punch def __str__(self): return '<Attendance>: {} : {} ({}, {})'.format(self.user_id, self.timestamp, self.status, self.punch) def __repr__(self): return '<Attendance>: {} : {} ({}, {})'.format(self.user_id, self.timestamp,self.status, self.punch)
class Attendance(object): def __init__(self, user_id, timestamp, status, punch=0, uid=0): self.uid = uid self.user_id = user_id self.timestamp = timestamp self.status = status self.punch = punch def __str__(self): return '<Attendance>: {} : {} ({}, {})'.format(self.user_id, self.timestamp, self.status, self.punch) def __repr__(self): return '<Attendance>: {} : {} ({}, {})'.format(self.user_id, self.timestamp, self.status, self.punch)
# admins defines who can issue admin-level commands to the bot. Looks like this: # admins = ["First Admin", "second admin", "xXx third admin-dono xXX"] #please be precise, else python pukes up an error. TIA. admins = ["Exo", "Kalikrates"] #This is the login infor for the account Cogito runs over. account= "Cogito" character= "Cogito" password= "1ChD3Nk34Ls=!" #For channels, make sure you enter their PRECISE title, including any trailing spaces and/or punctuation! #channels= ['Development'] channels= ['Gay/Bi Male Human(oid)s. ', 'Coaches, Sweat and Muscles', 'Manly Males of Extra Manly Manliness', 'The Felines Lair~!'] host= 'chat.f-list.net' port= 9722 #9722 - Real | 8722 - Dev version= "2.1" banter = True banterchance = 1.0 messagelimit = 7 minSendDelay = 1.0 #Format: Command : (function_name, level required for access, message type required for access.) #levels: #2: normal user. #1: channel admin/chat admin. #0: admin defined above, in config.py #message types: #0: private message #1: in-channel #2: in-channel, mentioning config.character; e.g. Cogito: <function> functions = { ".shutdown": ("hibernation", 0, [0]), ".join": ("join", 0, [0,1]), ".leave": ("leave", 0, [0,1]), ".lockdown": ("lockdown", 0, [0,1,2]), ".minage": ("minage", 0, [0,1]), ".scan": ("scan", 0, [1]), ".act": ("act", 1, [0,1]), ".noAge": ("alertNoAge", 1, [0,1]), ".underAge": ("alertUnderAge", 1, [0,1]), ".ban": ("ban", 1, [0,1]), ".black": ("blacklist", 1, [0,1]), ".deop": ("deop", 1, [0,1]), ".kick": ("kick", 1, [0,1]), ".lj": ("lastJoined", 1, [0,1]), ".op": ("op", 1, [0,1]), ".r": ("rainbowText", 1, [0,1]), ".say": ("say", 1, [0,1]), ".white": ("whitelist", 1, [0,1]), ".ignore": ("ignore", 1, [1]), ".auth": ("auth", 2, [0]), ".bingo": ("bingo", 2, [0,1]), ".lc": ("listIndices", 2, [0]), ".help": ("help", 2, [0,1]), ".tell": ("tell", 2, [0,1])} masterkey = "425133f6b2a9a881d9dc67f5db17179e"
admins = ['Exo', 'Kalikrates'] account = 'Cogito' character = 'Cogito' password = '1ChD3Nk34Ls=!' channels = ['Gay/Bi Male Human(oid)s. ', 'Coaches, Sweat and Muscles', 'Manly Males of Extra Manly Manliness', 'The Felines Lair~!'] host = 'chat.f-list.net' port = 9722 version = '2.1' banter = True banterchance = 1.0 messagelimit = 7 min_send_delay = 1.0 functions = {'.shutdown': ('hibernation', 0, [0]), '.join': ('join', 0, [0, 1]), '.leave': ('leave', 0, [0, 1]), '.lockdown': ('lockdown', 0, [0, 1, 2]), '.minage': ('minage', 0, [0, 1]), '.scan': ('scan', 0, [1]), '.act': ('act', 1, [0, 1]), '.noAge': ('alertNoAge', 1, [0, 1]), '.underAge': ('alertUnderAge', 1, [0, 1]), '.ban': ('ban', 1, [0, 1]), '.black': ('blacklist', 1, [0, 1]), '.deop': ('deop', 1, [0, 1]), '.kick': ('kick', 1, [0, 1]), '.lj': ('lastJoined', 1, [0, 1]), '.op': ('op', 1, [0, 1]), '.r': ('rainbowText', 1, [0, 1]), '.say': ('say', 1, [0, 1]), '.white': ('whitelist', 1, [0, 1]), '.ignore': ('ignore', 1, [1]), '.auth': ('auth', 2, [0]), '.bingo': ('bingo', 2, [0, 1]), '.lc': ('listIndices', 2, [0]), '.help': ('help', 2, [0, 1]), '.tell': ('tell', 2, [0, 1])} masterkey = '425133f6b2a9a881d9dc67f5db17179e'
"""Define class ModelParams which has relevant attributes Params ------ transmission_rate: float sip_start_date: int initial_infection_multiplier: float prison_infection_rate = None: float police_contact_rate = None: float police_group_size = int Returns ------- an object of the class ModelParams that has attributes for each of the above parameters """ class ModelParams: def __init__(self, transmission_rate, sip_start_date, initial_infection_multiplier, prison_infection_rate = None, police_contact_rate = None, police_group_size = None): self.transmission_rate = transmission_rate self.sip_start_date = sip_start_date self.initial_infection_multiplier = initial_infection_multiplier self.prison_infection_rate = prison_infection_rate self.police_contact_rate = police_contact_rate self.police_group_size = police_group_size """Add attributes based on parameters we modified for uncertainty calculations """ def add_uncertainty_params(self, infection, pc, pgrp): self.prison_infection_rate = infection self.police_contact_rate = pc self.police_group_size = pgrp return self """Format name that is suitable for these model params """ def get_name(self): suffix = '_pc%s_pgrp%s'%(self.police_contact_rate, self.police_group_size) name = 'I%s_PI%s_L%s'%(self.initial_infection_multiplier, self.prison_infection_rate, self.sip_start_date) + \ "__" + suffix return name
"""Define class ModelParams which has relevant attributes Params ------ transmission_rate: float sip_start_date: int initial_infection_multiplier: float prison_infection_rate = None: float police_contact_rate = None: float police_group_size = int Returns ------- an object of the class ModelParams that has attributes for each of the above parameters """ class Modelparams: def __init__(self, transmission_rate, sip_start_date, initial_infection_multiplier, prison_infection_rate=None, police_contact_rate=None, police_group_size=None): self.transmission_rate = transmission_rate self.sip_start_date = sip_start_date self.initial_infection_multiplier = initial_infection_multiplier self.prison_infection_rate = prison_infection_rate self.police_contact_rate = police_contact_rate self.police_group_size = police_group_size 'Add attributes based on parameters we modified for uncertainty calculations\n ' def add_uncertainty_params(self, infection, pc, pgrp): self.prison_infection_rate = infection self.police_contact_rate = pc self.police_group_size = pgrp return self 'Format name that is suitable for these model params\n ' def get_name(self): suffix = '_pc%s_pgrp%s' % (self.police_contact_rate, self.police_group_size) name = 'I%s_PI%s_L%s' % (self.initial_infection_multiplier, self.prison_infection_rate, self.sip_start_date) + '__' + suffix return name
class Solution: def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ index = 0 for i in range(0,len(nums)): if nums[i] != 0: nums[index] = nums[i] index += 1 nums[index:] = (len(nums) - index) * [0]
class Solution: def move_zeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ index = 0 for i in range(0, len(nums)): if nums[i] != 0: nums[index] = nums[i] index += 1 nums[index:] = (len(nums) - index) * [0]
class Fraction: def __init__(self, n, den=1): if isinstance(n, float): string = str(n) decimalCount = len(string[string.find("."):]) - 1 self.numerator = int(n * 10 ** decimalCount) self.denominator = int(10 ** decimalCount) self.reduce(self) else: self.numerator = n self.denominator = den @staticmethod def gcd(a, b): while b: a, b = b, a % b return a @staticmethod def lcm(a, b): return a * b // Fraction.gcd(a, b) @staticmethod def reduce(frac: "Fraction"): gcd = Fraction.gcd(frac.numerator, frac.denominator) frac.numerator //= gcd frac.denominator //= gcd return frac @property def decimal(self): return self.numerator / self.denominator def __mul__(self, other): otherF = Fraction(other) if not isinstance(other, Fraction) else other frac = Fraction(1) frac.numerator = self.numerator * otherF.numerator frac.denominator = self.denominator * otherF.denominator return self.reduce(frac) def __rmul__(self, other): return self.__mul__(other) def __truediv__(self, other): otherF = Fraction(other) if not isinstance(other, Fraction) else other frac = Fraction(1) frac.numerator, frac.denominator = otherF.denominator, otherF.numerator return self.__mul__(frac) def __rtruediv__(self, other): frac = Fraction(1) frac.numerator, frac.denominator = self.denominator, self.numerator return frac * other def __floordiv__(self, other): return self.__truediv__(other) def __rfloordiv__(self, other): return self.__rtruediv__(other) def __add__(self, other): otherF = Fraction(other) if not isinstance(other, Fraction) else other frac = Fraction(1) lcm = Fraction.lcm(self.denominator, otherF.denominator) frac.denominator = lcm frac.numerator = self.numerator * lcm // self.denominator + otherF.numerator * lcm // otherF.denominator return self.reduce(frac) def __radd__(self, other): return self.__add__(other) def __sub__(self, other): otherF = Fraction(other) if not isinstance(other, Fraction) else other frac = Fraction(1) frac.numerator = otherF.numerator * -1 frac.denominator = otherF.denominator return self.__add__(frac) def __rsub__(self, other): return self.__neg__().__add__(other) def __neg__(self): frac = Fraction(1) frac.numerator, frac.denominator = -self.numerator, self.denominator return frac def __str__(self): if self.denominator == 1 or self.numerator == 0: return f"{self.numerator}" else: return f"{self.numerator}/{self.denominator}" """ fraction1 = Fraction(0.25) fraction2 = Fraction(0.2) print(fraction1, fraction2) print(-fraction1, -fraction2) print(fraction1 - 3) print(3 - fraction1) print(fraction1 + 2) print(2 + fraction1) print(fraction1 * fraction2) print(fraction2 * fraction1) print(fraction1 / fraction2) print(fraction2 / fraction1) """
class Fraction: def __init__(self, n, den=1): if isinstance(n, float): string = str(n) decimal_count = len(string[string.find('.'):]) - 1 self.numerator = int(n * 10 ** decimalCount) self.denominator = int(10 ** decimalCount) self.reduce(self) else: self.numerator = n self.denominator = den @staticmethod def gcd(a, b): while b: (a, b) = (b, a % b) return a @staticmethod def lcm(a, b): return a * b // Fraction.gcd(a, b) @staticmethod def reduce(frac: 'Fraction'): gcd = Fraction.gcd(frac.numerator, frac.denominator) frac.numerator //= gcd frac.denominator //= gcd return frac @property def decimal(self): return self.numerator / self.denominator def __mul__(self, other): other_f = fraction(other) if not isinstance(other, Fraction) else other frac = fraction(1) frac.numerator = self.numerator * otherF.numerator frac.denominator = self.denominator * otherF.denominator return self.reduce(frac) def __rmul__(self, other): return self.__mul__(other) def __truediv__(self, other): other_f = fraction(other) if not isinstance(other, Fraction) else other frac = fraction(1) (frac.numerator, frac.denominator) = (otherF.denominator, otherF.numerator) return self.__mul__(frac) def __rtruediv__(self, other): frac = fraction(1) (frac.numerator, frac.denominator) = (self.denominator, self.numerator) return frac * other def __floordiv__(self, other): return self.__truediv__(other) def __rfloordiv__(self, other): return self.__rtruediv__(other) def __add__(self, other): other_f = fraction(other) if not isinstance(other, Fraction) else other frac = fraction(1) lcm = Fraction.lcm(self.denominator, otherF.denominator) frac.denominator = lcm frac.numerator = self.numerator * lcm // self.denominator + otherF.numerator * lcm // otherF.denominator return self.reduce(frac) def __radd__(self, other): return self.__add__(other) def __sub__(self, other): other_f = fraction(other) if not isinstance(other, Fraction) else other frac = fraction(1) frac.numerator = otherF.numerator * -1 frac.denominator = otherF.denominator return self.__add__(frac) def __rsub__(self, other): return self.__neg__().__add__(other) def __neg__(self): frac = fraction(1) (frac.numerator, frac.denominator) = (-self.numerator, self.denominator) return frac def __str__(self): if self.denominator == 1 or self.numerator == 0: return f'{self.numerator}' else: return f'{self.numerator}/{self.denominator}' '\nfraction1 = Fraction(0.25)\nfraction2 = Fraction(0.2)\n\nprint(fraction1, fraction2)\nprint(-fraction1, -fraction2)\n\nprint(fraction1 - 3)\nprint(3 - fraction1)\n\nprint(fraction1 + 2)\nprint(2 + fraction1)\n\nprint(fraction1 * fraction2)\nprint(fraction2 * fraction1)\n\nprint(fraction1 / fraction2)\nprint(fraction2 / fraction1)\n'
class NodeTemplate(object): def __init__(self, name): self.name = name def to_dict(self): raise NotImplementedError() def get_attr(self, attribute): return {'get_attribute': [self.name, attribute]} class RSAKey(NodeTemplate): def __init__(self, name, key_name, openssh_format=True, use_secret_store=True, use_secrets_if_exist=True, store_private_key_material=True): super(RSAKey, self).__init__(name) self.key_name = key_name self.openssh_format = openssh_format self.use_secret_store = use_secret_store self.use_secrets_if_exist = use_secrets_if_exist self.store_private_key_material = store_private_key_material def to_dict(self): return { 'type': 'cloudify.keys.nodes.RSAKey', 'properties': { 'resource_config': { 'key_name': self.key_name, 'openssh_format': self.openssh_format }, 'use_secret_store': self.use_secret_store, 'use_secrets_if_exist': self.use_secrets_if_exist }, 'interfaces': { 'cloudify.interfaces.lifecycle': { 'create': { 'implementation': 'keys.cloudify_ssh_key.operations.create', 'inputs': { 'store_private_key_material': self.store_private_key_material } } } } } class CloudInit(NodeTemplate): def __init__(self, name, agent_user, ssh_authorized_keys): super(CloudInit, self).__init__(name) self.agent_user = agent_user self.ssh_authorized_keys = ssh_authorized_keys def to_dict(self): return { 'type': 'cloudify.nodes.CloudInit.CloudConfig', 'properties': { 'resource_config': { 'users': [ {'name': self.agent_user, 'shell': '/bin/bash', 'sudo': ['ALL=(ALL) NOPASSWD:ALL'], 'ssh-authorized-keys': self.ssh_authorized_keys} ] } }, 'relationships': [ {'type': 'cloudify.relationships.depends_on', 'target': 'agent_key'} ] }
class Nodetemplate(object): def __init__(self, name): self.name = name def to_dict(self): raise not_implemented_error() def get_attr(self, attribute): return {'get_attribute': [self.name, attribute]} class Rsakey(NodeTemplate): def __init__(self, name, key_name, openssh_format=True, use_secret_store=True, use_secrets_if_exist=True, store_private_key_material=True): super(RSAKey, self).__init__(name) self.key_name = key_name self.openssh_format = openssh_format self.use_secret_store = use_secret_store self.use_secrets_if_exist = use_secrets_if_exist self.store_private_key_material = store_private_key_material def to_dict(self): return {'type': 'cloudify.keys.nodes.RSAKey', 'properties': {'resource_config': {'key_name': self.key_name, 'openssh_format': self.openssh_format}, 'use_secret_store': self.use_secret_store, 'use_secrets_if_exist': self.use_secrets_if_exist}, 'interfaces': {'cloudify.interfaces.lifecycle': {'create': {'implementation': 'keys.cloudify_ssh_key.operations.create', 'inputs': {'store_private_key_material': self.store_private_key_material}}}}} class Cloudinit(NodeTemplate): def __init__(self, name, agent_user, ssh_authorized_keys): super(CloudInit, self).__init__(name) self.agent_user = agent_user self.ssh_authorized_keys = ssh_authorized_keys def to_dict(self): return {'type': 'cloudify.nodes.CloudInit.CloudConfig', 'properties': {'resource_config': {'users': [{'name': self.agent_user, 'shell': '/bin/bash', 'sudo': ['ALL=(ALL) NOPASSWD:ALL'], 'ssh-authorized-keys': self.ssh_authorized_keys}]}}, 'relationships': [{'type': 'cloudify.relationships.depends_on', 'target': 'agent_key'}]}
class Solution: def findSmallestRegion(self, regions: List[List[str]], region1: str, region2: str) -> str: seen = set() graph = {} for nodes in regions: root = nodes[0] if root not in graph: graph[root] = root for child in nodes[1:]: graph[child] = root paths1 = self.search(region1, graph) paths2 = self.search(region2, graph) length = min(len(paths1), len(paths2)) index = length for i in range(length): if paths1[i] != paths2[i]: index = i break return paths1[index - 1] def search(self, region, graph): paths = [] root = region while graph[root] != root: paths.append(root) root = graph[root] paths.append(root) return paths[::-1]
class Solution: def find_smallest_region(self, regions: List[List[str]], region1: str, region2: str) -> str: seen = set() graph = {} for nodes in regions: root = nodes[0] if root not in graph: graph[root] = root for child in nodes[1:]: graph[child] = root paths1 = self.search(region1, graph) paths2 = self.search(region2, graph) length = min(len(paths1), len(paths2)) index = length for i in range(length): if paths1[i] != paths2[i]: index = i break return paths1[index - 1] def search(self, region, graph): paths = [] root = region while graph[root] != root: paths.append(root) root = graph[root] paths.append(root) return paths[::-1]
# -*- coding: utf-8 -*- """This module contains the blueprint app configuration""" # The namespace of the application. Used to prevent collisions in supporting services across # applications. If not set here, the app's enclosing directory name is used. # APP_NAMESPACE = 'app-name' # Dictionaries for the various NLP classifier configurations # Logistic regression model for intent classification INTENT_CLASSIFIER_CONFIG = { "model_type": "text", "model_settings": {"classifier_type": "logreg"}, "param_selection": { "type": "k-fold", "k": 5, "grid": { "fit_intercept": [True, False], "C": [0.01, 1, 10, 100], "class_bias": [0.7, 0.3, 0], }, }, "features": { "bag-of-words": {"lengths": [1, 2]}, "edge-ngrams": {"lengths": [1, 2]}, "in-gaz": {}, "exact": {"scaling": 10}, "gaz-freq": {}, "freq": {"bins": 5}, }, } ENTITY_RECOGNIZER_CONFIG = { "model_type": "tagger", "label_type": "entities", "model_settings": { "classifier_type": "memm", "tag_scheme": "IOB", "feature_scaler": "max-abs", }, "param_selection": { "type": "k-fold", "k": 5, "scoring": "accuracy", "grid": { "penalty": ["l1", "l2"], "C": [0.01, 1, 100, 10000, 1000000, 100000000], }, }, "features": { "bag-of-words-seq": { "ngram_lengths_to_start_positions": { 1: [-2, -1, 0, 1, 2], 2: [-2, -1, 0, 1], } }, "sys-candidates-seq": {"start_positions": [-1, 0, 1]}, }, }
"""This module contains the blueprint app configuration""" intent_classifier_config = {'model_type': 'text', 'model_settings': {'classifier_type': 'logreg'}, 'param_selection': {'type': 'k-fold', 'k': 5, 'grid': {'fit_intercept': [True, False], 'C': [0.01, 1, 10, 100], 'class_bias': [0.7, 0.3, 0]}}, 'features': {'bag-of-words': {'lengths': [1, 2]}, 'edge-ngrams': {'lengths': [1, 2]}, 'in-gaz': {}, 'exact': {'scaling': 10}, 'gaz-freq': {}, 'freq': {'bins': 5}}} entity_recognizer_config = {'model_type': 'tagger', 'label_type': 'entities', 'model_settings': {'classifier_type': 'memm', 'tag_scheme': 'IOB', 'feature_scaler': 'max-abs'}, 'param_selection': {'type': 'k-fold', 'k': 5, 'scoring': 'accuracy', 'grid': {'penalty': ['l1', 'l2'], 'C': [0.01, 1, 100, 10000, 1000000, 100000000]}}, 'features': {'bag-of-words-seq': {'ngram_lengths_to_start_positions': {1: [-2, -1, 0, 1, 2], 2: [-2, -1, 0, 1]}}, 'sys-candidates-seq': {'start_positions': [-1, 0, 1]}}}
class White(object): def __init__(self): self.color = 255, 255, 255 self.radius = 10 self.width = 10
class White(object): def __init__(self): self.color = (255, 255, 255) self.radius = 10 self.width = 10
def linearSearch(arr, x): for i in range(len(arr)): if arr[i] == x: return i return -1 if __name__ == "__main__": arr = [0,1,2,3,4,5,6,7,8,9] x = 6 print("Value is present at index number: {}".format(linearSearch(arr,x)))
def linear_search(arr, x): for i in range(len(arr)): if arr[i] == x: return i return -1 if __name__ == '__main__': arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] x = 6 print('Value is present at index number: {}'.format(linear_search(arr, x)))
""" __init__.py Created by: Martin Sicho On: 4/27/20, 6:22 PM """ __all__ = tuple()
""" __init__.py Created by: Martin Sicho On: 4/27/20, 6:22 PM """ __all__ = tuple()
#http://shell-storm.org/shellcode/files/shellcode-855.php #Author : gunslinger_ (yuda at cr0security dot com) def bin_sh(): shellcode = r"\x01\x60\x8f\xe2" shellcode += r"\x16\xff\x2f\xe1" shellcode += r"\x40\x40" shellcode += r"\x78\x44" shellcode += r"\x0c\x30" shellcode += r"\x49\x40" shellcode += r"\x52\x40" shellcode += r"\x0b\x27" shellcode += r"\x01\xdf" shellcode += r"\x01\x27" shellcode += r"\x01\xdf" shellcode += r"\x2f\x2f" shellcode += r"\x62\x69\x6e\x2f" shellcode += r"\x2f\x73" shellcode += r"\x68" return shellcode
def bin_sh(): shellcode = '\\x01\\x60\\x8f\\xe2' shellcode += '\\x16\\xff\\x2f\\xe1' shellcode += '\\x40\\x40' shellcode += '\\x78\\x44' shellcode += '\\x0c\\x30' shellcode += '\\x49\\x40' shellcode += '\\x52\\x40' shellcode += '\\x0b\\x27' shellcode += '\\x01\\xdf' shellcode += '\\x01\\x27' shellcode += '\\x01\\xdf' shellcode += '\\x2f\\x2f' shellcode += '\\x62\\x69\\x6e\\x2f' shellcode += '\\x2f\\x73' shellcode += '\\x68' return shellcode
SECRET_KEY = "GENERATA AL SETUP DI SEAFILE" DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'seahub-db', 'USER': 'UTENTE DB MYSQL', 'PASSWORD': 'INSERIRE LA PASSWORD DI MYSQL', 'HOST': '127.0.0.1', 'PORT': '3306', 'OPTIONS': { 'init_command': 'SET storage_engine=INNODB', } } } FILE_SERVER_ROOT = 'https://cname.dominio.tld/seafhttp' SERVE_STATIC = True MEDIA_URL = '/seafmedia/' SITE_ROOT = '/archivio/' COMPRESS_URL = MEDIA_URL STATIC_URL = MEDIA_URL + 'assets/' # workaround momentaneo valido almeno per la 4.x (5.x da testare) DEBUG = True LANGUAGE_CODE = 'it-IT' # show or hide library 'download' button SHOW_REPO_DOWNLOAD_BUTTON = True # enable 'upload folder' or not ENABLE_UPLOAD_FOLDER = True # enable resumable fileupload or not ENABLE_RESUMABLE_FILEUPLOAD = True # browser tab title SITE_TITLE = 'Archivio ACME' # Path to the Logo Imagefile (relative to the media path) #LOGO_PATH = 'img/seafile_logo.png' CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } }
secret_key = 'GENERATA AL SETUP DI SEAFILE' databases = {'default': {'ENGINE': 'django.db.backends.mysql', 'NAME': 'seahub-db', 'USER': 'UTENTE DB MYSQL', 'PASSWORD': 'INSERIRE LA PASSWORD DI MYSQL', 'HOST': '127.0.0.1', 'PORT': '3306', 'OPTIONS': {'init_command': 'SET storage_engine=INNODB'}}} file_server_root = 'https://cname.dominio.tld/seafhttp' serve_static = True media_url = '/seafmedia/' site_root = '/archivio/' compress_url = MEDIA_URL static_url = MEDIA_URL + 'assets/' debug = True language_code = 'it-IT' show_repo_download_button = True enable_upload_folder = True enable_resumable_fileupload = True site_title = 'Archivio ACME' caches = {'default': {'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211'}}
""" A board of players for the Tsuro game. :Author: Maded Batara III :Version: v1.0 """ class PlayerBoard: """ A PlayerBoard is a representation of the Tsuro board as a 2D list. An R*C board in the game is represented by a 2D list with 2*R rows and (3*C)+1 columns. The R*C board will be referred to as the tile board; the grid graph will be referred to as the graph board. """ def __init__(self, rows, cols): """ Creates a new PlayerBoard. Args: rows (int): Number of rows in the board. cols (int): Number of columns in the board. """ self.rows = rows self.cols = cols self.graph_rows = 2 * rows self.graph_cols = 3 * cols + 1 self.grid = [[[None] * self.graph_cols] * self.graph_rows] self.positions = {} def place(self, player, graph_index): """ Places a player in the board. Args: player (Player): Player to place in the board. graph_index (tuple): Row and column of node to place player in. """ self.grid[graph_index[0]][graph_index[1]] = player.turn self.positions[player.turn] = graph_index def move(self, player, graph_index): """ Places a player in the board. Args: player (Player): Player to place in the board. graph_index (tuple): Row and column of node to place player in. """ self.grid[self.positions[player.turn[0]]][self.positions[player.turn[1]]] = None self.grid[graph_index[0]][graph_index[1]] = player.turn self.positions[player.turn] = graph_index def remove(self, player): """ Removes a player from the game. Args: player (Player): Player to remove from the board. """ self.grid[self.positions[player.turn[0]]][self.positions[player.turn[1]]] = None self.positions[player.turn] = None def current_position(self, player): """ Gets the current position of the player. """ return self.positions[player.turn]
""" A board of players for the Tsuro game. :Author: Maded Batara III :Version: v1.0 """ class Playerboard: """ A PlayerBoard is a representation of the Tsuro board as a 2D list. An R*C board in the game is represented by a 2D list with 2*R rows and (3*C)+1 columns. The R*C board will be referred to as the tile board; the grid graph will be referred to as the graph board. """ def __init__(self, rows, cols): """ Creates a new PlayerBoard. Args: rows (int): Number of rows in the board. cols (int): Number of columns in the board. """ self.rows = rows self.cols = cols self.graph_rows = 2 * rows self.graph_cols = 3 * cols + 1 self.grid = [[[None] * self.graph_cols] * self.graph_rows] self.positions = {} def place(self, player, graph_index): """ Places a player in the board. Args: player (Player): Player to place in the board. graph_index (tuple): Row and column of node to place player in. """ self.grid[graph_index[0]][graph_index[1]] = player.turn self.positions[player.turn] = graph_index def move(self, player, graph_index): """ Places a player in the board. Args: player (Player): Player to place in the board. graph_index (tuple): Row and column of node to place player in. """ self.grid[self.positions[player.turn[0]]][self.positions[player.turn[1]]] = None self.grid[graph_index[0]][graph_index[1]] = player.turn self.positions[player.turn] = graph_index def remove(self, player): """ Removes a player from the game. Args: player (Player): Player to remove from the board. """ self.grid[self.positions[player.turn[0]]][self.positions[player.turn[1]]] = None self.positions[player.turn] = None def current_position(self, player): """ Gets the current position of the player. """ return self.positions[player.turn]
# # PySNMP MIB module HUAWEI-IMA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-IMA-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:45:04 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) # ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint") hwDatacomm, = mibBuilder.importSymbols("HUAWEI-MIB", "hwDatacomm") InterfaceIndexOrZero, InterfaceIndex, ifIndex = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero", "InterfaceIndex", "ifIndex") ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") Integer32, TimeTicks, Counter64, Counter32, iso, ObjectIdentity, ModuleIdentity, MibIdentifier, Bits, Unsigned32, NotificationType, enterprises, Gauge32, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "TimeTicks", "Counter64", "Counter32", "iso", "ObjectIdentity", "ModuleIdentity", "MibIdentifier", "Bits", "Unsigned32", "NotificationType", "enterprises", "Gauge32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress") DisplayString, TextualConvention, DateAndTime, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "DateAndTime", "RowStatus") hwImaMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176)) if mibBuilder.loadTexts: hwImaMIB.setLastUpdated('200902101400Z') if mibBuilder.loadTexts: hwImaMIB.setOrganization('Huawei Technologies co.,Ltd.') if mibBuilder.loadTexts: hwImaMIB.setContactInfo('Huawei Technologies co.,Ltd. Huawei Bld.,NO.3 Xinxi Rd., Shang-Di Information Industry Base, Hai-Dian District Beijing P.R. China http://www.huawei.com Zip:100085 ') if mibBuilder.loadTexts: hwImaMIB.setDescription('The MIB is mainly used to configure Inverse Multiplexing for ATM (IMA) interfaces.') hwImaMibObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1)) hwImaMibConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2)) class MilliSeconds(TextualConvention, Integer32): description = 'Time in milliseconds' status = 'current' class ImaGroupState(TextualConvention, Integer32): description = 'State of the IMA group.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) namedValues = NamedValues(("notConfigured", 1), ("startUp", 2), ("startUpAck", 3), ("configAbortUnsupportedM", 4), ("configAbortIncompatibleSymmetry", 5), ("configAbortOther", 6), ("insufficientLinks", 7), ("blocked", 8), ("operational", 9), ("configAbortUnsupportedImaVersion", 10)) class ImaGroupSymmetry(TextualConvention, Integer32): description = 'The group symmetry mode adjusted during the group start-up.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3)) namedValues = NamedValues(("symmetricOperation", 1), ("asymmetricOperation", 2), ("asymmetricConfiguration", 3)) class ImaFrameLength(TextualConvention, Integer32): description = 'Length of the IMA frames.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(32, 64, 128, 256)) namedValues = NamedValues(("m32", 32), ("m64", 64), ("m128", 128), ("m256", 256)) class ImaLinkState(TextualConvention, Integer32): description = 'State of a link belonging to an IMA group.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8)) namedValues = NamedValues(("notInGroup", 1), ("unusableNoGivenReason", 2), ("unusableFault", 3), ("unusableMisconnected", 4), ("unusableInhibited", 5), ("unusableFailed", 6), ("usable", 7), ("active", 8)) hwImaGroupTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1), ) if mibBuilder.loadTexts: hwImaGroupTable.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTable.setDescription('The IMA Group Configuration table.') hwImaGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1), ).setIndexNames((0, "HUAWEI-IMA-MIB", "hwImaGroupIfIndex")) if mibBuilder.loadTexts: hwImaGroupEntry.setStatus('current') if mibBuilder.loadTexts: hwImaGroupEntry.setDescription('An entry in the IMA Group table.') hwImaGroupIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 1), InterfaceIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaGroupIfIndex.setDescription("This object identifies the logical interface number ('ifIndex') assigned to this IMA group, and is used to identify corresponding rows in the Interfaces MIB. Note that re-initialization of the management agent may cause a client's 'hwImaGroupIfIndex' to change.") hwImaGroupNeState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 2), ImaGroupState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupNeState.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNeState.setDescription('The current operational state of the near-end IMA Group State Machine.') hwImaGroupFeState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 3), ImaGroupState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupFeState.setStatus('current') if mibBuilder.loadTexts: hwImaGroupFeState.setDescription('The current operational state of the far-end IMA Group State Machine.') hwImaGroupSymmetry = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 4), ImaGroupSymmetry().clone('symmetricOperation')).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupSymmetry.setStatus('current') if mibBuilder.loadTexts: hwImaGroupSymmetry.setDescription('Symmetry of the IMA group.') hwImaGroupMinNumTxLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 32))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaGroupMinNumTxLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupMinNumTxLinks.setDescription('Minimum number of transmit links required to be Active for the IMA group to be in the Operational state.') hwImaGroupMinNumRxLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 32))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaGroupMinNumRxLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupMinNumRxLinks.setDescription('Minimum number of receive links required to be Active for the IMA group to be in the Operational state.') hwImaGroupTxTimingRefLink = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 7), InterfaceIndexOrZero()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupTxTimingRefLink.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxTimingRefLink.setDescription('The ifIndex of the transmit timing reference link to be used by the near-end for IMA data cell clock recovery from the ATM layer. The distinguished value of zero may be used if no link has been configured in the IMA group, or if the transmit timing reference link has not yet been selected.') hwImaGroupRxTimingRefLink = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 8), InterfaceIndexOrZero()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupRxTimingRefLink.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxTimingRefLink.setDescription('The ifIndex of the receive timing reference link to be used by near-end for IMA data cell clock recovery toward the ATM layer. The distinguished value of zero may be used if no link has been configured in the IMA group, or if the receive timing reference link has not yet been detected.') hwImaGroupTxImaId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupTxImaId.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxImaId.setDescription('The IMA ID currently in use by the near-end IMA function.') hwImaGroupRxImaId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupRxImaId.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxImaId.setDescription('The IMA ID currently in use by the far-end IMA function.') hwImaGroupTxFrameLength = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 11), ImaFrameLength().clone('m128')).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaGroupTxFrameLength.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxFrameLength.setDescription('The frame length to be used by the IMA group in the transmit direction. Can only be set when the IMA group is startup.') hwImaGroupRxFrameLength = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 12), ImaFrameLength()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupRxFrameLength.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxFrameLength.setDescription('Value of IMA frame length as received from remote IMA function.') hwImaGroupDiffDelayMax = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 13), MilliSeconds().subtype(subtypeSpec=ValueRangeConstraint(25, 100)).clone(25)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaGroupDiffDelayMax.setStatus('current') if mibBuilder.loadTexts: hwImaGroupDiffDelayMax.setDescription('The maximum number of milliseconds of differential delay among the links that will be tolerated on this interface.') hwImaGroupAlphaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2)).clone(2)).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupAlphaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupAlphaValue.setDescription("This indicates the 'alpha' value used to specify the number of consecutive invalid ICP cells to be detected before moving to the IMA Hunt state from the IMA Sync state.") hwImaGroupBetaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 5)).clone(2)).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupBetaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupBetaValue.setDescription("This indicates the 'beta' value used to specify the number of consecutive errored ICP cells to be detected before moving to the IMA Hunt state from the IMA Sync state.") hwImaGroupGammaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 5)).clone(1)).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupGammaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupGammaValue.setDescription("This indicates the 'gamma' value used to specify the number of consecutive valid ICP cells to be detected before moving to the IMA Sync state from the IMA PreSync state.") hwImaGroupNumTxActLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 17), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupNumTxActLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNumTxActLinks.setDescription('The number of links which are configured to transmit and are currently Active in this IMA group.') hwImaGroupNumRxActLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 18), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupNumRxActLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNumRxActLinks.setDescription('The number of links which are configured to receive and are currently Active in this IMA group.') hwImaGroupTxOamLabelValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupTxOamLabelValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxOamLabelValue.setDescription('IMA OAM Label value transmitted by the NE IMA unit.') hwImaGroupRxOamLabelValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupRxOamLabelValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxOamLabelValue.setDescription('IMA OAM Label value transmitted by the FE IMA unit. The value 0 likely means that the IMA unit has not received an OAM Label from the FE IMA unit at this time.') hwImaGroupFirstLinkIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 21), InterfaceIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaGroupFirstLinkIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaGroupFirstLinkIfIndex.setDescription('This object identifies the first link of this IMA Group.') hwImaLinkTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2), ) if mibBuilder.loadTexts: hwImaLinkTable.setStatus('current') if mibBuilder.loadTexts: hwImaLinkTable.setDescription('The IMA group Link Status and Configuration table.') hwImaLinkEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1), ).setIndexNames((0, "HUAWEI-IMA-MIB", "hwImaLinkIfIndex")) if mibBuilder.loadTexts: hwImaLinkEntry.setStatus('current') if mibBuilder.loadTexts: hwImaLinkEntry.setDescription('An entry in the IMA Group Link table.') hwImaLinkIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: hwImaLinkIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaLinkIfIndex.setDescription("This corresponds to the 'ifIndex' of the MIB-II interface on which this link is established. This object also corresponds to the logical number ('ifIndex') assigned to this IMA link.") hwImaLinkGroupIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 2), InterfaceIndex()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaLinkGroupIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaLinkGroupIfIndex.setDescription("This object identifies the logical interface number ('ifIndex') assigned to this IMA group. The specified link will be bound to this IMA group.") hwImaLinkNeTxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 3), ImaLinkState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaLinkNeTxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkNeTxState.setDescription('The current state of the near-end transmit link.') hwImaLinkNeRxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 4), ImaLinkState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaLinkNeRxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkNeRxState.setDescription('The current state of the near-end receive link.') hwImaLinkFeTxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 5), ImaLinkState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaLinkFeTxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkFeTxState.setDescription('The current state of the far-end transmit link as reported via ICP cells.') hwImaLinkFeRxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 6), ImaLinkState()).setMaxAccess("readonly") if mibBuilder.loadTexts: hwImaLinkFeRxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkFeRxState.setDescription('The current state of the far-end receive link as reported via ICP cells.') hwImaLinkRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 51), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hwImaLinkRowStatus.setStatus('current') if mibBuilder.loadTexts: hwImaLinkRowStatus.setDescription("The hwImaLinkRowStatus object allows create, change, and delete operations on hwImaLinkTable entries. To create a new conceptual row (or instance) of the hwImaLinkTable, hwImaLinkRowStatus must be set to 'createAndWait' or 'createAndGo'. A successful set of the imaLinkGroupIndex object must be performed before the hwImaLinkRowStatus of a new conceptual row can be set to 'active'. To change (modify) the imaLinkGroupIndex in an hwImaLinkTable entry, the hwImaLinkRowStatus object must first be set to 'notInService'. Only then can this object in the conceptual row be modified. This is due to the fact that the imaLinkGroupIndex object provides the association between a physical IMA link and the IMA group to which it belongs, and setting the imaLinkGroupIndex object to a different value has the effect of changing the association between a physical IMA link and an IMA group. To place the link 'in group', the hwImaLinkRowStatus object is set to 'active'. While the row is not in 'active' state, both the Transmit and Receive IMA link state machines are in the 'Not In Group' state. To remove (delete) an hwImaLinkTable entry from this table, set this object to 'destroy'.") hwImaMibGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1)) hwImaMibCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2)) hwImaMibCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2, 1)).setObjects(("HUAWEI-IMA-MIB", "hwImaGroupGroup"), ("HUAWEI-IMA-MIB", "hwImaLinkGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hwImaMibCompliance = hwImaMibCompliance.setStatus('current') if mibBuilder.loadTexts: hwImaMibCompliance.setDescription('The compliance statement for network elements implementing Inverse Multiplexing for ATM (IMA) interfaces.') hwImaGroupGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 1)).setObjects(("HUAWEI-IMA-MIB", "hwImaGroupIfIndex"), ("HUAWEI-IMA-MIB", "hwImaGroupNeState"), ("HUAWEI-IMA-MIB", "hwImaGroupFeState"), ("HUAWEI-IMA-MIB", "hwImaGroupSymmetry"), ("HUAWEI-IMA-MIB", "hwImaGroupMinNumTxLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupMinNumRxLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupTxTimingRefLink"), ("HUAWEI-IMA-MIB", "hwImaGroupRxTimingRefLink"), ("HUAWEI-IMA-MIB", "hwImaGroupTxImaId"), ("HUAWEI-IMA-MIB", "hwImaGroupRxImaId"), ("HUAWEI-IMA-MIB", "hwImaGroupTxFrameLength"), ("HUAWEI-IMA-MIB", "hwImaGroupRxFrameLength"), ("HUAWEI-IMA-MIB", "hwImaGroupDiffDelayMax"), ("HUAWEI-IMA-MIB", "hwImaGroupAlphaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupBetaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupGammaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupNumTxActLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupNumRxActLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupTxOamLabelValue"), ("HUAWEI-IMA-MIB", "hwImaGroupRxOamLabelValue"), ("HUAWEI-IMA-MIB", "hwImaGroupFirstLinkIfIndex")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hwImaGroupGroup = hwImaGroupGroup.setStatus('current') if mibBuilder.loadTexts: hwImaGroupGroup.setDescription('A set of objects providing configuration and status information for an IMA group definition.') hwImaLinkGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 2)).setObjects(("HUAWEI-IMA-MIB", "hwImaLinkGroupIfIndex"), ("HUAWEI-IMA-MIB", "hwImaLinkNeTxState"), ("HUAWEI-IMA-MIB", "hwImaLinkNeRxState"), ("HUAWEI-IMA-MIB", "hwImaLinkFeTxState"), ("HUAWEI-IMA-MIB", "hwImaLinkFeRxState"), ("HUAWEI-IMA-MIB", "hwImaLinkRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hwImaLinkGroup = hwImaLinkGroup.setStatus('current') if mibBuilder.loadTexts: hwImaLinkGroup.setDescription('A set of objects providing status information for an IMA link.') mibBuilder.exportSymbols("HUAWEI-IMA-MIB", hwImaMibGroups=hwImaMibGroups, hwImaMIB=hwImaMIB, hwImaGroupTxFrameLength=hwImaGroupTxFrameLength, hwImaMibCompliance=hwImaMibCompliance, hwImaGroupGammaValue=hwImaGroupGammaValue, hwImaMibObjects=hwImaMibObjects, hwImaGroupFeState=hwImaGroupFeState, hwImaGroupRxTimingRefLink=hwImaGroupRxTimingRefLink, ImaGroupState=ImaGroupState, hwImaGroupNumTxActLinks=hwImaGroupNumTxActLinks, hwImaGroupMinNumTxLinks=hwImaGroupMinNumTxLinks, hwImaGroupDiffDelayMax=hwImaGroupDiffDelayMax, hwImaGroupRxOamLabelValue=hwImaGroupRxOamLabelValue, hwImaLinkTable=hwImaLinkTable, hwImaLinkFeTxState=hwImaLinkFeTxState, hwImaLinkGroupIfIndex=hwImaLinkGroupIfIndex, hwImaLinkNeRxState=hwImaLinkNeRxState, hwImaGroupEntry=hwImaGroupEntry, hwImaMibConformance=hwImaMibConformance, hwImaGroupTable=hwImaGroupTable, ImaGroupSymmetry=ImaGroupSymmetry, hwImaLinkFeRxState=hwImaLinkFeRxState, hwImaGroupTxOamLabelValue=hwImaGroupTxOamLabelValue, hwImaGroupAlphaValue=hwImaGroupAlphaValue, hwImaLinkNeTxState=hwImaLinkNeTxState, hwImaGroupRxFrameLength=hwImaGroupRxFrameLength, MilliSeconds=MilliSeconds, PYSNMP_MODULE_ID=hwImaMIB, ImaLinkState=ImaLinkState, hwImaGroupIfIndex=hwImaGroupIfIndex, hwImaGroupNeState=hwImaGroupNeState, hwImaLinkEntry=hwImaLinkEntry, hwImaGroupRxImaId=hwImaGroupRxImaId, hwImaMibCompliances=hwImaMibCompliances, hwImaGroupGroup=hwImaGroupGroup, hwImaGroupBetaValue=hwImaGroupBetaValue, hwImaLinkIfIndex=hwImaLinkIfIndex, hwImaGroupMinNumRxLinks=hwImaGroupMinNumRxLinks, hwImaGroupFirstLinkIfIndex=hwImaGroupFirstLinkIfIndex, hwImaGroupSymmetry=hwImaGroupSymmetry, hwImaGroupTxImaId=hwImaGroupTxImaId, hwImaLinkGroup=hwImaLinkGroup, hwImaLinkRowStatus=hwImaLinkRowStatus, hwImaGroupNumRxActLinks=hwImaGroupNumRxActLinks, hwImaGroupTxTimingRefLink=hwImaGroupTxTimingRefLink, ImaFrameLength=ImaFrameLength)
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueRangeConstraint') (hw_datacomm,) = mibBuilder.importSymbols('HUAWEI-MIB', 'hwDatacomm') (interface_index_or_zero, interface_index, if_index) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero', 'InterfaceIndex', 'ifIndex') (module_compliance, object_group, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'ObjectGroup', 'NotificationGroup') (integer32, time_ticks, counter64, counter32, iso, object_identity, module_identity, mib_identifier, bits, unsigned32, notification_type, enterprises, gauge32, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'TimeTicks', 'Counter64', 'Counter32', 'iso', 'ObjectIdentity', 'ModuleIdentity', 'MibIdentifier', 'Bits', 'Unsigned32', 'NotificationType', 'enterprises', 'Gauge32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress') (display_string, textual_convention, date_and_time, row_status) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention', 'DateAndTime', 'RowStatus') hw_ima_mib = module_identity((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176)) if mibBuilder.loadTexts: hwImaMIB.setLastUpdated('200902101400Z') if mibBuilder.loadTexts: hwImaMIB.setOrganization('Huawei Technologies co.,Ltd.') if mibBuilder.loadTexts: hwImaMIB.setContactInfo('Huawei Technologies co.,Ltd. Huawei Bld.,NO.3 Xinxi Rd., Shang-Di Information Industry Base, Hai-Dian District Beijing P.R. China http://www.huawei.com Zip:100085 ') if mibBuilder.loadTexts: hwImaMIB.setDescription('The MIB is mainly used to configure Inverse Multiplexing for ATM (IMA) interfaces.') hw_ima_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1)) hw_ima_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2)) class Milliseconds(TextualConvention, Integer32): description = 'Time in milliseconds' status = 'current' class Imagroupstate(TextualConvention, Integer32): description = 'State of the IMA group.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) named_values = named_values(('notConfigured', 1), ('startUp', 2), ('startUpAck', 3), ('configAbortUnsupportedM', 4), ('configAbortIncompatibleSymmetry', 5), ('configAbortOther', 6), ('insufficientLinks', 7), ('blocked', 8), ('operational', 9), ('configAbortUnsupportedImaVersion', 10)) class Imagroupsymmetry(TextualConvention, Integer32): description = 'The group symmetry mode adjusted during the group start-up.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3)) named_values = named_values(('symmetricOperation', 1), ('asymmetricOperation', 2), ('asymmetricConfiguration', 3)) class Imaframelength(TextualConvention, Integer32): description = 'Length of the IMA frames.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(32, 64, 128, 256)) named_values = named_values(('m32', 32), ('m64', 64), ('m128', 128), ('m256', 256)) class Imalinkstate(TextualConvention, Integer32): description = 'State of a link belonging to an IMA group.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8)) named_values = named_values(('notInGroup', 1), ('unusableNoGivenReason', 2), ('unusableFault', 3), ('unusableMisconnected', 4), ('unusableInhibited', 5), ('unusableFailed', 6), ('usable', 7), ('active', 8)) hw_ima_group_table = mib_table((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1)) if mibBuilder.loadTexts: hwImaGroupTable.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTable.setDescription('The IMA Group Configuration table.') hw_ima_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1)).setIndexNames((0, 'HUAWEI-IMA-MIB', 'hwImaGroupIfIndex')) if mibBuilder.loadTexts: hwImaGroupEntry.setStatus('current') if mibBuilder.loadTexts: hwImaGroupEntry.setDescription('An entry in the IMA Group table.') hw_ima_group_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 1), interface_index()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaGroupIfIndex.setDescription("This object identifies the logical interface number ('ifIndex') assigned to this IMA group, and is used to identify corresponding rows in the Interfaces MIB. Note that re-initialization of the management agent may cause a client's 'hwImaGroupIfIndex' to change.") hw_ima_group_ne_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 2), ima_group_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupNeState.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNeState.setDescription('The current operational state of the near-end IMA Group State Machine.') hw_ima_group_fe_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 3), ima_group_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupFeState.setStatus('current') if mibBuilder.loadTexts: hwImaGroupFeState.setDescription('The current operational state of the far-end IMA Group State Machine.') hw_ima_group_symmetry = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 4), ima_group_symmetry().clone('symmetricOperation')).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupSymmetry.setStatus('current') if mibBuilder.loadTexts: hwImaGroupSymmetry.setDescription('Symmetry of the IMA group.') hw_ima_group_min_num_tx_links = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(1, 32))).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaGroupMinNumTxLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupMinNumTxLinks.setDescription('Minimum number of transmit links required to be Active for the IMA group to be in the Operational state.') hw_ima_group_min_num_rx_links = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(1, 32))).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaGroupMinNumRxLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupMinNumRxLinks.setDescription('Minimum number of receive links required to be Active for the IMA group to be in the Operational state.') hw_ima_group_tx_timing_ref_link = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 7), interface_index_or_zero()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupTxTimingRefLink.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxTimingRefLink.setDescription('The ifIndex of the transmit timing reference link to be used by the near-end for IMA data cell clock recovery from the ATM layer. The distinguished value of zero may be used if no link has been configured in the IMA group, or if the transmit timing reference link has not yet been selected.') hw_ima_group_rx_timing_ref_link = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 8), interface_index_or_zero()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupRxTimingRefLink.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxTimingRefLink.setDescription('The ifIndex of the receive timing reference link to be used by near-end for IMA data cell clock recovery toward the ATM layer. The distinguished value of zero may be used if no link has been configured in the IMA group, or if the receive timing reference link has not yet been detected.') hw_ima_group_tx_ima_id = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupTxImaId.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxImaId.setDescription('The IMA ID currently in use by the near-end IMA function.') hw_ima_group_rx_ima_id = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupRxImaId.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxImaId.setDescription('The IMA ID currently in use by the far-end IMA function.') hw_ima_group_tx_frame_length = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 11), ima_frame_length().clone('m128')).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaGroupTxFrameLength.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxFrameLength.setDescription('The frame length to be used by the IMA group in the transmit direction. Can only be set when the IMA group is startup.') hw_ima_group_rx_frame_length = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 12), ima_frame_length()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupRxFrameLength.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxFrameLength.setDescription('Value of IMA frame length as received from remote IMA function.') hw_ima_group_diff_delay_max = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 13), milli_seconds().subtype(subtypeSpec=value_range_constraint(25, 100)).clone(25)).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaGroupDiffDelayMax.setStatus('current') if mibBuilder.loadTexts: hwImaGroupDiffDelayMax.setDescription('The maximum number of milliseconds of differential delay among the links that will be tolerated on this interface.') hw_ima_group_alpha_value = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 14), integer32().subtype(subtypeSpec=value_range_constraint(1, 2)).clone(2)).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupAlphaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupAlphaValue.setDescription("This indicates the 'alpha' value used to specify the number of consecutive invalid ICP cells to be detected before moving to the IMA Hunt state from the IMA Sync state.") hw_ima_group_beta_value = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(1, 5)).clone(2)).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupBetaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupBetaValue.setDescription("This indicates the 'beta' value used to specify the number of consecutive errored ICP cells to be detected before moving to the IMA Hunt state from the IMA Sync state.") hw_ima_group_gamma_value = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 16), integer32().subtype(subtypeSpec=value_range_constraint(1, 5)).clone(1)).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupGammaValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupGammaValue.setDescription("This indicates the 'gamma' value used to specify the number of consecutive valid ICP cells to be detected before moving to the IMA Sync state from the IMA PreSync state.") hw_ima_group_num_tx_act_links = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 17), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupNumTxActLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNumTxActLinks.setDescription('The number of links which are configured to transmit and are currently Active in this IMA group.') hw_ima_group_num_rx_act_links = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 18), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupNumRxActLinks.setStatus('current') if mibBuilder.loadTexts: hwImaGroupNumRxActLinks.setDescription('The number of links which are configured to receive and are currently Active in this IMA group.') hw_ima_group_tx_oam_label_value = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 19), integer32().subtype(subtypeSpec=value_range_constraint(1, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupTxOamLabelValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupTxOamLabelValue.setDescription('IMA OAM Label value transmitted by the NE IMA unit.') hw_ima_group_rx_oam_label_value = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 20), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupRxOamLabelValue.setStatus('current') if mibBuilder.loadTexts: hwImaGroupRxOamLabelValue.setDescription('IMA OAM Label value transmitted by the FE IMA unit. The value 0 likely means that the IMA unit has not received an OAM Label from the FE IMA unit at this time.') hw_ima_group_first_link_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 21), interface_index()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaGroupFirstLinkIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaGroupFirstLinkIfIndex.setDescription('This object identifies the first link of this IMA Group.') hw_ima_link_table = mib_table((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2)) if mibBuilder.loadTexts: hwImaLinkTable.setStatus('current') if mibBuilder.loadTexts: hwImaLinkTable.setDescription('The IMA group Link Status and Configuration table.') hw_ima_link_entry = mib_table_row((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1)).setIndexNames((0, 'HUAWEI-IMA-MIB', 'hwImaLinkIfIndex')) if mibBuilder.loadTexts: hwImaLinkEntry.setStatus('current') if mibBuilder.loadTexts: hwImaLinkEntry.setDescription('An entry in the IMA Group Link table.') hw_ima_link_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 1), interface_index()) if mibBuilder.loadTexts: hwImaLinkIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaLinkIfIndex.setDescription("This corresponds to the 'ifIndex' of the MIB-II interface on which this link is established. This object also corresponds to the logical number ('ifIndex') assigned to this IMA link.") hw_ima_link_group_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 2), interface_index()).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaLinkGroupIfIndex.setStatus('current') if mibBuilder.loadTexts: hwImaLinkGroupIfIndex.setDescription("This object identifies the logical interface number ('ifIndex') assigned to this IMA group. The specified link will be bound to this IMA group.") hw_ima_link_ne_tx_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 3), ima_link_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaLinkNeTxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkNeTxState.setDescription('The current state of the near-end transmit link.') hw_ima_link_ne_rx_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 4), ima_link_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaLinkNeRxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkNeRxState.setDescription('The current state of the near-end receive link.') hw_ima_link_fe_tx_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 5), ima_link_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaLinkFeTxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkFeTxState.setDescription('The current state of the far-end transmit link as reported via ICP cells.') hw_ima_link_fe_rx_state = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 6), ima_link_state()).setMaxAccess('readonly') if mibBuilder.loadTexts: hwImaLinkFeRxState.setStatus('current') if mibBuilder.loadTexts: hwImaLinkFeRxState.setDescription('The current state of the far-end receive link as reported via ICP cells.') hw_ima_link_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 51), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: hwImaLinkRowStatus.setStatus('current') if mibBuilder.loadTexts: hwImaLinkRowStatus.setDescription("The hwImaLinkRowStatus object allows create, change, and delete operations on hwImaLinkTable entries. To create a new conceptual row (or instance) of the hwImaLinkTable, hwImaLinkRowStatus must be set to 'createAndWait' or 'createAndGo'. A successful set of the imaLinkGroupIndex object must be performed before the hwImaLinkRowStatus of a new conceptual row can be set to 'active'. To change (modify) the imaLinkGroupIndex in an hwImaLinkTable entry, the hwImaLinkRowStatus object must first be set to 'notInService'. Only then can this object in the conceptual row be modified. This is due to the fact that the imaLinkGroupIndex object provides the association between a physical IMA link and the IMA group to which it belongs, and setting the imaLinkGroupIndex object to a different value has the effect of changing the association between a physical IMA link and an IMA group. To place the link 'in group', the hwImaLinkRowStatus object is set to 'active'. While the row is not in 'active' state, both the Transmit and Receive IMA link state machines are in the 'Not In Group' state. To remove (delete) an hwImaLinkTable entry from this table, set this object to 'destroy'.") hw_ima_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1)) hw_ima_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2)) hw_ima_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2, 1)).setObjects(('HUAWEI-IMA-MIB', 'hwImaGroupGroup'), ('HUAWEI-IMA-MIB', 'hwImaLinkGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hw_ima_mib_compliance = hwImaMibCompliance.setStatus('current') if mibBuilder.loadTexts: hwImaMibCompliance.setDescription('The compliance statement for network elements implementing Inverse Multiplexing for ATM (IMA) interfaces.') hw_ima_group_group = object_group((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 1)).setObjects(('HUAWEI-IMA-MIB', 'hwImaGroupIfIndex'), ('HUAWEI-IMA-MIB', 'hwImaGroupNeState'), ('HUAWEI-IMA-MIB', 'hwImaGroupFeState'), ('HUAWEI-IMA-MIB', 'hwImaGroupSymmetry'), ('HUAWEI-IMA-MIB', 'hwImaGroupMinNumTxLinks'), ('HUAWEI-IMA-MIB', 'hwImaGroupMinNumRxLinks'), ('HUAWEI-IMA-MIB', 'hwImaGroupTxTimingRefLink'), ('HUAWEI-IMA-MIB', 'hwImaGroupRxTimingRefLink'), ('HUAWEI-IMA-MIB', 'hwImaGroupTxImaId'), ('HUAWEI-IMA-MIB', 'hwImaGroupRxImaId'), ('HUAWEI-IMA-MIB', 'hwImaGroupTxFrameLength'), ('HUAWEI-IMA-MIB', 'hwImaGroupRxFrameLength'), ('HUAWEI-IMA-MIB', 'hwImaGroupDiffDelayMax'), ('HUAWEI-IMA-MIB', 'hwImaGroupAlphaValue'), ('HUAWEI-IMA-MIB', 'hwImaGroupBetaValue'), ('HUAWEI-IMA-MIB', 'hwImaGroupGammaValue'), ('HUAWEI-IMA-MIB', 'hwImaGroupNumTxActLinks'), ('HUAWEI-IMA-MIB', 'hwImaGroupNumRxActLinks'), ('HUAWEI-IMA-MIB', 'hwImaGroupTxOamLabelValue'), ('HUAWEI-IMA-MIB', 'hwImaGroupRxOamLabelValue'), ('HUAWEI-IMA-MIB', 'hwImaGroupFirstLinkIfIndex')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hw_ima_group_group = hwImaGroupGroup.setStatus('current') if mibBuilder.loadTexts: hwImaGroupGroup.setDescription('A set of objects providing configuration and status information for an IMA group definition.') hw_ima_link_group = object_group((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 2)).setObjects(('HUAWEI-IMA-MIB', 'hwImaLinkGroupIfIndex'), ('HUAWEI-IMA-MIB', 'hwImaLinkNeTxState'), ('HUAWEI-IMA-MIB', 'hwImaLinkNeRxState'), ('HUAWEI-IMA-MIB', 'hwImaLinkFeTxState'), ('HUAWEI-IMA-MIB', 'hwImaLinkFeRxState'), ('HUAWEI-IMA-MIB', 'hwImaLinkRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hw_ima_link_group = hwImaLinkGroup.setStatus('current') if mibBuilder.loadTexts: hwImaLinkGroup.setDescription('A set of objects providing status information for an IMA link.') mibBuilder.exportSymbols('HUAWEI-IMA-MIB', hwImaMibGroups=hwImaMibGroups, hwImaMIB=hwImaMIB, hwImaGroupTxFrameLength=hwImaGroupTxFrameLength, hwImaMibCompliance=hwImaMibCompliance, hwImaGroupGammaValue=hwImaGroupGammaValue, hwImaMibObjects=hwImaMibObjects, hwImaGroupFeState=hwImaGroupFeState, hwImaGroupRxTimingRefLink=hwImaGroupRxTimingRefLink, ImaGroupState=ImaGroupState, hwImaGroupNumTxActLinks=hwImaGroupNumTxActLinks, hwImaGroupMinNumTxLinks=hwImaGroupMinNumTxLinks, hwImaGroupDiffDelayMax=hwImaGroupDiffDelayMax, hwImaGroupRxOamLabelValue=hwImaGroupRxOamLabelValue, hwImaLinkTable=hwImaLinkTable, hwImaLinkFeTxState=hwImaLinkFeTxState, hwImaLinkGroupIfIndex=hwImaLinkGroupIfIndex, hwImaLinkNeRxState=hwImaLinkNeRxState, hwImaGroupEntry=hwImaGroupEntry, hwImaMibConformance=hwImaMibConformance, hwImaGroupTable=hwImaGroupTable, ImaGroupSymmetry=ImaGroupSymmetry, hwImaLinkFeRxState=hwImaLinkFeRxState, hwImaGroupTxOamLabelValue=hwImaGroupTxOamLabelValue, hwImaGroupAlphaValue=hwImaGroupAlphaValue, hwImaLinkNeTxState=hwImaLinkNeTxState, hwImaGroupRxFrameLength=hwImaGroupRxFrameLength, MilliSeconds=MilliSeconds, PYSNMP_MODULE_ID=hwImaMIB, ImaLinkState=ImaLinkState, hwImaGroupIfIndex=hwImaGroupIfIndex, hwImaGroupNeState=hwImaGroupNeState, hwImaLinkEntry=hwImaLinkEntry, hwImaGroupRxImaId=hwImaGroupRxImaId, hwImaMibCompliances=hwImaMibCompliances, hwImaGroupGroup=hwImaGroupGroup, hwImaGroupBetaValue=hwImaGroupBetaValue, hwImaLinkIfIndex=hwImaLinkIfIndex, hwImaGroupMinNumRxLinks=hwImaGroupMinNumRxLinks, hwImaGroupFirstLinkIfIndex=hwImaGroupFirstLinkIfIndex, hwImaGroupSymmetry=hwImaGroupSymmetry, hwImaGroupTxImaId=hwImaGroupTxImaId, hwImaLinkGroup=hwImaLinkGroup, hwImaLinkRowStatus=hwImaLinkRowStatus, hwImaGroupNumRxActLinks=hwImaGroupNumRxActLinks, hwImaGroupTxTimingRefLink=hwImaGroupTxTimingRefLink, ImaFrameLength=ImaFrameLength)
class priorityqueue(): def __init__(self): self.data = [] def __repr__(self): return str(self.data) def add(self, i): if len(self.data) == 0: self.data.append(i) else: for j in range(len(self.data)): if self.data[j][1] > i[1]: self.data.insert(j, i) return self.data.append(i) def remove(self): return self.data.pop(0) def isempty(self): return len(self.data) == 0 class stack(): def __init__(self): self.data = [] def __repr__(self): return str(self.data) def add(self, i): self.data.append(i) def remove(self): return self.data.pop() def isempty(self): return len(self.data) == 0 def reverse(self): return reversed(self.data) def ToPath(a, b, hashtable, stack): stack.add(b) if hashtable[b] == a: stack.add(a) return list(stack.reverse()) else: return ToPath(a, hashtable[b], hashtable, stack)
class Priorityqueue: def __init__(self): self.data = [] def __repr__(self): return str(self.data) def add(self, i): if len(self.data) == 0: self.data.append(i) else: for j in range(len(self.data)): if self.data[j][1] > i[1]: self.data.insert(j, i) return self.data.append(i) def remove(self): return self.data.pop(0) def isempty(self): return len(self.data) == 0 class Stack: def __init__(self): self.data = [] def __repr__(self): return str(self.data) def add(self, i): self.data.append(i) def remove(self): return self.data.pop() def isempty(self): return len(self.data) == 0 def reverse(self): return reversed(self.data) def to_path(a, b, hashtable, stack): stack.add(b) if hashtable[b] == a: stack.add(a) return list(stack.reverse()) else: return to_path(a, hashtable[b], hashtable, stack)
class Account(object): @classmethod def all(cls, client): request_url = "https://api.robinhood.com/accounts/" data = client.get(request_url) results = data["results"] while data["next"]: data = client.get(data["next"]) results.extend(data["results"]) return results @classmethod def all_urls(cls, client): accounts = cls.all(client) urls = [account["url"] for account in accounts] return urls
class Account(object): @classmethod def all(cls, client): request_url = 'https://api.robinhood.com/accounts/' data = client.get(request_url) results = data['results'] while data['next']: data = client.get(data['next']) results.extend(data['results']) return results @classmethod def all_urls(cls, client): accounts = cls.all(client) urls = [account['url'] for account in accounts] return urls
## global strings for output dictionaries ## NAME = "name" TABLE = "table" FIELD = "field" TABLES = "tables" VALUE = "value" FIELDS = "fields" REPORT = "report" MRN = "mrn" DATE = "date" MRN_CAPS = "MRN" UWID = "uwid" ACCESSION_NUM = "accession" KARYO = "karyotype" KARYOTYPE_STRING = "KaryotypeString" FILLER_ORDER_NO = "FillerOrderNo" CONFIDENCE = "confidence" VERSION = "algorithmVersion" STARTSTOPS = "startStops" SET_ID = "SetId" OBSERVATION_VALUE = "ObservationValue" SPECIMEN_SOURCE = "SpecimenSource" KEY = "recordKey" START = "startPosition" STOP = "stopPosition" ERR_STR = "errorString" ERR_TYPE = "errorType" INSUFFICIENT = "Insufficient" MISCELLANEOUS = "Miscellaneous" INTERMEDIATE = "Intermediate" UNFAVORABLE = "Unfavorable" FAVORABLE = "Favorable" CELL_COUNT = "CellCount" CELL_ORDER = "CellTypeOrder" CHROMOSOME = "Chromosome" ABNORMALITIES = "Abnormalities" CHROMOSOME_NUM = "ChromosomeNumber" WARNING = "Warning" CYTOGENETICS = "Cytogenetics" SWOG = "AML_SWOG_RiskCategory" ELN = "ELN_RiskCategory" POLY = "Polyploidy" UNKNOWN = "Unknown" SPEC_DATE = "spec_date" OFFSET = "Offset" PARSE_ERR = "PARSING ERROR" DATE = "ReceivedDate"
name = 'name' table = 'table' field = 'field' tables = 'tables' value = 'value' fields = 'fields' report = 'report' mrn = 'mrn' date = 'date' mrn_caps = 'MRN' uwid = 'uwid' accession_num = 'accession' karyo = 'karyotype' karyotype_string = 'KaryotypeString' filler_order_no = 'FillerOrderNo' confidence = 'confidence' version = 'algorithmVersion' startstops = 'startStops' set_id = 'SetId' observation_value = 'ObservationValue' specimen_source = 'SpecimenSource' key = 'recordKey' start = 'startPosition' stop = 'stopPosition' err_str = 'errorString' err_type = 'errorType' insufficient = 'Insufficient' miscellaneous = 'Miscellaneous' intermediate = 'Intermediate' unfavorable = 'Unfavorable' favorable = 'Favorable' cell_count = 'CellCount' cell_order = 'CellTypeOrder' chromosome = 'Chromosome' abnormalities = 'Abnormalities' chromosome_num = 'ChromosomeNumber' warning = 'Warning' cytogenetics = 'Cytogenetics' swog = 'AML_SWOG_RiskCategory' eln = 'ELN_RiskCategory' poly = 'Polyploidy' unknown = 'Unknown' spec_date = 'spec_date' offset = 'Offset' parse_err = 'PARSING ERROR' date = 'ReceivedDate'
username = input('Enter your name: ') password = input('Enter your password: ') password_len = len(password) password_secret = '*' * password_len print(f'Your name is: {username} and your {password_secret} is {password_len} letters long.')
username = input('Enter your name: ') password = input('Enter your password: ') password_len = len(password) password_secret = '*' * password_len print(f'Your name is: {username} and your {password_secret} is {password_len} letters long.')
maxvalue = int(input("Until which value do you want to calculate the prime numbers?")) # The first prime, 2, we skip, so that afterwards we can make our loop faster by skipping all even numbers: print("The prime numbers under", maxvalue, "are:") print(2) # Break as soon as isprime is False for n in range(3, maxvalue + 1, 2): # Let's start out by assuming n is a prime: isprime = True # For each n we want to look at all values larger than one, and smaller than n: for x in range(2, n): # If n is divisible by x, the remainder of this division is 0. We can check this with the modulo operator: if n % x == 0: # If we get here the current n is not a prime. isprime = False # we don't need to check further numbers break # If isprime is still True this is indeed a prime if isprime: print(n) # Alternative approach with for-else for n in range(3, maxvalue + 1, 2): for x in range(2, n): if n % x == 0: # In this case we only need to break break else: # When this else block is reached n is a prime print(n)
maxvalue = int(input('Until which value do you want to calculate the prime numbers?')) print('The prime numbers under', maxvalue, 'are:') print(2) for n in range(3, maxvalue + 1, 2): isprime = True for x in range(2, n): if n % x == 0: isprime = False break if isprime: print(n) for n in range(3, maxvalue + 1, 2): for x in range(2, n): if n % x == 0: break else: print(n)
s,n = [int(x) for x in input().split()] arr = [] for _ in range(n): x,y = [int(x) for x in input().split()] arr.append((x,y)) arr.sort(key=lambda x: x[0]) msg = "YES" for i in range(n): x,y = arr[i] if s > x: s += y else: msg = "NO" break print(msg)
(s, n) = [int(x) for x in input().split()] arr = [] for _ in range(n): (x, y) = [int(x) for x in input().split()] arr.append((x, y)) arr.sort(key=lambda x: x[0]) msg = 'YES' for i in range(n): (x, y) = arr[i] if s > x: s += y else: msg = 'NO' break print(msg)
class ProfileParsingError(Exception): pass class RoleNotFoundError(Exception): def __init__(self, credential_method, *args, **kwargs): Exception.__init__(self, *args, **kwargs) # a string describing the IAM context self.credential_method = credential_method class AssumeRoleError(Exception): def __init__(self, credential_method, *args, **kwargs): Exception.__init__(self, *args, **kwargs) # a string describing the IAM context self.credential_method = credential_method
class Profileparsingerror(Exception): pass class Rolenotfounderror(Exception): def __init__(self, credential_method, *args, **kwargs): Exception.__init__(self, *args, **kwargs) self.credential_method = credential_method class Assumeroleerror(Exception): def __init__(self, credential_method, *args, **kwargs): Exception.__init__(self, *args, **kwargs) self.credential_method = credential_method
name = 'Jatin Mehta' greeting = "Hello World, I am " print(greeting, name)
name = 'Jatin Mehta' greeting = 'Hello World, I am ' print(greeting, name)
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # https://leetcode.com/problems/subtree-of-another-tree/solution/ def isSubtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ s_res = self.preorder(s, True) t_res = self.preorder(t, True) return t_res in s_res def preorder(self, root, isLeft): if root is None: if isLeft: return "lnull" else: return "rnull" return "#" + str(root.val) + " " + self.preorder(root.left, True) + " " + self.preorder(root.right, False) # def isSubtree(self, s, t): # return self.traverse(s, t) # def equals(self, x, y): # if x is None and y is None: # return True # if x is None or y is None: # return False # return x.val == y.val and self.equals(x.left, y.left) and self.equals(x.right, y.right) # def traverse(self, s, t): # return s is not None and (self.equals(s, t) or self.traverse(s.left, t) or self.traverse(s.right, t))
class Solution(object): def is_subtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ s_res = self.preorder(s, True) t_res = self.preorder(t, True) return t_res in s_res def preorder(self, root, isLeft): if root is None: if isLeft: return 'lnull' else: return 'rnull' return '#' + str(root.val) + ' ' + self.preorder(root.left, True) + ' ' + self.preorder(root.right, False)
for i in range(100, 1000): sum = 0 for s in range(0, 3): i = str(i) sum = sum + int(i[s]) ** 3 i = int(i) if sum == i: print(i) for i in range(1000, 10000): sum = 0 for s in range(0, 4): i = str(i) sum = sum + int(i[s]) ** 4 i = int(i) if sum == i: print(i)
for i in range(100, 1000): sum = 0 for s in range(0, 3): i = str(i) sum = sum + int(i[s]) ** 3 i = int(i) if sum == i: print(i) for i in range(1000, 10000): sum = 0 for s in range(0, 4): i = str(i) sum = sum + int(i[s]) ** 4 i = int(i) if sum == i: print(i)
def check_user_timeblock_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_1 == section.primary_instructor.user: color = sections_dict[section.id].get('color') if preference.weight: if section.timeblock == preference.object_2: # If the preference is positive, and the specified teacher is teaching a class during the # specified timeblock, highlight the section green. if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append( 'The specified teacher is teaching a class during the specified timeblock' ) else: # If the preference is positive, and the specified teacher is not teaching a class during the # specified timeblock, highlight it red. sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'specified teacher is not teaching a class during the specified timeblock' ) else: # If the preference is negative, and the specified teacher is teaching a class during the # specified timeblock, highlight the section red. if section.timeblock == preference.object_2: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'preference is negative, and the specified teacher is teaching a class during the ' 'specified timeblock ' ) def check_user_course_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_2 == section.course: color = sections_dict[section.id].get('color') if preference.weight: if section.primary_instructor.user == preference.object_1: # If the preference is positive, and the course is taught by the specified teacher, highlight # it green. if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append( 'preference is positive, and the course is taught by the specified teacher' ) else: # If the preference is positive, and the course is not taught by the specified teacher, # highlight it red. sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'the course is not taught by the specified teacher' ) else: # If the preference is negative, and the course is taught by the specified teacher, highlight it # red. if section.primary_instructor.user == preference.object_1: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'the preference is negative, and the course is taught by the specified teacher' ) def check_user_section_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_2 == section: color = sections_dict[section.id].get('color') if preference.weight: if section.primary_instructor.user == preference.object_1: # If the preference is positive, and the section is taught by the specified teacher, highlight # it green. if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append( 'Preference is positive, and the section is taught by the specified teacher' ) else: # If the preference is positive, and the course is not taught by the specified teacher, # highlight it red. sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'The section is not taught by the specified teacher' ) else: # If the preference is negative, and the section is taught by the specified teacher, highlight it # red. if section.primary_instructor.user == preference.object_1: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'The preference is negative, and the section is taught by the specified teacher' ) def check_section_timeblock_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_1 == section: color = sections_dict[section.id].get('color') if preference.weight: if section.timeblock == preference.object_2: # If the preference is positive, and the section is at the specified timeblock, highlight it # green. if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append( 'Preference is positive, and the section is at the specified timeblock' ) else: # If the preference is positive, and the section is not at the specified timeblock, highlight # it red. sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'The section is not at the specified timeblock' ) else: # If the preference is negative, and the section is at the specified timeblock, highlight it red. if section.timeblock == preference.object_2: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append( 'Preference is negative, and the section is at the specified timeblock' )
def check_user_timeblock_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_1 == section.primary_instructor.user: color = sections_dict[section.id].get('color') if preference.weight: if section.timeblock == preference.object_2: if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append('The specified teacher is teaching a class during the specified timeblock') else: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('specified teacher is not teaching a class during the specified timeblock') elif section.timeblock == preference.object_2: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('preference is negative, and the specified teacher is teaching a class during the specified timeblock ') def check_user_course_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_2 == section.course: color = sections_dict[section.id].get('color') if preference.weight: if section.primary_instructor.user == preference.object_1: if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append('preference is positive, and the course is taught by the specified teacher') else: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('the course is not taught by the specified teacher') elif section.primary_instructor.user == preference.object_1: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('the preference is negative, and the course is taught by the specified teacher') def check_user_section_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_2 == section: color = sections_dict[section.id].get('color') if preference.weight: if section.primary_instructor.user == preference.object_1: if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append('Preference is positive, and the section is taught by the specified teacher') else: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('The section is not taught by the specified teacher') elif section.primary_instructor.user == preference.object_1: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('The preference is negative, and the section is taught by the specified teacher') def check_section_timeblock_preference(section, preferences, sections_dict): for preference in preferences: if preference.object_1 == section: color = sections_dict[section.id].get('color') if preference.weight: if section.timeblock == preference.object_2: if color != 'red': sections_dict[section.id]['color'] = 'green' sections_dict[section.id]['positive_points'].append('Preference is positive, and the section is at the specified timeblock') else: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('The section is not at the specified timeblock') elif section.timeblock == preference.object_2: sections_dict[section.id]['color'] = 'red' sections_dict[section.id]['negative_points'].append('Preference is negative, and the section is at the specified timeblock')
# Runs with PythonScript plugin # Copy to %APPDATA%\Roaming\Notepad++\plugins\config\PythonScript\scripts search_text_4 = '[4[' search_text_8 = '[8[' search_text_f = '[f[' search_text_h = '[h[' search_text_q = '[q[' search_text_i = '[i[' search_text_o = '[o[' search_text_R = '[R[' search_text_r = '[r[' search_text_S = '[S[' search_text_u = '[u[' search_text_v = '[v[' replacement_f = '<iframe title="SketchFab model" width="480" height="360"\n src="https://sketchfab.com/models/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX/embed?ui_controls=0&amp;ui_infos=0&amp;ui_inspector=0&amp;ui_watermark=1&amp;ui_watermark_link=0" allow="autoplay; fullscreen; vr" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>' replacement_h = '<div class="row">\n <div class="col-8 col-12-narrow">\n <h3>\n \n </h3>\n </div>\n </div>\n <div class="row">\n \n </div>' replacement_i = '<li class="do">\n \n </li>\n <li class="how">\n \n </li>'; replacement_o = '<li class="option" onclick="Right|Wrong(this, \'TODO\');">\n \n </li>' replacement_q = '<li class="question" onclick="Reveal(\'TODO\');">\n \n </li>\n <li class="hidden written answer" id="TODO">\n \n </li>' replacement_r = '<div class="row">\n \n </div>' replacement_R = '</div>\n </div>\n\n <div class="row">\n <div class="col-8 col-12-narrow">' replacement_u = '<ul>\n <li class="question" onclick="Reveal(\'TODO\');">\n \n </li>\n <li class="hidden written answer" id="TODO">\n \n </li>\n </ul>' replacement_v = '<div class="col-8 col-12-narrow">\n <iframe src="https://durham.cloud.panopto.eu/Panopto/Pages/Embed.aspx?id="\n height="360" width="640" allow="fullscreen" loading="lazy"></iframe>\n </div>' replacement_4 = '<div class="col-4 col-12-narrow">\n <span class="image">\n <img src="images/" />\n </span>\n </div>' replacement_8 = '<div class="col-8 col-12-narrow">\n <p>\n \n </p>\n </div>' replacement_S = '\n </div>\n </div>\n </section>\n\n <section id="SECTION_ID" class="main">\n <header>\n <div class="container">\n <span class="image featured">\n <img src="images/IMAGE"\n title=""\n alt="Credit: " />\n </span>\n <h2>TODO_SECTION_HEADING</h2>\n </div>\n </header>\n <div class="content dark style3">\n <div class="container">\n <div class="row">\n <div class="col-8 col-12-narrow">\n <h3>TODO_SUBHEADING</h3>\n </div>\n </div>\n <div class="row">\n \n </div>'; def callback_sci_CHARADDED(args): if chr(args['ch']) == '[': cp = editor.getCurrentPos() search_text_length = 3 start_of_search_text_pos = cp - search_text_length if editor.getTextRange(start_of_search_text_pos, cp) == search_text_f: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_f) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_f) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_R: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_R) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_R) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_r: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_r) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_r) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_h: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_h) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_h) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_i: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_i) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_i) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_o: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_o) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_o) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_q: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_q) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_q) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_u: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_u) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_u) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_4: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_4) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_4) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_8: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_8) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_8) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_v: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_v) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_v) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_S: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_S) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_S) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() editor.callback(callback_sci_CHARADDED, [SCINTILLANOTIFICATION.CHARADDED])
search_text_4 = '[4[' search_text_8 = '[8[' search_text_f = '[f[' search_text_h = '[h[' search_text_q = '[q[' search_text_i = '[i[' search_text_o = '[o[' search_text_r = '[R[' search_text_r = '[r[' search_text_s = '[S[' search_text_u = '[u[' search_text_v = '[v[' replacement_f = '<iframe title="SketchFab model" width="480" height="360"\n src="https://sketchfab.com/models/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX/embed?ui_controls=0&amp;ui_infos=0&amp;ui_inspector=0&amp;ui_watermark=1&amp;ui_watermark_link=0" allow="autoplay; fullscreen; vr" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>' replacement_h = '<div class="row">\n <div class="col-8 col-12-narrow">\n <h3>\n \n </h3>\n </div>\n </div>\n <div class="row">\n \n </div>' replacement_i = '<li class="do">\n \n </li>\n <li class="how">\n \n </li>' replacement_o = '<li class="option" onclick="Right|Wrong(this, \'TODO\');">\n \n </li>' replacement_q = '<li class="question" onclick="Reveal(\'TODO\');">\n \n </li>\n <li class="hidden written answer" id="TODO">\n \n </li>' replacement_r = '<div class="row">\n \n </div>' replacement_r = '</div>\n </div>\n\n <div class="row">\n <div class="col-8 col-12-narrow">' replacement_u = '<ul>\n <li class="question" onclick="Reveal(\'TODO\');">\n \n </li>\n <li class="hidden written answer" id="TODO">\n \n </li>\n </ul>' replacement_v = '<div class="col-8 col-12-narrow">\n <iframe src="https://durham.cloud.panopto.eu/Panopto/Pages/Embed.aspx?id="\n height="360" width="640" allow="fullscreen" loading="lazy"></iframe>\n </div>' replacement_4 = '<div class="col-4 col-12-narrow">\n <span class="image">\n <img src="images/" />\n </span>\n </div>' replacement_8 = '<div class="col-8 col-12-narrow">\n <p>\n \n </p>\n </div>' replacement_s = '\n </div>\n </div>\n </section>\n\n <section id="SECTION_ID" class="main">\n <header>\n <div class="container">\n <span class="image featured">\n <img src="images/IMAGE"\n title=""\n alt="Credit: " />\n </span>\n <h2>TODO_SECTION_HEADING</h2>\n </div>\n </header>\n <div class="content dark style3">\n <div class="container">\n <div class="row">\n <div class="col-8 col-12-narrow">\n <h3>TODO_SUBHEADING</h3>\n </div>\n </div>\n <div class="row">\n \n </div>' def callback_sci_charadded(args): if chr(args['ch']) == '[': cp = editor.getCurrentPos() search_text_length = 3 start_of_search_text_pos = cp - search_text_length if editor.getTextRange(start_of_search_text_pos, cp) == search_text_f: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_f) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_f) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_R: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_R) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_R) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_r: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_r) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_r) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_h: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_h) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_h) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_i: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_i) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_i) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_o: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_o) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_o) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_q: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_q) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_q) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_u: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_u) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_u) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_4: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_4) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_4) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_8: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_8) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_8) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_v: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_v) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_v) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() elif editor.getTextRange(start_of_search_text_pos, cp) == search_text_S: editor.beginUndoAction() editor.deleteRange(start_of_search_text_pos, search_text_length) editor.insertText(start_of_search_text_pos, replacement_S) editor.endUndoAction() end_of_search_text_pos = start_of_search_text_pos + len(replacement_S) editor.setCurrentPos(end_of_search_text_pos) editor.setSelection(end_of_search_text_pos, end_of_search_text_pos) editor.chooseCaretX() editor.callback(callback_sci_CHARADDED, [SCINTILLANOTIFICATION.CHARADDED])
#! /usr/bin/env Pyrhon3 list_of_tuples_even = [] list_of_tuples_odd = [] for i in range(1, 11): for j in range(1, 11): if i % 2 == 0: list_of_tuples_even.append((i, j, i * j)) else: list_of_tuples_odd.append((i, j, i * j)) print(list_of_tuples_odd) print('******************') print(list_of_tuples_even)
list_of_tuples_even = [] list_of_tuples_odd = [] for i in range(1, 11): for j in range(1, 11): if i % 2 == 0: list_of_tuples_even.append((i, j, i * j)) else: list_of_tuples_odd.append((i, j, i * j)) print(list_of_tuples_odd) print('******************') print(list_of_tuples_even)
#!/usr/bin/python3 for first_digit in range(10): for second_digit in range(first_digit+1, 10): if first_digit == 8 and second_digit == 9: print("{}{}".format(first_digit, second_digit)) else: print("{}{}".format(first_digit, second_digit), end=", ")
for first_digit in range(10): for second_digit in range(first_digit + 1, 10): if first_digit == 8 and second_digit == 9: print('{}{}'.format(first_digit, second_digit)) else: print('{}{}'.format(first_digit, second_digit), end=', ')
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print("-- This parrot wouldn't", action, end =' ') print("if you put", voltage, "volts through it.") print("-- Lovely plumage, the", type) print("-- It's", state, "!") parrot(1000) parrot(voltage=1000000, action='VOOOOOM') parrot('a million', 'bereft of life', 'jump')
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print("-- This parrot wouldn't", action, end=' ') print('if you put', voltage, 'volts through it.') print('-- Lovely plumage, the', type) print("-- It's", state, '!') parrot(1000) parrot(voltage=1000000, action='VOOOOOM') parrot('a million', 'bereft of life', 'jump')