Utils Module¶
-
py2p.utils.
sanitize_packet
(packet)[source]¶ Function to sanitize a packet for pathfinding_message serialization, or dict keying
-
py2p.utils.
intersect
(*args)[source]¶ Finds the intersection of several iterables
Parameters: *args – Several iterables Returns: A list containing the ordered intersection of all given iterables, where the order is defined by the first iterable
-
py2p.utils.
get_lan_ip
()[source]¶ Retrieves the LAN ip. Expanded from http://stackoverflow.com/a/28950776
Note: This will return ‘127.0.0.1’ if it is not connected to a network
-
py2p.utils.
getUTC
()[source]¶ Returns the current unix time in UTC
Note: This will always return an integral value
-
py2p.utils.
get_socket
(protocol, serverside=False)[source]¶ Given a protocol object, return the appropriate socket
Parameters: - protocol – A py2p.base.protocol object
- serverside – Whether you are the server end of a connection (default: False)
Raises: ValueError
– If your protocol object has an unknown encryption methodReturns: A socket-like object