Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pingparser():
return pingparsing.PingParsing()
def pingparser():
return pingparsing.PingParsing()
def pingparser():
return pingparsing.PingParsing()
def ping_parser():
return PingParsing()
def main():
ping_parser = pingparsing.PingParsing()
transmitter = pingparsing.PingTransmitter()
transmitter.destination = "google.com"
transmitter.count = 10
result = transmitter.ping()
print(json.dumps(ping_parser.parse(result).as_dict(), indent=4))
return result.returncode
def ping(host: str) -> pingparsing.PingStats:
ping_parser = pingparsing.PingParsing()
transmitter = pingparsing.PingTransmitter()
transmitter.destination = host
transmitter.count = 2
transmitter.timeout = 2000
return ping_parser.parse(transmitter.ping())
for _ in range(self.num_workers):
self._workers.append(threading.Thread(target=self.worker_func, args=(ping_args, self._pending, self._done)))
# Put all the addresses into the 'pending' queue.
with open(file_path, "r") as hostsFile:
for line in hostsFile:
self._pending.put(line.strip())
# Start all the workers.
for w in self._workers:
w.daemon = True
w.start()
# Parser to parse the ping response
ping_parser = pingparsing.PingParsing()
# Get the results as they arrive.
num_terminated = 0
while num_terminated < self.num_workers:
result = self._done.get()
if result is None:
# A worker is about to terminate.
num_terminated += 1
else:
# Print as soon as results arrive
if result[1].decode("utf-8") == '': # Error is empty string
if self.verbose:
print("IP", result[0]['ip'])
print(result[0]['result'].decode("utf-8"))
ping_parser.parse(result[0]['result'].decode("utf-8"))
if int(ping_parser.packet_loss) == 100: # All packets are lost
def main():
parser = pingparsing.PingParsing()
stats = parser.parse(
dedent(
"""\
PING google.com (74.125.24.100) 56(84) bytes of data.
[1524930937.003555] 64 bytes from 74.125.24.100: icmp_seq=1 ttl=39 time=148 ms
[1524930937.787175] 64 bytes from 74.125.24.100: icmp_seq=2 ttl=39 time=137 ms
[1524930938.787642] 64 bytes from 74.125.24.100: icmp_seq=3 ttl=39 time=137 ms
[1524930939.787653] 64 bytes from 74.125.24.100: icmp_seq=4 ttl=39 time=136 ms
[1524930940.788365] 64 bytes from 74.125.24.100: icmp_seq=5 ttl=39 time=136 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 136.537/139.174/148.006/4.425 ms
"""
)
)