idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
13,000 | def Pop ( self ) : if self . tagList : tag = self . tagList [ 0 ] del self . tagList [ 0 ] else : tag = None return tag | Remove the tag from the front of the list and return it . |
13,001 | def get_context ( self , context ) : i = 0 while i < len ( self . tagList ) : tag = self . tagList [ i ] if tag . tagClass == Tag . applicationTagClass : pass elif tag . tagClass == Tag . contextTagClass : if tag . tagNumber == context : return tag elif tag . tagClass == Tag . openingTagClass : keeper = tag . tagNumber... | Return a tag or a list of tags context encoded . |
13,002 | def decode ( self , pdu ) : while pdu . pduData : self . tagList . append ( Tag ( pdu ) ) | decode the tags from a PDU . |
13,003 | def coerce ( cls , arg ) : try : return cls ( arg ) . value except ( ValueError , TypeError ) : raise InvalidParameterDatatype ( "%s coerce error" % ( cls . __name__ , ) ) | Given an arg return the appropriate value given the class . |
13,004 | def keylist ( self ) : items = self . enumerations . items ( ) items . sort ( lambda a , b : self . cmp ( a [ 1 ] , b [ 1 ] ) ) rslt = [ None ] * ( items [ - 1 ] [ 1 ] + 1 ) for key , value in items : rslt [ value ] = key return rslt | Return a list of names in order by value . |
13,005 | def CalcDayOfWeek ( self ) : year , month , day , day_of_week = self . value day_of_week = 255 if year == 255 : pass elif month in _special_mon_inv : pass elif day in _special_day_inv : pass else : try : today = time . mktime ( ( year + 1900 , month , day , 0 , 0 , 0 , 0 , 0 , - 1 ) ) day_of_week = time . gmtime ( toda... | Calculate the correct day of the week . |
13,006 | def now ( self , when = None ) : if when is None : when = _TaskManager ( ) . get_time ( ) tup = time . localtime ( when ) self . value = ( tup [ 0 ] - 1900 , tup [ 1 ] , tup [ 2 ] , tup [ 6 ] + 1 ) return self | Set the current value to the correct tuple based on the seconds since the epoch . If when is not provided get the current time from the task manager . |
13,007 | def has_device_info ( self , key ) : if _debug : DeviceInfoCache . _debug ( "has_device_info %r" , key ) return key in self . cache | Return true iff cache has information about the device . |
13,008 | def iam_device_info ( self , apdu ) : if _debug : DeviceInfoCache . _debug ( "iam_device_info %r" , apdu ) if not isinstance ( apdu , IAmRequest ) : raise ValueError ( "not an IAmRequest: %r" % ( apdu , ) ) device_instance = apdu . iAmDeviceIdentifier [ 1 ] device_info = self . cache . get ( device_instance , None ) if... | Create a device information record based on the contents of an IAmRequest and put it in the cache . |
13,009 | def update_device_info ( self , device_info ) : if _debug : DeviceInfoCache . _debug ( "update_device_info %r" , device_info ) if not hasattr ( device_info , '_ref_count' ) : device_info . _ref_count = 0 cache_id , cache_address = getattr ( device_info , '_cache_keys' , ( None , None ) ) if ( cache_id is not None ) and... | The application has updated one or more fields in the device information record and the cache needs to be updated to reflect the changes . If this is a cached version of a persistent record then this is the opportunity to update the database . |
13,010 | def acquire ( self , key ) : if _debug : DeviceInfoCache . _debug ( "acquire %r" , key ) if isinstance ( key , int ) : device_info = self . cache . get ( key , None ) elif not isinstance ( key , Address ) : raise TypeError ( "key must be integer or an address" ) elif key . addrType not in ( Address . localStationAddr ,... | Return the known information about the device and mark the record as being used by a segmenation state machine . |
13,011 | def release ( self , device_info ) : if _debug : DeviceInfoCache . _debug ( "release %r" , device_info ) if device_info . _ref_count == 0 : raise RuntimeError ( "reference count" ) device_info . _ref_count -= 1 | This function is called by the segmentation state machine when it has finished with the device information . |
13,012 | def get_services_supported ( self ) : if _debug : Application . _debug ( "get_services_supported" ) services_supported = ServicesSupported ( ) for service_choice , service_request_class in confirmed_request_types . items ( ) : service_helper = "do_" + service_request_class . __name__ if hasattr ( self , service_helper ... | Return a ServicesSupported bit string based in introspection look for helper methods that match confirmed and unconfirmed services . |
13,013 | def get_next_task ( self ) : if _debug : TaskManager . _debug ( "get_next_task" ) now = _time ( ) task = None delta = None if self . tasks : when , n , nxttask = self . tasks [ 0 ] if when <= now : heappop ( self . tasks ) task = nxttask task . isScheduled = False if self . tasks : when , n , nxttask = self . tasks [ 0... | get the next task if there s one that should be processed and return how long it will be until the next one should be processed . |
13,014 | def match_date ( date , date_pattern ) : year , month , day , day_of_week = date year_p , month_p , day_p , day_of_week_p = date_pattern if year_p == 255 : pass elif year != year_p : return False if month_p == 255 : pass elif month_p == 13 : if ( month % 2 ) == 0 : return False elif month_p == 14 : if ( month % 2 ) == ... | Match a specific date a four - tuple with no special values with a date pattern four - tuple possibly having special values . |
13,015 | def datetime_to_time ( date , time ) : if ( 255 in date ) or ( 255 in time ) : raise RuntimeError ( "specific date and time required" ) time_tuple = ( date [ 0 ] + 1900 , date [ 1 ] , date [ 2 ] , time [ 0 ] , time [ 1 ] , time [ 2 ] , 0 , 0 , - 1 , ) return _mktime ( time_tuple ) | Take the date and time 4 - tuples and return the time in seconds since the epoch as a floating point number . |
13,016 | def _check_reliability ( self , old_value = None , new_value = None ) : if _debug : LocalScheduleObject . _debug ( "_check_reliability %r %r" , old_value , new_value ) try : schedule_default = self . scheduleDefault if schedule_default is None : raise ValueError ( "scheduleDefault expected" ) if not isinstance ( schedu... | This function is called when the object is created and after one of its configuration properties has changed . The new and old value parameters are ignored this is called after the property has been changed and this is only concerned with the current value . |
13,017 | def present_value_changed ( self , old_value , new_value ) : if _debug : LocalScheduleInterpreter . _debug ( "present_value_changed %s %s" , old_value , new_value ) if not self . sched_obj . _app : if _debug : LocalScheduleInterpreter . _debug ( " - no application" ) return obj_prop_refs = self . sched_obj . listOfO... | This function is called when the presentValue of the local schedule object has changed both internally by this interpreter or externally by some client using WriteProperty . |
13,018 | def do_gc ( self , args ) : instance_type = getattr ( types , 'InstanceType' , object ) type2count = { } type2all = { } for o in gc . get_objects ( ) : if type ( o ) == instance_type : type2count [ o . __class__ ] = type2count . get ( o . __class__ , 0 ) + 1 type2all [ o . __class__ ] = type2all . get ( o . __class__ ,... | gc - print out garbage collection information |
13,019 | def do_buggers ( self , args ) : args = args . split ( ) if _debug : ConsoleCmd . _debug ( "do_buggers %r" , args ) if not self . handlers : self . stdout . write ( "no handlers\n" ) else : self . stdout . write ( "handlers: " ) self . stdout . write ( ', ' . join ( loggerName or '__root__' for loggerName in self . han... | buggers - list the console logging handlers |
13,020 | def do_EOF ( self , args ) : if _debug : ConsoleCmd . _debug ( "do_EOF %r" , args ) return self . do_exit ( args ) | Exit on system end of file character |
13,021 | def do_shell ( self , args ) : if _debug : ConsoleCmd . _debug ( "do_shell %r" , args ) os . system ( args ) | Pass command to a system shell when line begins with ! |
13,022 | def confirmation ( self , pdu ) : if _debug : NetworkAdapter . _debug ( "confirmation %r (net=%r)" , pdu , self . adapterNet ) npdu = NPDU ( user_data = pdu . pduUserData ) npdu . decode ( pdu ) self . adapterSAP . process_npdu ( self , npdu ) | Decode upstream PDUs and pass them up to the service access point . |
13,023 | def process_npdu ( self , npdu ) : if _debug : NetworkAdapter . _debug ( "process_npdu %r (net=%r)" , npdu , self . adapterNet ) pdu = PDU ( user_data = npdu . pduUserData ) npdu . encode ( pdu ) self . request ( pdu ) | Encode NPDUs from the service access point and send them downstream . |
13,024 | def bind ( self , server , net = None , address = None ) : if _debug : NetworkServiceAccessPoint . _debug ( "bind %r net=%r address=%r" , server , net , address ) if net in self . adapters : raise RuntimeError ( "already bound" ) adapter = NetworkAdapter ( self , net ) self . adapters [ net ] = adapter if _debug : Netw... | Create a network adapter object and bind . |
13,025 | def unpack_ip_addr ( addr ) : if isinstance ( addr , bytearray ) : addr = bytes ( addr ) return ( socket . inet_ntoa ( addr [ 0 : 4 ] ) , struct . unpack ( '!H' , addr [ 4 : 6 ] ) [ 0 ] ) | Given a six - octet BACnet address return an IP address tuple . |
13,026 | def ModuleLogger ( globs ) : if not globs . has_key ( '_debug' ) : raise RuntimeError ( "define _debug before creating a module logger" ) logger_name = globs [ '__name__' ] logger = logging . getLogger ( logger_name ) logger . globs = globs if '.' not in logger_name : hdlr = logging . StreamHandler ( ) hdlr . setLevel ... | Create a module level logger . |
13,027 | def bacpypes_debugging ( obj ) : logger = logging . getLogger ( obj . __module__ + '.' + obj . __name__ ) obj . _logger = logger obj . _debug = logger . debug obj . _info = logger . info obj . _warning = logger . warning obj . _error = logger . error obj . _exception = logger . exception obj . _fatal = logger . fatal r... | Function for attaching a debugging logger to a class or function . |
13,028 | def add_node ( self , node ) : if _debug : Network . _debug ( "add_node %r" , node ) self . nodes . append ( node ) node . lan = self if not node . name : node . name = '%s:%s' % ( self . name , node . address ) | Add a node to this network let the node know which network it s on . |
13,029 | def remove_node ( self , node ) : if _debug : Network . _debug ( "remove_node %r" , node ) self . nodes . remove ( node ) node . lan = None | Remove a node from this network . |
13,030 | def process_pdu ( self , pdu ) : if _debug : Network . _debug ( "process_pdu(%s) %r" , self . name , pdu ) if self . traffic_log : self . traffic_log ( self . name , pdu ) if self . drop_percent != 0.0 : if ( random . random ( ) * 100.0 ) < self . drop_percent : if _debug : Network . _debug ( " - packet dropped" ) r... | Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous . |
13,031 | def bind ( self , lan ) : if _debug : Node . _debug ( "bind %r" , lan ) lan . add_node ( self ) | bind to a LAN . |
13,032 | def Match ( addr1 , addr2 ) : if _debug : Match . _debug ( "Match %r %r" , addr1 , addr2 ) if ( addr2 . addrType == Address . localBroadcastAddr ) : return ( addr1 . addrType == Address . localStationAddr ) or ( addr1 . addrType == Address . localBroadcastAddr ) elif ( addr2 . addrType == Address . localStationAddr ) :... | Return true iff addr1 matches addr2 . |
13,033 | def do_WhoIsRequest ( self , apdu ) : if _debug : WhoIsIAmServices . _debug ( "do_WhoIsRequest %r" , apdu ) if not self . localDevice : if _debug : WhoIsIAmServices . _debug ( " - no local device" ) return low_limit = apdu . deviceInstanceRangeLowLimit high_limit = apdu . deviceInstanceRangeHighLimit if ( low_limit ... | Respond to a Who - Is request . |
13,034 | def do_IAmRequest ( self , apdu ) : if _debug : WhoIsIAmServices . _debug ( "do_IAmRequest %r" , apdu ) if apdu . iAmDeviceIdentifier is None : raise MissingRequiredParameter ( "iAmDeviceIdentifier required" ) if apdu . maxAPDULengthAccepted is None : raise MissingRequiredParameter ( "maxAPDULengthAccepted required" ) ... | Respond to an I - Am request . |
13,035 | def do_WhoHasRequest ( self , apdu ) : if _debug : WhoHasIHaveServices . _debug ( "do_WhoHasRequest, %r" , apdu ) if not self . localDevice : if _debug : WhoIsIAmServices . _debug ( " - no local device" ) return if apdu . limits is not None : low_limit = apdu . limits . deviceInstanceRangeLowLimit high_limit = apdu ... | Respond to a Who - Has request . |
13,036 | def do_IHaveRequest ( self , apdu ) : if _debug : WhoHasIHaveServices . _debug ( "do_IHaveRequest %r" , apdu ) if apdu . deviceIdentifier is None : raise MissingRequiredParameter ( "deviceIdentifier required" ) if apdu . objectIdentifier is None : raise MissingRequiredParameter ( "objectIdentifier required" ) if apdu .... | Respond to a I - Have request . |
13,037 | def set_state ( self , newState , timer = 0 ) : if _debug : SSM . _debug ( "set_state %r (%s) timer=%r" , newState , SSM . transactionLabels [ newState ] , timer ) if ( self . state == COMPLETED ) or ( self . state == ABORTED ) : e = RuntimeError ( "invalid state transition from %s to %s" % ( SSM . transactionLabels [ ... | This function is called when the derived class wants to change state . |
13,038 | def set_segmentation_context ( self , apdu ) : if _debug : SSM . _debug ( "set_segmentation_context %s" , repr ( apdu ) ) self . segmentAPDU = apdu | This function is called to set the segmentation context . |
13,039 | def get_segment ( self , indx ) : if _debug : SSM . _debug ( "get_segment %r" , indx ) if not self . segmentAPDU : raise RuntimeError ( "no segmentation context established" ) if indx >= self . segmentCount : raise RuntimeError ( "invalid segment number %r, APDU has %r segments" % ( indx , self . segmentCount ) ) if se... | This function returns an APDU coorisponding to a particular segment of a confirmed request or complex ack . The segmentAPDU is the context . |
13,040 | def append_segment ( self , apdu ) : if _debug : SSM . _debug ( "append_segment %r" , apdu ) if not self . segmentAPDU : raise RuntimeError ( "no segmentation context established" ) self . segmentAPDU . put_data ( apdu . pduData ) | This function appends the apdu content to the end of the current APDU being built . The segmentAPDU is the context . |
13,041 | def fill_window ( self , seqNum ) : if _debug : SSM . _debug ( "fill_window %r" , seqNum ) if _debug : SSM . _debug ( " - actualWindowSize: %r" , self . actualWindowSize ) for ix in range ( self . actualWindowSize ) : apdu = self . get_segment ( seqNum + ix ) self . ssmSAP . request ( apdu ) if not apdu . apduMor : ... | This function sends all of the packets necessary to fill out the segmentation window . |
13,042 | def request ( self , apdu ) : if _debug : ClientSSM . _debug ( "request %r" , apdu ) apdu . pduSource = None apdu . pduDestination = self . pdu_address self . ssmSAP . request ( apdu ) | This function is called by client transaction functions when it wants to send a message to the device . |
13,043 | def indication ( self , apdu ) : if _debug : ClientSSM . _debug ( "indication %r" , apdu ) if ( apdu . apduType != ConfirmedRequestPDU . pduType ) : raise RuntimeError ( "invalid APDU (1)" ) self . set_segmentation_context ( apdu ) if ( not self . device_info ) or ( self . device_info . maxApduLengthAccepted is None ) ... | This function is called after the device has bound a new transaction and wants to start the process rolling . |
13,044 | def response ( self , apdu ) : if _debug : ClientSSM . _debug ( "response %r" , apdu ) apdu . pduSource = self . pdu_address apdu . pduDestination = None self . ssmSAP . sap_response ( apdu ) | This function is called by client transaction functions when they want to send a message to the application . |
13,045 | def confirmation ( self , apdu ) : if _debug : ClientSSM . _debug ( "confirmation %r" , apdu ) if self . state == SEGMENTED_REQUEST : self . segmented_request ( apdu ) elif self . state == AWAIT_CONFIRMATION : self . await_confirmation ( apdu ) elif self . state == SEGMENTED_CONFIRMATION : self . segmented_confirmation... | This function is called by the device for all upstream messages related to the transaction . |
13,046 | def process_task ( self ) : if _debug : ClientSSM . _debug ( "process_task" ) if self . state == SEGMENTED_REQUEST : self . segmented_request_timeout ( ) elif self . state == AWAIT_CONFIRMATION : self . await_confirmation_timeout ( ) elif self . state == SEGMENTED_CONFIRMATION : self . segmented_confirmation_timeout ( ... | This function is called when something has taken too long . |
13,047 | def abort ( self , reason ) : if _debug : ClientSSM . _debug ( "abort %r" , reason ) self . set_state ( ABORTED ) abort_pdu = AbortPDU ( False , self . invokeID , reason ) return abort_pdu | This function is called when the transaction should be aborted . |
13,048 | def segmented_request ( self , apdu ) : if _debug : ClientSSM . _debug ( "segmented_request %r" , apdu ) if apdu . apduType == SegmentAckPDU . pduType : if _debug : ClientSSM . _debug ( " - segment ack" ) self . actualWindowSize = apdu . apduWin if not self . in_window ( apdu . apduSeq , self . initialSequenceNumber... | This function is called when the client is sending a segmented request and receives an apdu . |
13,049 | def set_state ( self , newState , timer = 0 ) : if _debug : ServerSSM . _debug ( "set_state %r (%s) timer=%r" , newState , SSM . transactionLabels [ newState ] , timer ) SSM . set_state ( self , newState , timer ) if ( newState == COMPLETED ) or ( newState == ABORTED ) : if _debug : ServerSSM . _debug ( " - remove f... | This function is called when the client wants to change state . |
13,050 | def request ( self , apdu ) : if _debug : ServerSSM . _debug ( "request %r" , apdu ) apdu . pduSource = self . pdu_address apdu . pduDestination = None self . ssmSAP . sap_request ( apdu ) | This function is called by transaction functions to send to the application . |
13,051 | def indication ( self , apdu ) : if _debug : ServerSSM . _debug ( "indication %r" , apdu ) if self . state == IDLE : self . idle ( apdu ) elif self . state == SEGMENTED_REQUEST : self . segmented_request ( apdu ) elif self . state == AWAIT_RESPONSE : self . await_response ( apdu ) elif self . state == SEGMENTED_RESPONS... | This function is called for each downstream packet related to the transaction . |
13,052 | def confirmation ( self , apdu ) : if _debug : ServerSSM . _debug ( "confirmation %r" , apdu ) if self . state != AWAIT_RESPONSE : if _debug : ServerSSM . _debug ( " - warning: not expecting a response" ) if ( apdu . apduType == AbortPDU . pduType ) : if _debug : ServerSSM . _debug ( " - abort" ) self . set_state... | This function is called when the application has provided a response and needs it to be sent to the client . |
13,053 | def process_task ( self ) : if _debug : ServerSSM . _debug ( "process_task" ) if self . state == SEGMENTED_REQUEST : self . segmented_request_timeout ( ) elif self . state == AWAIT_RESPONSE : self . await_response_timeout ( ) elif self . state == SEGMENTED_RESPONSE : self . segmented_response_timeout ( ) elif self . st... | This function is called when the client has failed to send all of the segments of a segmented request the application has taken too long to complete the request or the client failed to ack the segments of a segmented response . |
13,054 | def abort ( self , reason ) : if _debug : ServerSSM . _debug ( "abort %r" , reason ) self . set_state ( ABORTED ) return AbortPDU ( True , self . invokeID , reason ) | This function is called when the application would like to abort the transaction . There is no notification back to the application . |
13,055 | def await_response_timeout ( self ) : if _debug : ServerSSM . _debug ( "await_response_timeout" ) abort = self . abort ( AbortReason . serverTimeout ) self . request ( abort ) | This function is called when the application has taken too long to respond to a clients request . The client has probably long since given up . |
13,056 | def get_next_invoke_id ( self , addr ) : if _debug : StateMachineAccessPoint . _debug ( "get_next_invoke_id" ) initialID = self . nextInvokeID while 1 : invokeID = self . nextInvokeID self . nextInvokeID = ( self . nextInvokeID + 1 ) % 256 if initialID == self . nextInvokeID : raise RuntimeError ( "no available invoke ... | Called by clients to get an unused invoke ID . |
13,057 | def sap_indication ( self , apdu ) : if _debug : StateMachineAccessPoint . _debug ( "sap_indication %r" , apdu ) if self . dccEnableDisable == 'enable' : if _debug : StateMachineAccessPoint . _debug ( " - communications enabled" ) elif self . dccEnableDisable == 'disable' : if _debug : StateMachineAccessPoint . _deb... | This function is called when the application is requesting a new transaction as a client . |
13,058 | def sap_confirmation ( self , apdu ) : if _debug : StateMachineAccessPoint . _debug ( "sap_confirmation %r" , apdu ) if isinstance ( apdu , SimpleAckPDU ) or isinstance ( apdu , ComplexAckPDU ) or isinstance ( apdu , ErrorPDU ) or isinstance ( apdu , RejectPDU ) or isinstance ( apdu , AbortPDU ) : for tr in self . serv... | This function is called when the application is responding to a request the apdu may be a simple ack complex ack error reject or abort . |
13,059 | def add_peer ( self , peerAddr , networks = None ) : if _debug : BTR . _debug ( "add_peer %r networks=%r" , peerAddr , networks ) if peerAddr in self . peers : if not networks : networks = [ ] else : self . peers [ peerAddr ] . extend ( networks ) else : if not networks : networks = [ ] self . peers [ peerAddr ] = netw... | Add a peer and optionally provide a list of the reachable networks . |
13,060 | def delete_peer ( self , peerAddr ) : if _debug : BTR . _debug ( "delete_peer %r" , peerAddr ) del self . peers [ peerAddr ] | Delete a peer . |
13,061 | def register ( self , addr , ttl ) : if ttl <= 0 : raise ValueError ( "time-to-live must be greater than zero" ) if isinstance ( addr , Address ) : self . bbmdAddress = addr else : self . bbmdAddress = Address ( addr ) self . bbmdTimeToLive = ttl self . install_task ( when = 0 ) | Initiate the process of registering with a BBMD . |
13,062 | def unregister ( self ) : pdu = RegisterForeignDevice ( 0 ) pdu . pduDestination = self . bbmdAddress self . request ( pdu ) self . registrationStatus = - 2 self . bbmdAddress = None self . bbmdTimeToLive = None | Drop the registration with a BBMD . |
13,063 | def process_task ( self ) : pdu = RegisterForeignDevice ( self . bbmdTimeToLive ) pdu . pduDestination = self . bbmdAddress self . request ( pdu ) | Called when the registration request should be sent to the BBMD . |
13,064 | def register_foreign_device ( self , addr , ttl ) : if _debug : BIPBBMD . _debug ( "register_foreign_device %r %r" , addr , ttl ) if isinstance ( addr , Address ) : pass elif isinstance ( addr , str ) : addr = Address ( addr ) else : raise TypeError ( "addr must be a string or an Address" ) for fdte in self . bbmdFDT :... | Add a foreign device to the FDT . |
13,065 | def encode_max_segments_accepted ( arg ) : if not arg : return 0 if arg > 64 : return 7 for i in range ( 6 , 0 , - 1 ) : if _max_segments_accepted_encoding [ i ] <= arg : return i raise ValueError ( "invalid max max segments accepted: %r" % ( arg , ) ) | Encode the maximum number of segments the device will accept Section 20 . 1 . 2 . 4 and if the device says it can only accept one segment it shouldn t say that it supports segmentation! |
13,066 | def encode_max_apdu_length_accepted ( arg ) : for i in range ( 5 , - 1 , - 1 ) : if ( arg >= _max_apdu_length_encoding [ i ] ) : return i raise ValueError ( "invalid max APDU length accepted: %r" % ( arg , ) ) | Return the encoding of the highest encodable value less than the value of the arg . |
13,067 | def encode ( self , pdu ) : if _debug : APCI . _debug ( "encode %r" , pdu ) PCI . update ( pdu , self ) if ( self . apduType == ConfirmedRequestPDU . pduType ) : buff = self . apduType << 4 if self . apduSeg : buff += 0x08 if self . apduMor : buff += 0x04 if self . apduSA : buff += 0x02 pdu . put ( buff ) pdu . put ( (... | encode the contents of the APCI into the PDU . |
13,068 | def decode ( self , pdu ) : if _debug : APCI . _debug ( "decode %r" , pdu ) PCI . update ( self , pdu ) buff = pdu . get ( ) self . apduType = ( buff >> 4 ) & 0x0F if ( self . apduType == ConfirmedRequestPDU . pduType ) : self . apduSeg = ( ( buff & 0x08 ) != 0 ) self . apduMor = ( ( buff & 0x04 ) != 0 ) self . apduSA ... | decode the contents of the PDU into the APCI . |
13,069 | def decode ( self , pdu ) : try : tag = pdu . get ( ) self . tagClass = ( tag >> 3 ) & 0x01 self . tagNumber = ( tag >> 4 ) if ( self . tagNumber == 0x0F ) : self . tagNumber = pdu . get ( ) self . tagLVT = tag & 0x07 if ( self . tagLVT == 5 ) : self . tagLVT = pdu . get ( ) if ( self . tagLVT == 254 ) : self . tagLVT ... | Decode a tag from the PDU . |
13,070 | def app_to_context ( self , context ) : if self . tagClass != Tag . applicationTagClass : raise ValueError ( "application tag required" ) if ( self . tagNumber == Tag . booleanAppTag ) : return ContextTag ( context , chr ( self . tagLVT ) ) else : return ContextTag ( context , self . tagData ) | Return a context encoded tag . |
13,071 | def context_to_app ( self , dataType ) : if self . tagClass != Tag . contextTagClass : raise ValueError ( "context tag required" ) if ( dataType == Tag . booleanAppTag ) : return Tag ( Tag . applicationTagClass , Tag . booleanAppTag , struct . unpack ( 'B' , self . tagData ) [ 0 ] , '' ) else : return ApplicationTag ( ... | Return an application encoded tag . |
13,072 | def encode ( self , pdu ) : if _debug : BSLCI . _debug ( "encode %r" , pdu ) PCI . update ( pdu , self ) pdu . put ( self . bslciType ) pdu . put ( self . bslciFunction ) if ( self . bslciLength != len ( self . pduData ) + 4 ) : raise EncodingError ( "invalid BSLCI length" ) pdu . put_short ( self . bslciLength ) | encode the contents of the BSLCI into the PDU . |
13,073 | def decode ( self , pdu ) : if _debug : BSLCI . _debug ( "decode %r" , pdu ) PCI . update ( self , pdu ) self . bslciType = pdu . get ( ) if self . bslciType != 0x83 : raise DecodingError ( "invalid BSLCI type" ) self . bslciFunction = pdu . get ( ) self . bslciLength = pdu . get_short ( ) if ( self . bslciLength != le... | decode the contents of the PDU into the BSLCI . |
13,074 | def ConsoleLogHandler ( loggerRef = '' , handler = None , level = logging . DEBUG , color = None ) : if isinstance ( loggerRef , logging . Logger ) : pass elif isinstance ( loggerRef , str ) : if not loggerRef : loggerRef = _log elif loggerRef not in logging . Logger . manager . loggerDict : raise RuntimeError ( "not a... | Add a handler to stderr with our custom formatter to a logger . |
13,075 | def call_me ( iocb ) : if _debug : call_me . _debug ( "callback_function %r" , iocb ) print ( "call me, %r or %r" % ( iocb . ioResponse , iocb . ioError ) ) | When a controller completes the processing of a request the IOCB can contain one or more functions to be called . |
13,076 | def get_object_class ( object_type , vendor_id = 0 ) : if _debug : get_object_class . _debug ( "get_object_class %r vendor_id=%r" , object_type , vendor_id ) cls = registered_object_types . get ( ( object_type , vendor_id ) ) if _debug : get_object_class . _debug ( " - direct lookup: %s" , repr ( cls ) ) if ( not cl... | Return the class associated with an object type . |
13,077 | def _attr_to_property ( self , attr ) : prop = self . _properties . get ( attr ) if not prop : raise PropertyError ( attr ) return prop | Common routine to translate a python attribute name to a property name and return the appropriate property . |
13,078 | def add_property ( self , prop ) : if _debug : Object . _debug ( "add_property %r" , prop ) self . _properties = _copy ( self . _properties ) self . _properties [ prop . identifier ] = prop self . _values [ prop . identifier ] = prop . default | Add a property to an object . The property is an instance of a Property or one of its derived classes . Adding a property disconnects it from the collection of properties common to all of the objects of its class . |
13,079 | def delete_property ( self , prop ) : if _debug : Object . _debug ( "delete_property %r" , prop ) self . _properties = _copy ( self . _properties ) del self . _properties [ prop . identifier ] if prop . identifier in self . _values : del self . _values [ prop . identifier ] | Delete a property from an object . The property is an instance of a Property or one of its derived classes but only the property is relavent . Deleting a property disconnects it from the collection of properties common to all of the objects of its class . |
13,080 | def debug_contents ( self , indent = 1 , file = sys . stdout , _ids = None ) : klasses = list ( self . __class__ . __mro__ ) klasses . reverse ( ) previous_attrs = ( ) for c in klasses : attrs = getattr ( c , '_debug_contents' , ( ) ) if attrs is previous_attrs : continue for attr in attrs : file . write ( "%s%s = %s\n... | Print out interesting things about the object . |
13,081 | def encode ( self , pdu ) : if _debug : BVLCI . _debug ( "encode %s" , str ( pdu ) ) PCI . update ( pdu , self ) pdu . put ( self . bvlciType ) pdu . put ( self . bvlciFunction ) if ( self . bvlciLength != len ( self . pduData ) + 4 ) : raise EncodingError ( "invalid BVLCI length" ) pdu . put_short ( self . bvlciLength... | encode the contents of the BVLCI into the PDU . |
13,082 | def decode ( self , pdu ) : if _debug : BVLCI . _debug ( "decode %s" , str ( pdu ) ) PCI . update ( self , pdu ) self . bvlciType = pdu . get ( ) if self . bvlciType != 0x81 : raise DecodingError ( "invalid BVLCI type" ) self . bvlciFunction = pdu . get ( ) self . bvlciLength = pdu . get_short ( ) if ( self . bvlciLeng... | decode the contents of the PDU into the BVLCI . |
13,083 | def indication ( self , * args , ** kwargs ) : if not self . current_terminal : raise RuntimeError ( "no active terminal" ) if not isinstance ( self . current_terminal , Server ) : raise RuntimeError ( "current terminal not a server" ) self . current_terminal . indication ( * args , ** kwargs ) | Downstream packet send to current terminal . |
13,084 | def confirmation ( self , * args , ** kwargs ) : if not self . current_terminal : raise RuntimeError ( "no active terminal" ) if not isinstance ( self . current_terminal , Client ) : raise RuntimeError ( "current terminal not a client" ) self . current_terminal . confirmation ( * args , ** kwargs ) | Upstream packet send to current terminal . |
13,085 | def do_ReadPropertyRequest ( self , apdu ) : if _debug : ReadWritePropertyServices . _debug ( "do_ReadPropertyRequest %r" , apdu ) objId = apdu . objectIdentifier if ( objId == ( 'device' , 4194303 ) ) and self . localDevice is not None : if _debug : ReadWritePropertyServices . _debug ( " - wildcard device identifie... | Return the value of some property of one of our objects . |
13,086 | def do_WritePropertyRequest ( self , apdu ) : if _debug : ReadWritePropertyServices . _debug ( "do_WritePropertyRequest %r" , apdu ) obj = self . get_object_id ( apdu . objectIdentifier ) if _debug : ReadWritePropertyServices . _debug ( " - object: %r" , obj ) if not obj : raise ExecutionError ( errorClass = 'object... | Change the value of some property of one of our objects . |
13,087 | def do_ReadPropertyMultipleRequest ( self , apdu ) : if _debug : ReadWritePropertyMultipleServices . _debug ( "do_ReadPropertyMultipleRequest %r" , apdu ) resp = None read_access_result_list = [ ] for read_access_spec in apdu . listOfReadAccessSpecs : objectIdentifier = read_access_spec . objectIdentifier if _debug : R... | Respond to a ReadPropertyMultiple Request . |
13,088 | def handle_write ( self ) : if _debug : UDPDirector . _debug ( "handle_write" ) try : pdu = self . request . get ( ) sent = self . socket . sendto ( pdu . pduData , pdu . pduDestination ) if _debug : UDPDirector . _debug ( " - sent %d octets to %s" , sent , pdu . pduDestination ) except socket . error , err : if _de... | get a PDU from the queue and send it . |
13,089 | def indication ( self , pdu ) : if _debug : UDPDirector . _debug ( "indication %r" , pdu ) addr = pdu . pduDestination peer = self . peers . get ( addr , None ) if not peer : peer = self . actorClass ( self , addr ) peer . indication ( pdu ) | Client requests are queued for delivery . |
13,090 | def _response ( self , pdu ) : if _debug : UDPDirector . _debug ( "_response %r" , pdu ) addr = pdu . pduSource peer = self . peers . get ( addr , None ) if not peer : peer = self . actorClass ( self , addr ) peer . response ( pdu ) | Incoming datagrams are routed through an actor . |
13,091 | def subscriptions ( self ) : if _debug : ChangeOfValueServices . _debug ( "subscriptions" ) subscription_list = [ ] for obj , cov_detection in self . cov_detections . items ( ) : for cov in cov_detection . cov_subscriptions : subscription_list . append ( cov ) return subscription_list | Generator for the active subscriptions . |
13,092 | def bind ( * args ) : if _debug : bind . _debug ( "bind %r" , args ) if not args : for cid , client in client_map . items ( ) : if client . clientPeer : continue if not cid in server_map : raise RuntimeError ( "unmatched server {!r}" . format ( cid ) ) server = server_map [ cid ] if server . serverPeer : raise RuntimeE... | bind a list of clients and servers together top down . |
13,093 | def encode ( self , pdu ) : if _debug : NPCI . _debug ( "encode %s" , repr ( pdu ) ) PCI . update ( pdu , self ) pdu . put ( self . npduVersion ) if self . npduNetMessage is not None : netLayerMessage = 0x80 else : netLayerMessage = 0x00 dnetPresent = 0x00 if self . npduDADR is not None : dnetPresent = 0x20 snetPresent... | encode the contents of the NPCI into the PDU . |
13,094 | def decode ( self , pdu ) : if _debug : NPCI . _debug ( "decode %s" , str ( pdu ) ) PCI . update ( self , pdu ) if len ( pdu . pduData ) < 2 : raise DecodingError ( "invalid length" ) self . npduVersion = pdu . get ( ) if ( self . npduVersion != 0x01 ) : raise DecodingError ( "only version 1 messages supported" ) self ... | decode the contents of the PDU and put them into the NPDU . |
13,095 | def del_actor ( self , actor ) : if _debug : TCPClientDirector . _debug ( "del_actor %r" , actor ) del self . clients [ actor . peer ] if self . serviceElement : self . sap_request ( del_actor = actor ) if actor . peer in self . reconnect : connect_task = FunctionTask ( self . connect , actor . peer ) connect_task . in... | Remove an actor when the socket is closed . |
13,096 | def indication ( self , pdu ) : if _debug : TCPClientDirector . _debug ( "indication %r" , pdu ) addr = pdu . pduDestination client = self . clients . get ( addr , None ) if not client : client = self . actorClass ( self , addr ) client . indication ( pdu ) | Direct this PDU to the appropriate server create a connection if one hasn t already been created . |
13,097 | def indication ( self , pdu ) : if _debug : TCPServerDirector . _debug ( "indication %r" , pdu ) addr = pdu . pduDestination server = self . servers . get ( addr , None ) if not server : raise RuntimeError ( "not a connected server" ) server . indication ( pdu ) | Direct this PDU to the appropriate server . |
13,098 | def indication ( self , pdu ) : if _debug : StreamToPacket . _debug ( "indication %r" , pdu ) for packet in self . packetize ( pdu , self . downstreamBuffer ) : self . request ( packet ) | Message going downstream . |
13,099 | def confirmation ( self , pdu ) : if _debug : StreamToPacket . _debug ( "StreamToPacket.confirmation %r" , pdu ) for packet in self . packetize ( pdu , self . upstreamBuffer ) : self . response ( packet ) | Message going upstream . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.