clean up unused Python imports (#454)
* Remove unused python imports These changes have been auto-generated with: pip3 install isort autoflake isort -rc -sl . autoflake --remove-all-unused-imports -i -r . isort -rc -m 3 . Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org> * python: remove redundant parenthesis Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
committed by
GitHub
parent
50f397b249
commit
d84179e42f
@@ -1,14 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
import os
|
||||
import sys
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
||||
from scapy.all import IP, TCP, UDP, Raw
|
||||
from scapy.all import (
|
||||
TCP,
|
||||
FieldLenField,
|
||||
FieldListField,
|
||||
IntField,
|
||||
IPOption,
|
||||
ShortField,
|
||||
get_if_list,
|
||||
sniff
|
||||
)
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
iface=None
|
||||
@@ -44,7 +50,7 @@ def handle_pkt(pkt):
|
||||
def main():
|
||||
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
||||
iface = ifaces[0]
|
||||
print(("sniffing on %s" % iface))
|
||||
print("sniffing on %s" % iface)
|
||||
sys.stdout.flush()
|
||||
sniff(iface = iface,
|
||||
prn = lambda x: handle_pkt(x))
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||
|
||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet
|
||||
from scapy.all import Ether, IP, UDP, TCP
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
@@ -30,7 +27,7 @@ def main():
|
||||
addr = socket.gethostbyname(sys.argv[1])
|
||||
iface = get_if()
|
||||
|
||||
print(("sending on interface %s to %s" % (iface, str(addr))))
|
||||
print("sending on interface %s to %s" % (iface, str(addr)))
|
||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||
pkt = pkt /IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / sys.argv[2]
|
||||
pkt.show2()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
from scapy.all import *
|
||||
import sys, os
|
||||
|
||||
TYPE_MYTUNNEL = 0x1212
|
||||
TYPE_IPV4 = 0x0800
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
import os
|
||||
import sys
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
||||
from scapy.all import IP, TCP, UDP, Raw
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
from myTunnel_header import MyTunnel
|
||||
from scapy.all import TCP, get_if_list, sniff
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
@@ -34,7 +30,7 @@ def handle_pkt(pkt):
|
||||
def main():
|
||||
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
||||
iface = ifaces[0]
|
||||
print(("sniffing on %s" % iface))
|
||||
print("sniffing on %s" % iface)
|
||||
sys.stdout.flush()
|
||||
sniff(iface = iface,
|
||||
prn = lambda x: handle_pkt(x))
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import argparse
|
||||
import socket
|
||||
|
||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr, hexdump
|
||||
from scapy.all import Packet
|
||||
from scapy.all import Ether, IP, UDP, TCP
|
||||
from myTunnel_header import MyTunnel
|
||||
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
@@ -35,11 +31,11 @@ def main():
|
||||
iface = get_if()
|
||||
|
||||
if (dst_id is not None):
|
||||
print(("sending on interface {} to dst_id {}".format(iface, str(dst_id))))
|
||||
print("sending on interface {} to dst_id {}".format(iface, str(dst_id)))
|
||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||
pkt = pkt / MyTunnel(dst_id=dst_id) / IP(dst=addr) / args.message
|
||||
else:
|
||||
print(("sending on interface {} to IP addr {}".format(iface, str(addr))))
|
||||
print("sending on interface {} to IP addr {}".format(iface, str(addr)))
|
||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||
pkt = pkt / IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / args.message
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import re
|
||||
|
||||
from scapy.all import sendp, send, srp1
|
||||
from scapy.all import Packet, hexdump
|
||||
from scapy.all import Ether, StrFixedLenField, XByteField, IntField
|
||||
from scapy.all import bind_layers
|
||||
import readline
|
||||
from scapy.all import (
|
||||
Ether,
|
||||
IntField,
|
||||
Packet,
|
||||
StrFixedLenField,
|
||||
XByteField,
|
||||
bind_layers,
|
||||
srp1
|
||||
)
|
||||
|
||||
|
||||
class P4calc(Packet):
|
||||
name = "P4calc"
|
||||
@@ -84,7 +84,7 @@ def main():
|
||||
if resp:
|
||||
p4calc=resp[P4calc]
|
||||
if p4calc:
|
||||
print((p4calc.result))
|
||||
print(p4calc.result)
|
||||
else:
|
||||
print("cannot find P4calc header in the packet")
|
||||
else:
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet
|
||||
from scapy.all import IP, UDP, Raw
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
from scapy.all import get_if_list, sniff
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
@@ -28,7 +25,7 @@ def handle_pkt(pkt):
|
||||
|
||||
def main():
|
||||
iface = 'eth0'
|
||||
print(("sniffing on %s" % iface))
|
||||
print("sniffing on %s" % iface)
|
||||
sys.stdout.flush()
|
||||
sniff(filter="udp and port 4321", iface = iface,
|
||||
prn = lambda x: handle_pkt(x))
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
|
||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import Ether, IP, UDP
|
||||
from scapy.all import IntField, FieldListField, FieldLenField, ShortField
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from scapy.all import IP, UDP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
iface=None # "h1-eth0"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from probe_hdrs import *
|
||||
|
||||
|
||||
def expand(x):
|
||||
yield x
|
||||
while x.payload:
|
||||
@@ -14,11 +15,11 @@ def handle_pkt(pkt):
|
||||
print("")
|
||||
for sw in data_layers:
|
||||
utilization = 0 if sw.cur_time == sw.last_time else 8.0*sw.byte_cnt/(sw.cur_time - sw.last_time)
|
||||
print(("Switch {} - Port {}: {} Mbps".format(sw.swid, sw.port, utilization)))
|
||||
print("Switch {} - Port {}: {} Mbps".format(sw.swid, sw.port, utilization))
|
||||
|
||||
def main():
|
||||
iface = 'eth0'
|
||||
print(("sniffing on {}".format(iface)))
|
||||
print("sniffing on {}".format(iface))
|
||||
sniff(iface = iface,
|
||||
prn = lambda x: handle_pkt(x))
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import time
|
||||
|
||||
from probe_hdrs import *
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
probe_pkt = Ether(dst='ff:ff:ff:ff:ff:ff', src=get_if_hwaddr('eth0')) / \
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
import os
|
||||
import sys
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
||||
from scapy.all import IP, UDP, Raw
|
||||
from scapy.all import (
|
||||
FieldLenField,
|
||||
FieldListField,
|
||||
IntField,
|
||||
IPOption,
|
||||
ShortField,
|
||||
get_if_list,
|
||||
sniff
|
||||
)
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
iface=None
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||
|
||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet
|
||||
from scapy.all import Ether, IP, UDP, TCP
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import PacketListField, ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
||||
from scapy.all import IP, UDP, Raw
|
||||
from scapy.all import (
|
||||
FieldLenField,
|
||||
IntField,
|
||||
IPOption,
|
||||
Packet,
|
||||
PacketListField,
|
||||
ShortField,
|
||||
get_if_list,
|
||||
sniff
|
||||
)
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
iface=None
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import Ether, IP, UDP
|
||||
from scapy.all import IntField, FieldListField, FieldLenField, ShortField, PacketListField
|
||||
from scapy.all import (
|
||||
IP,
|
||||
UDP,
|
||||
Ether,
|
||||
FieldLenField,
|
||||
IntField,
|
||||
IPOption,
|
||||
Packet,
|
||||
PacketListField,
|
||||
ShortField,
|
||||
get_if_hwaddr,
|
||||
get_if_list,
|
||||
sendp
|
||||
)
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
from time import sleep
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import grpc
|
||||
import os
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
import grpc
|
||||
|
||||
# Import P4Runtime lib from parent utils dir
|
||||
# Probably there's a better way of doing this.
|
||||
sys.path.append(
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
'../../utils/'))
|
||||
import p4runtime_lib.bmv2
|
||||
import p4runtime_lib.helper
|
||||
from p4runtime_lib.error_utils import printGrpcError
|
||||
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
||||
import p4runtime_lib.helper
|
||||
|
||||
SWITCH_TO_HOST_PORT = 1
|
||||
SWITCH_TO_SWITCH_PORT = 2
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import grpc
|
||||
import os
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
import grpc
|
||||
|
||||
# Import P4Runtime lib from parent utils dir
|
||||
# Probably there's a better way of doing this.
|
||||
sys.path.append(
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
'../../utils/'))
|
||||
import p4runtime_lib.bmv2
|
||||
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
||||
import p4runtime_lib.helper
|
||||
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
||||
|
||||
SWITCH_TO_HOST_PORT = 1
|
||||
SWITCH_TO_SWITCH_PORT = 2
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from scapy.all import sniff, get_if_list
|
||||
|
||||
from scapy.all import sniff
|
||||
|
||||
|
||||
def handle_pkt(pkt):
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
import argparse
|
||||
import socket
|
||||
|
||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
||||
from scapy.all import Ether, IP, UDP, TCP
|
||||
|
||||
from time import sleep
|
||||
|
||||
from scapy.all import IP, TCP, UDP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||
|
||||
|
||||
def get_if():
|
||||
iface = None
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
|
||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr, bind_layers
|
||||
from scapy.all import Packet, IPOption
|
||||
from scapy.all import IP, UDP, Raw, Ether
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
from scapy.all import Ether, IPOption, Packet, bind_layers, get_if_list, sniff
|
||||
from scapy.fields import *
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import sys
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr, bind_layers
|
||||
from scapy.all import Packet
|
||||
from scapy.all import Ether, IP, UDP
|
||||
from scapy.all import (
|
||||
IP,
|
||||
UDP,
|
||||
Ether,
|
||||
Packet,
|
||||
bind_layers,
|
||||
get_if_hwaddr,
|
||||
get_if_list,
|
||||
sendp
|
||||
)
|
||||
from scapy.fields import *
|
||||
import readline
|
||||
|
||||
|
||||
def get_if():
|
||||
ifs=get_if_list()
|
||||
|
||||
Reference in New Issue
Block a user