-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the static code instead of entry points Bug-Url: #1076
- Loading branch information
Showing
4 changed files
with
221 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import struct | ||
import sys | ||
|
||
## | ||
# | ||
# Logging setup | ||
# | ||
# See the history: | ||
# * https://github.com/svinota/pyroute2/issues/246 | ||
# * https://github.com/svinota/pyroute2/issues/255 | ||
# * https://github.com/svinota/pyroute2/issues/270 | ||
# * https://github.com/svinota/pyroute2/issues/573 | ||
# * https://github.com/svinota/pyroute2/issues/601 | ||
# | ||
from pyroute2.config import log | ||
|
||
## | ||
# | ||
# Windows platform specific: socket module monkey patching | ||
# | ||
# To use the library on Windows, run:: | ||
# pip install win-inet-pton | ||
# | ||
if sys.platform.startswith('win'): # noqa: E402 | ||
import win_inet_pton # noqa: F401 | ||
|
||
|
||
def init(): | ||
try: | ||
# probe, if the bytearray can be used in struct.unpack_from() | ||
struct.unpack_from('I', bytearray((1, 0, 0, 0)), 0) | ||
except Exception: | ||
if sys.version_info[0] < 3: | ||
# monkeypatch for old Python versions | ||
log.warning('patching struct.unpack_from()') | ||
|
||
def wrapped(fmt, buf, offset=0): | ||
return struct._u_f_orig(fmt, str(buf), offset) | ||
|
||
struct._u_f_orig = struct.unpack_from | ||
struct.unpack_from = wrapped | ||
else: | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## | ||
# | ||
# This module contains all the public symbols from the library. | ||
# | ||
|
||
## | ||
# | ||
# Version | ||
# | ||
try: | ||
from pyroute2.config.version import __version__ | ||
except ImportError: | ||
__version__ = 'unknown' | ||
|
||
|
||
from pyroute2.conntrack import Conntrack, ConntrackEntry | ||
from pyroute2.iproute import ChaoticIPRoute, IPBatch, IPRoute, RawIPRoute | ||
from pyroute2.iproute.ipmock import IPRoute as IPMock | ||
from pyroute2.iwutil import IW | ||
from pyroute2.netlink.devlink import DevlinkSocket | ||
from pyroute2.netlink.diag import DiagSocket | ||
from pyroute2.netlink.event.acpi_event import AcpiEventSocket | ||
from pyroute2.netlink.event.dquot import DQuotSocket | ||
from pyroute2.netlink.exceptions import ( | ||
ChaoticException, | ||
NetlinkDecodeError, | ||
NetlinkDumpInterrupted, | ||
NetlinkError, | ||
) | ||
from pyroute2.netlink.generic import GenericNetlinkSocket | ||
from pyroute2.netlink.generic.l2tp import L2tp | ||
from pyroute2.netlink.generic.mptcp import MPTCP | ||
from pyroute2.netlink.generic.wireguard import WireGuard | ||
from pyroute2.netlink.ipq import IPQSocket | ||
from pyroute2.netlink.nfnetlink.nfctsocket import NFCTSocket | ||
from pyroute2.netlink.nfnetlink.nftsocket import NFTSocket | ||
from pyroute2.netlink.nl80211 import NL80211 | ||
from pyroute2.netlink.rtnl.iprsocket import IPRSocket | ||
from pyroute2.netlink.taskstats import TaskStats | ||
from pyroute2.netlink.uevent import UeventSocket | ||
|
||
modules = [ | ||
AcpiEventSocket, | ||
ChaoticException, | ||
ChaoticIPRoute, | ||
Conntrack, | ||
ConntrackEntry, | ||
DevlinkSocket, | ||
DiagSocket, | ||
DQuotSocket, | ||
IPBatch, | ||
IPMock, | ||
IPQSocket, | ||
IPRoute, | ||
IPRSocket, | ||
IW, | ||
GenericNetlinkSocket, | ||
L2tp, | ||
MPTCP, | ||
NetlinkError, | ||
NetlinkDecodeError, | ||
NetlinkDumpInterrupted, | ||
NFCTSocket, | ||
NFTSocket, | ||
NL80211, | ||
RawIPRoute, | ||
TaskStats, | ||
UeventSocket, | ||
WireGuard, | ||
] | ||
|
||
__all__ = [] | ||
__all__.extend(modules) |