Changed main to define the structure of hosts and update
This commit is contained in:
20
status.py
20
status.py
@@ -17,11 +17,7 @@ def parseArguments():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Parsear los argumentos de la línea de comandos
|
# Parsear los argumentos de la línea de comandos
|
||||||
args = parser.parse_args()
|
return parser.parse_args()
|
||||||
if args.host:
|
|
||||||
return args.host
|
|
||||||
elif args.web:
|
|
||||||
return args.web
|
|
||||||
except argparse.ArgumentError as e:
|
except argparse.ArgumentError as e:
|
||||||
# Si ocurre un error al analizar los argumentos, mostrar un mensaje de error
|
# Si ocurre un error al analizar los argumentos, mostrar un mensaje de error
|
||||||
print("Error:", e)
|
print("Error:", e)
|
||||||
@@ -36,7 +32,7 @@ def toIP(hosts):
|
|||||||
ip = ipaddress.IPv4Address(host)
|
ip = ipaddress.IPv4Address(host)
|
||||||
ips.add(ip)
|
ips.add(ip)
|
||||||
except ipaddress.AddressValueError:
|
except ipaddress.AddressValueError:
|
||||||
print(f"La entrada '{ip}' no es una dirección IP válida.")
|
print(f"La entrada '{host}' no es una dirección IP válida.")
|
||||||
return ips
|
return ips
|
||||||
|
|
||||||
def check_ping(hosts):
|
def check_ping(hosts):
|
||||||
@@ -55,6 +51,12 @@ def check_ping(hosts):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = parseArguments()
|
args = parseArguments()
|
||||||
hosts = read_document(args)
|
ips_and_hosts = set()
|
||||||
ips = toIP(hosts)
|
if args.host:
|
||||||
check_ping(ips)
|
ips_and_hosts.update(toIP(read_document(args.host)))
|
||||||
|
print(ips_and_hosts)
|
||||||
|
if args.web:
|
||||||
|
print("Hay webs")
|
||||||
|
# Parsear correctamente
|
||||||
|
# ips_and_hosts.update()
|
||||||
|
check_ping(ips_and_hosts)
|
||||||
Reference in New Issue
Block a user