code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
broadcast_distribution_table = []
for bdte in self.bvlciBDT:
broadcast_distribution_table.append(str(bdte))
return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
('function', 'ReadBroadcastDistributionTableAck'),
... | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 7.75111 | 7.244743 | 1.069894 |
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# save the content
use_dict.__setitem__('address', str(self.fdAddress))
use_dict.__setitem__('ttl', self.fdTTL)
use_dict.__setitem__('remaining', self.fdRemain)
... | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 5.012882 | 5.058381 | 0.991005 |
return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
('function', 'RegisterForeignDevice'),
('ttl', self.bvlciTimeToLive),
)) | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 10.978035 | 11.730503 | 0.935854 |
foreign_device_table = []
for fdte in self.bvlciFDT:
foreign_device_table.append(fdte.dict_contents(as_class=as_class))
return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
('function', 'ReadForeignDeviceTableAck'),
... | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 6.446597 | 6.287728 | 1.025267 |
return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
('function', 'DeleteForeignDeviceTableEntry'),
('address', str(self.bvlciAddress)),
)) | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 11.040832 | 11.997783 | 0.920239 |
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# call the normal procedure
key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
('function', 'DistributeBroadcastToNetwork'),
... | def bvlpdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 5.856159 | 5.909836 | 0.990917 |
global server_address
# check the version
if (sys.version_info[:2] != (2, 5)):
sys.stderr.write("Python 2.5 only\n")
sys.exit(1)
# parse the command line arguments
parser = ArgumentParser(description=__doc__)
parser.add_argument(
"host", nargs='?',
help="ad... | def main() | Main function, called when run as an application. | 2.415922 | 2.402681 | 1.005511 |
if _debug: TaskManager._debug("get_next_task")
# get the time
now = _time()
task = None
delta = None
if self.tasks:
# look at the first task
when, n, nxttask = self.tasks[0]
if when <= now:
# pull it off the ... | def get_next_task(self) | 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. | 4.813307 | 4.634484 | 1.038585 |
global args, server_address
# parse the command line arguments
parser = ArgumentParser(description=__doc__)
parser.add_argument(
"host", nargs='?',
help="address of host (default %r)" % (SERVER_HOST,),
default=SERVER_HOST,
)
parser.add_argument(
"port", ... | def main() | Main function, called when run as an application. | 2.350102 | 2.32704 | 1.00991 |
# unpack the date and pattern
year, month, day, day_of_week = date
year_p, month_p, day_p, day_of_week_p = date_pattern
# check the year
if year_p == 255:
# any year
pass
elif year != year_p:
# specific year
return False
# check the month
if month_p... | def match_date(date, date_pattern) | Match a specific date, a four-tuple with no special values, with a date
pattern, four-tuple possibly having special values. | 1.622877 | 1.609134 | 1.008541 |
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) | def datetime_to_time(date, time) | Take the date and time 4-tuples and return the time in seconds since
the epoch as a floating point number. | 3.926679 | 3.857166 | 1.018022 |
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(schedule_default... | def _check_reliability(self, old_value=None, new_value=None) | 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. | 2.50637 | 2.515837 | 0.996237 |
if _debug: LocalScheduleInterpreter._debug("present_value_changed %s %s", old_value, new_value)
# if this hasn't been added to an application, there's nothing to do
if not self.sched_obj._app:
if _debug: LocalScheduleInterpreter._debug(" - no application")
re... | def present_value_changed(self, old_value, new_value) | 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. | 3.464628 | 3.191019 | 1.085743 |
### humm...
instance_type = getattr(types, 'InstanceType', object)
# snapshot of counts
type2count = {}
type2all = {}
for o in gc.get_objects():
if type(o) == instance_type:
type2count[o.__class__] = type2count.get(o.__class__,0) + 1... | def do_gc(self, args) | gc - print out garbage collection information | 2.529018 | 2.443018 | 1.035202 |
args = args.split()
if _debug: ConsoleCmd._debug("do_bugin %r", args)
# get the logger name and logger
if args:
loggerName = args[0]
if loggerName in logging.Logger.manager.loggerDict:
logger = logging.getLogger(loggerName)
el... | def do_bugin(self, args) | bugin [ <logger> ] - add a console logging handler to a logger | 2.730195 | 2.471069 | 1.104864 |
args = args.split()
if _debug: ConsoleCmd._debug("do_bugout %r", args)
# get the logger name and logger
if args:
loggerName = args[0]
if loggerName in logging.Logger.manager.loggerDict:
logger = logging.getLogger(loggerName)
e... | def do_bugout(self, args) | bugout [ <logger> ] - remove a console logging handler from a logger | 2.950707 | 2.686383 | 1.098394 |
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... | def do_buggers(self, args) | buggers - list the console logging handlers | 2.777084 | 2.599287 | 1.068402 |
if _debug: ConsoleCmd._debug("do_EOF %r", args)
return self.do_exit(args) | def do_EOF(self, args) | Exit on system end of file character | 4.15085 | 4.148689 | 1.000521 |
if _debug: ConsoleCmd._debug("do_shell %r", args)
os.system(args) | def do_shell(self, args) | Pass command to a system shell when line begins with '! | 5.465648 | 6.480479 | 0.843402 |
if _debug: ConsoleCmd._debug("do_help %r", args)
# the only reason to define this method is for the help text in the doc string
cmd.Cmd.do_help(self, args) | def do_help(self, args) | Get help on commands
'help' or '?' with no arguments prints a list of commands for which help is available
'help <command>' or '? <command>' gives help on <command> | 6.677097 | 8.126911 | 0.821603 |
cmd.Cmd.preloop(self) ## sets up command completion
try:
if readline:
readline.read_history_file(sys.argv[0] + ".history")
except Exception, err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err) | def preloop(self) | Initialization before prompting user for commands.
Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub. | 4.816334 | 3.650217 | 1.319465 |
try:
if readline:
readline.write_history_file(sys.argv[0] + ".history")
except Exception, err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
# clean up command completion
cmd.Cmd.postloop(... | def postloop(self) | Take care of any unfinished business.
Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub. | 5.205504 | 4.928957 | 1.056107 |
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) | def confirmation(self, pdu) | Decode upstream PDUs and pass them up to the service access point. | 6.962814 | 6.402108 | 1.087581 |
if _debug: NetworkAdapter._debug("process_npdu %r (net=%r)", npdu, self.adapterNet)
pdu = PDU(user_data=npdu.pduUserData)
npdu.encode(pdu)
self.request(pdu) | def process_npdu(self, npdu) | Encode NPDUs from the service access point and send them downstream. | 6.749459 | 6.255702 | 1.078929 |
if _debug: NetworkServiceAccessPoint._debug("bind %r net=%r address=%r", server, net, address)
# make sure this hasn't already been called with this network
if net in self.adapters:
raise RuntimeError("already bound")
# create an adapter object, add it to our map
... | def bind(self, server, net=None, address=None) | Create a network adapter object and bind. | 3.490864 | 3.41455 | 1.02235 |
if _debug: NetworkServiceAccessPoint._debug("add_router_references %r %r %r", snet, address, dnets)
# see if we have an adapter for the snet
if snet not in self.adapters:
raise RuntimeError("no adapter for network: %d" % (snet,))
# pass this along to the cache
... | def add_router_references(self, snet, address, dnets) | Add/update references to routers. | 4.000008 | 3.994411 | 1.001401 |
if _debug: NetworkServiceAccessPoint._debug("delete_router_references %r %r %r", snet, address, dnets)
# see if we have an adapter for the snet
if snet not in self.adapters:
raise RuntimeError("no adapter for network: %d" % (snet,))
# pass this along to the cache
... | def delete_router_references(self, snet, address=None, dnets=None) | Delete references to routers/networks. | 3.918338 | 4.013268 | 0.976346 |
if _debug: abort._debug("abort %r", err)
# start with the server
if IOServer._highlander:
IOServer._highlander.abort(err)
# now do everything local
for controller in _local_controllers.values():
controller.abort(err) | def abort(err) | Abort everything, everywhere. | 7.846667 | 6.715163 | 1.1685 |
addr, port = addr
return socket.inet_aton(addr) + struct.pack('!H', port & _short_mask) | def pack_ip_addr(addr) | Given an IP address tuple like ('1.2.3.4', 47808) return the six-octet string
useful for a BACnet address. | 5.834328 | 5.039857 | 1.157638 |
if isinstance(addr, bytearray):
addr = bytes(addr)
return (socket.inet_ntoa(addr[0:4]), struct.unpack('!H', addr[4:6])[0]) | def unpack_ip_addr(addr) | Given a six-octet BACnet address, return an IP address tuple. | 2.64541 | 2.398845 | 1.102785 |
# translate the blob into hex
hex_str = binascii.hexlify(data)
# inject the separator if it was given
if sep:
hex_str = sep.join(hex_str[i:i+2] for i in range(0, len(hex_str), 2))
# return the result
return hex_str | def btox(data, sep='') | Return the hex encoding of a blob (string). | 3.231711 | 2.808206 | 1.15081 |
# remove the non-hex characters
data = re.sub("[^0-9a-fA-F]", '', data)
# interpret the hex
return binascii.unhexlify(data) | def xtob(data, sep='') | Interpret the hex encoding of a blob (string). | 4.678495 | 4.050767 | 1.154965 |
# make sure that _debug is defined
if not globs.has_key('_debug'):
raise RuntimeError("define _debug before creating a module logger")
# logger name is the module name
logger_name = globs['__name__']
# create a logger to be assigned to _log
logger = logging.getLogger(logger_name)
... | def ModuleLogger(globs) | Create a module level logger.
To debug a module, create a _debug variable in the module, then use the
ModuleLogger function to create a "module level" logger. When a handler
is added to this logger or a child of this logger, the _debug variable will
be incremented.
All of the calls within functio... | 3.70875 | 3.603118 | 1.029317 |
# create a logger for this object
logger = logging.getLogger(obj.__module__ + '.' + obj.__name__)
# make it available to instances
obj._logger = logger
obj._debug = logger.debug
obj._info = logger.info
obj._warning = logger.warning
obj._error = logger.error
obj._exception = log... | def bacpypes_debugging(obj) | Function for attaching a debugging logger to a class or function. | 3.900174 | 3.802228 | 1.02576 |
args = args.split()
if _debug: ReadPropertyConsoleCmd._debug("do_read %r", args)
try:
addr, obj_id, prop_id = args[:3]
obj_id = ObjectIdentifier(obj_id).value
datatype = get_datatype(obj_id[0], prop_id)
if not datatype:
r... | def do_read(self, args) | read <addr> <objid> <prop> [ <indx> ] | 2.157121 | 2.104511 | 1.024999 |
args = args.split()
if _debug: ReadPropertyConsoleCmd._debug("do_rtn %r", args)
# provide the address and a list of network numbers
router_address = Address(args[0])
network_list = [int(arg) for arg in args[1:]]
# pass along to the service access point
... | def do_rtn(self, args) | rtn <addr> <net> ... | 7.278016 | 6.115298 | 1.190133 |
if _debug: Network._debug("add_node %r", node)
self.nodes.append(node)
node.lan = self
# update the node name
if not node.name:
node.name = '%s:%s' % (self.name, node.address) | def add_node(self, node) | Add a node to this network, let the node know which network it's on. | 3.835943 | 3.390454 | 1.131395 |
if _debug: Network._debug("remove_node %r", node)
self.nodes.remove(node)
node.lan = None | def remove_node(self, node) | Remove a node from this network. | 5.116685 | 4.268438 | 1.198725 |
if _debug: Network._debug("process_pdu(%s) %r", self.name, pdu)
# if there is a traffic log, call it with the network name and pdu
if self.traffic_log:
self.traffic_log(self.name, pdu)
# randomly drop a packet
if self.drop_percent != 0.0:
if (ra... | def process_pdu(self, pdu) | Process a PDU by sending a copy to each node as dictated by the
addressing and if a node is promiscuous. | 2.590232 | 2.47271 | 1.047527 |
if _debug: Node._debug("bind %r", lan)
lan.add_node(self) | def bind(self, lan) | bind to a LAN. | 6.719514 | 5.563639 | 1.207755 |
if _debug: Node._debug("indication(%s) %r", self.name, pdu)
# make sure we're connected
if not self.lan:
raise ConfigurationError("unbound node")
# if the pduSource is unset, fill in our address, otherwise
# leave it alone to allow for simulated spoofing
... | def indication(self, pdu) | Send a message. | 7.698024 | 7.36905 | 1.044643 |
if _debug: Match._debug("Match %r %r", addr1, addr2)
if (addr2.addrType == Address.localBroadcastAddr):
# match any local station
return (addr1.addrType == Address.localStationAddr) or (addr1.addrType == Address.localBroadcastAddr)
elif (addr2.addrType == Address.localStationAddr):
... | def Match(addr1, addr2) | Return true iff addr1 matches addr2. | 1.842636 | 1.842261 | 1.000203 |
if _debug: Sequence._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)
global _sequence_of_classes, _list_of_classes
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# loop through the elements
for ... | def dict_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 3.241054 | 3.197379 | 1.01366 |
if _debug: Choice._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# look for the chosen element
for element in self.choiceElements:
value = ge... | def dict_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 3.857975 | 3.78574 | 1.019081 |
if _debug: Any._debug("cast_in %r", element)
t = TagList()
if isinstance(element, Atomic):
tag = Tag()
element.encode(tag)
t.append(tag)
elif isinstance(element, AnyAtomic):
tag = Tag()
element.value.encode(tag)
... | def cast_in(self, element) | encode the element into the internal tag list. | 3.864747 | 3.276981 | 1.179362 |
if _debug: Any._debug("cast_out %r", klass)
global _sequence_of_classes, _list_of_classes
# check for a sequence element
if (klass in _sequence_of_classes) or (klass in _list_of_classes):
# build a sequence helper
helper = klass()
# make a c... | def cast_out(self, klass) | Interpret the content as a particular class. | 2.691764 | 2.717696 | 0.990458 |
if _debug: Any._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)
# result will be a list
rslt_list = []
# loop through the tags
for tag in self.tagList:
# build a tag thing
use_dict = as_class()
# save the pieces
... | def dict_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 4.294547 | 4.24547 | 1.01156 |
if _debug: SequenceOfAny._debug("cast_in %r", element)
# make sure it is a list
if not isinstance(element, List):
raise EncodingError("%r is not a list" % (element,))
t = TagList()
element.encode(t)
self.tagList.extend(t.tagList) | def cast_in(self, element) | encode the element into the internal tag list. | 4.945879 | 3.973588 | 1.244689 |
if _debug: SequenceOfAny._debug("cast_out %r", klass)
# make sure it is a list
if not issubclass(klass, List):
raise DecodingError("%r is not a list" % (klass,))
# build a helper
helper = klass()
# make a copy of the tag list
t = TagList(se... | def cast_out(self, klass) | Interpret the content as a particular class. | 4.509448 | 4.578175 | 0.984988 |
if _debug: WhoIsIAmServices._debug("do_WhoIsRequest %r", apdu)
# ignore this if there's no local device
if not self.localDevice:
if _debug: WhoIsIAmServices._debug(" - no local device")
return
# extract the parameters
low_limit = apdu.deviceI... | def do_WhoIsRequest(self, apdu) | Respond to a Who-Is request. | 2.408095 | 2.3669 | 1.017405 |
if _debug: WhoIsIAmServices._debug("do_IAmRequest %r", apdu)
# check for required parameters
if apdu.iAmDeviceIdentifier is None:
raise MissingRequiredParameter("iAmDeviceIdentifier required")
if apdu.maxAPDULengthAccepted is None:
raise MissingRequiredP... | def do_IAmRequest(self, apdu) | Respond to an I-Am request. | 2.05258 | 2.002153 | 1.025186 |
if _debug: WhoHasIHaveServices._debug("do_WhoHasRequest, %r", apdu)
# ignore this if there's no local device
if not self.localDevice:
if _debug: WhoIsIAmServices._debug(" - no local device")
return
# if this has limits, check them like Who-Is
... | def do_WhoHasRequest(self, apdu) | Respond to a Who-Has request. | 3.009669 | 2.93339 | 1.026004 |
if _debug: WhoHasIHaveServices._debug("do_IHaveRequest %r", apdu)
# check for required parameters
if apdu.deviceIdentifier is None:
raise MissingRequiredParameter("deviceIdentifier required")
if apdu.objectIdentifier is None:
raise MissingRequiredParamet... | def do_IHaveRequest(self, apdu) | Respond to a I-Have request. | 3.59642 | 3.320826 | 1.08299 |
if _debug: SSM._debug("set_state %r (%s) timer=%r", newState, SSM.transactionLabels[newState], timer)
# make sure we have a correct transition
if (self.state == COMPLETED) or (self.state == ABORTED):
e = RuntimeError("invalid state transition from %s to %s" % (SSM.transacti... | def set_state(self, newState, timer=0) | This function is called when the derived class wants to change state. | 3.440347 | 3.45364 | 0.996151 |
if _debug: SSM._debug("set_segmentation_context %s", repr(apdu))
# set the context
self.segmentAPDU = apdu | def set_segmentation_context(self, apdu) | This function is called to set the segmentation context. | 6.314577 | 5.758365 | 1.096592 |
if _debug: SSM._debug("get_segment %r", indx)
# check for no context
if not self.segmentAPDU:
raise RuntimeError("no segmentation context established")
# check for invalid segment number
if indx >= self.segmentCount:
raise RuntimeError("invalid ... | def get_segment(self, indx) | This function returns an APDU coorisponding to a particular
segment of a confirmed request or complex ack. The segmentAPDU
is the context. | 3.062155 | 2.888825 | 1.06 |
if _debug: SSM._debug("append_segment %r", apdu)
# check for no context
if not self.segmentAPDU:
raise RuntimeError("no segmentation context established")
# append the data
self.segmentAPDU.put_data(apdu.pduData) | def append_segment(self, apdu) | This function appends the apdu content to the end of the current
APDU being built. The segmentAPDU is the context. | 5.789835 | 4.407228 | 1.313713 |
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)
# send the message
self.ssmSAP.request(apdu)
... | def fill_window(self, seqNum) | This function sends all of the packets necessary to fill
out the segmentation window. | 6.223747 | 5.778031 | 1.07714 |
if _debug: ClientSSM._debug("request %r", apdu)
# make sure it has a good source and destination
apdu.pduSource = None
apdu.pduDestination = self.pdu_address
# send it via the device
self.ssmSAP.request(apdu) | def request(self, apdu) | This function is called by client transaction functions when it wants
to send a message to the device. | 5.998596 | 5.886343 | 1.01907 |
if _debug: ClientSSM._debug("indication %r", apdu)
# make sure we're getting confirmed requests
if (apdu.apduType != ConfirmedRequestPDU.pduType):
raise RuntimeError("invalid APDU (1)")
# save the request and set the segmentation context
self.set_segmentati... | def indication(self, apdu) | This function is called after the device has bound a new transaction
and wants to start the process rolling. | 2.879993 | 2.87332 | 1.002322 |
if _debug: ClientSSM._debug("response %r", apdu)
# make sure it has a good source and destination
apdu.pduSource = self.pdu_address
apdu.pduDestination = None
# send it to the application
self.ssmSAP.sap_response(apdu) | def response(self, apdu) | This function is called by client transaction functions when they want
to send a message to the application. | 5.942677 | 5.611321 | 1.059051 |
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.segment... | def confirmation(self, apdu) | This function is called by the device for all upstream messages related
to the transaction. | 2.977572 | 2.980419 | 0.999045 |
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.segmente... | def process_task(self) | This function is called when something has taken too long. | 3.245448 | 3.094634 | 1.048734 |
if _debug: ClientSSM._debug("abort %r", reason)
# change the state to aborted
self.set_state(ABORTED)
# build an abort PDU to return
abort_pdu = AbortPDU(False, self.invokeID, reason)
# return it
return abort_pdu | def abort(self, reason) | This function is called when the transaction should be aborted. | 6.287745 | 5.772584 | 1.089243 |
if _debug: ClientSSM._debug("segmented_request %r", apdu)
# server is ready for the next segment
if apdu.apduType == SegmentAckPDU.pduType:
if _debug: ClientSSM._debug(" - segment ack")
# actual window size is provided by server
self.actualWindow... | def segmented_request(self, apdu) | This function is called when the client is sending a segmented request
and receives an apdu. | 2.948271 | 2.941703 | 1.002233 |
if _debug: ServerSSM._debug("set_state %r (%s) timer=%r", newState, SSM.transactionLabels[newState], timer)
# do the regular state change
SSM.set_state(self, newState, timer)
# when completed or aborted, remove tracking
if (newState == COMPLETED) or (newState == ABORTE... | def set_state(self, newState, timer=0) | This function is called when the client wants to change state. | 4.71595 | 4.676692 | 1.008394 |
if _debug: ServerSSM._debug("request %r", apdu)
# make sure it has a good source and destination
apdu.pduSource = self.pdu_address
apdu.pduDestination = None
# send it via the device
self.ssmSAP.sap_request(apdu) | def request(self, apdu) | This function is called by transaction functions to send
to the application. | 6.608263 | 6.745269 | 0.979689 |
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 ... | def indication(self, apdu) | This function is called for each downstream packet related to
the transaction. | 2.406647 | 2.44877 | 0.982798 |
if _debug: ServerSSM._debug("confirmation %r", apdu)
# check to see we are in the correct state
if self.state != AWAIT_RESPONSE:
if _debug: ServerSSM._debug(" - warning: not expecting a response")
# abort response
if (apdu.apduType == AbortPDU.pduType):
... | def confirmation(self, apdu) | This function is called when the application has provided a response
and needs it to be sent to the client. | 2.68991 | 2.679169 | 1.004009 |
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_t... | def process_task(self) | 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. | 2.937217 | 2.671393 | 1.099508 |
if _debug: ServerSSM._debug("abort %r", reason)
# change the state to aborted
self.set_state(ABORTED)
# return an abort APDU
return AbortPDU(True, self.invokeID, reason) | def abort(self, reason) | This function is called when the application would like to abort the
transaction. There is no notification back to the application. | 7.68642 | 7.289598 | 1.054437 |
if _debug: ServerSSM._debug("await_response_timeout")
abort = self.abort(AbortReason.serverTimeout)
self.request(abort) | def await_response_timeout(self) | 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. | 14.724078 | 12.695827 | 1.159757 |
if _debug: StateMachineAccessPoint._debug("get_next_invoke_id")
initialID = self.nextInvokeID
while 1:
invokeID = self.nextInvokeID
self.nextInvokeID = (self.nextInvokeID + 1) % 256
# see if we've checked for them all
if initialID == sel... | def get_next_invoke_id(self, addr) | Called by clients to get an unused invoke ID. | 4.157831 | 3.891412 | 1.068463 |
if _debug: StateMachineAccessPoint._debug("confirmation %r", pdu)
# check device communication control
if self.dccEnableDisable == 'enable':
if _debug: StateMachineAccessPoint._debug(" - communications enabled")
elif self.dccEnableDisable == 'disable':
... | def confirmation(self, pdu) | Packets coming up the stack are APDU's. | 2.331836 | 2.318016 | 1.005962 |
if _debug: StateMachineAccessPoint._debug("sap_indication %r", apdu)
# check device communication control
if self.dccEnableDisable == 'enable':
if _debug: StateMachineAccessPoint._debug(" - communications enabled")
elif self.dccEnableDisable == 'disable':
... | def sap_indication(self, apdu) | This function is called when the application is requesting
a new transaction as a client. | 3.250745 | 3.279295 | 0.991294 |
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, A... | def sap_confirmation(self, apdu) | 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. | 3.551795 | 3.245769 | 1.094285 |
if _debug: BTR._debug("add_peer %r networks=%r", peerAddr, networks)
# see if this is already a peer
if peerAddr in self.peers:
# add the (new?) reachable networks
if not networks:
networks = []
else:
self.peers[peerAd... | def add_peer(self, peerAddr, networks=None) | Add a peer and optionally provide a list of the reachable networks. | 4.067688 | 3.739604 | 1.087732 |
if _debug: BTR._debug("delete_peer %r", peerAddr)
# get the peer networks
# networks = self.peers[peerAddr]
### send a control message upstream that these are no longer reachable
# now delete the peer
del self.peers[peerAddr] | def delete_peer(self, peerAddr) | Delete a peer. | 11.038911 | 11.013946 | 1.002267 |
# a little error checking
if ttl <= 0:
raise ValueError("time-to-live must be greater than zero")
# save the BBMD address and time-to-live
if isinstance(addr, Address):
self.bbmdAddress = addr
else:
self.bbmdAddress = Address(addr)
... | def register(self, addr, ttl) | Initiate the process of registering with a BBMD. | 5.845738 | 5.158562 | 1.133211 |
pdu = RegisterForeignDevice(0)
pdu.pduDestination = self.bbmdAddress
# send it downstream
self.request(pdu)
# change the status to unregistered
self.registrationStatus = -2
# clear the BBMD address and time-to-live
self.bbmdAddress = None
... | def unregister(self) | Drop the registration with a BBMD. | 7.442174 | 6.228415 | 1.194874 |
pdu = RegisterForeignDevice(self.bbmdTimeToLive)
pdu.pduDestination = self.bbmdAddress
# send it downstream
self.request(pdu) | def process_task(self) | Called when the registration request should be sent to the BBMD. | 21.879667 | 13.651119 | 1.602775 |
if _debug: BIPBBMD._debug("register_foreign_device %r %r", addr, ttl)
# see if it is an address or make it one
if isinstance(addr, Address):
pass
elif isinstance(addr, str):
addr = Address(addr)
else:
raise TypeError("addr must be a s... | def register_foreign_device(self, addr, ttl) | Add a foreign device to the FDT. | 3.982941 | 3.817454 | 1.04335 |
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# save the content
use_dict.__setitem__('dnet', self.rtDNET)
use_dict.__setitem__('port_id', self.rtPortID)
use_dict.__setitem__('port_info', self.rtPortInfo)
... | def dict_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 5.347941 | 5.40172 | 0.990044 |
if not isinstance(arg, (int, long)) or isinstance(arg, bool):
return False
if (arg < cls._low_limit):
return False
if (cls._high_limit is not None) and (arg > cls._high_limit):
return False
return True | def is_valid(cls, arg) | Return True if arg is valid value for the class. | 2.674475 | 2.559766 | 1.044812 |
return isinstance(arg, (int, long)) and (not isinstance(arg, bool)) | def is_valid(cls, arg) | Return True if arg is valid value for the class. | 5.533093 | 5.270431 | 1.049837 |
return (isinstance(arg, (int, long)) and (arg >= 0)) or \
isinstance(arg, str) | def is_valid(cls, arg) | Return True if arg is valid value for the class. If the string
value is wrong for the enumeration, the encoding will fail. | 4.302624 | 4.475806 | 0.961307 |
objType, objInstance = self.value
if isinstance(objType, int):
pass
elif isinstance(objType, long):
objType = int(objType)
elif isinstance(objType, basestring):
# turn it back into an integer
objType = self.objectTypeClass()[objTy... | def get_tuple(self) | Return the unsigned integer tuple of the identifier. | 5.48009 | 4.864864 | 1.126463 |
if _debug: FileServices._debug("do_AtomicReadFileRequest %r", apdu)
if (apdu.fileIdentifier[0] != 'file'):
raise ExecutionError('services', 'inconsistentObjectType')
# get the object
obj = self.get_object_id(apdu.fileIdentifier)
if _debug: FileServices._deb... | def do_AtomicReadFileRequest(self, apdu) | Return one of our records. | 2.25578 | 2.240681 | 1.006738 |
if _debug: FileServices._debug("do_AtomicWriteFileRequest %r", apdu)
if (apdu.fileIdentifier[0] != 'file'):
raise ExecutionError('services', 'inconsistentObjectType')
# get the object
obj = self.get_object_id(apdu.fileIdentifier)
if _debug: FileServices._de... | def do_AtomicWriteFileRequest(self, apdu) | Return one of our records. | 2.211157 | 2.198491 | 1.005761 |
# unspecified
if not arg:
return 0
if arg > 64:
return 7
# the largest number not greater than the arg
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,)) | def encode_max_segments_accepted(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! | 6.072464 | 6.340312 | 0.957755 |
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,)) | def encode_max_apdu_length_accepted(arg) | Return the encoding of the highest encodable value less than the
value of the arg. | 4.319243 | 4.065002 | 1.062544 |
if _debug: APCI._debug("encode %r", pdu)
PCI.update(pdu, self)
if (self.apduType == ConfirmedRequestPDU.pduType):
# PDU type
buff = self.apduType << 4
if self.apduSeg:
buff += 0x08
if self.apduMor:
buff +=... | def encode(self, pdu) | encode the contents of the APCI into the PDU. | 1.736058 | 1.699066 | 1.021772 |
if _debug: APCI._debug("decode %r", pdu)
PCI.update(self, pdu)
# decode the first octet
buff = pdu.get()
# decode the APCI type
self.apduType = (buff >> 4) & 0x0F
if (self.apduType == ConfirmedRequestPDU.pduType):
self.apduSeg = ((buff & 0... | def decode(self, pdu) | decode the contents of the PDU into the APCI. | 1.875261 | 1.817302 | 1.031892 |
if _debug: APCI._debug("apci_contents use_dict=%r as_class=%r", use_dict, as_class)
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# copy the source and destination to make it easier to search
if self.pduSource:
... | def apci_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 2.52061 | 2.489692 | 1.012418 |
if _debug: APDU._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# call the parent classes
self.apci_contents(use_dict=use_dict, as_class=as_class)
... | def dict_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 3.234995 | 3.175454 | 1.01875 |
if _debug: APCISequence._debug("apdu_contents use_dict=%r as_class=%r", use_dict, as_class)
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
# set the function based on the class name
use_dict.__setitem__('function', self._... | def apdu_contents(self, use_dict=None, as_class=dict) | Return the contents of an object as a dict. | 4.312726 | 3.918467 | 1.100616 |
if not isinstance(tdata, str):
raise TypeError("tag data must be str")
self.tagClass = tclass
self.tagNumber = tnum
self.tagLVT = tlvt
self.tagData = tdata | def set(self, tclass, tnum, tlvt=0, tdata='') | set the values of the tag. | 2.963552 | 2.663656 | 1.112588 |
if not isinstance(tdata, str):
raise TypeError("tag data must be str")
self.tagClass = Tag.applicationTagClass
self.tagNumber = tnum
self.tagLVT = len(tdata)
self.tagData = tdata | def set_app_data(self, tnum, tdata) | set the values of the tag. | 5.536669 | 4.708939 | 1.175779 |
try:
tag = pdu.get()
# extract the type
self.tagClass = (tag >> 3) & 0x01
# extract the tag number
self.tagNumber = (tag >> 4)
if (self.tagNumber == 0x0F):
self.tagNumber = pdu.get()
# extract the len... | def decode(self, pdu) | Decode a tag from the PDU. | 2.953071 | 2.812047 | 1.05015 |
if self.tagClass != Tag.applicationTagClass:
raise ValueError("application tag required")
# application tagged boolean now has data
if (self.tagNumber == Tag.booleanAppTag):
return ContextTag(context, chr(self.tagLVT))
else:
return ContextTag... | def app_to_context(self, context) | Return a context encoded tag. | 11.593847 | 9.113035 | 1.272227 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.