-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVesta.py
32 lines (30 loc) · 1.04 KB
/
Vesta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
import socket
import os
import datetime
from src import PingServer
from src import CheckLogs
try:
# Create the log folder if it doesn't exist yet.
if not os.path.exists("vesta-logs"):
os.makedirs("vesta-logs")
# Check current time and if between 01:00 or 07:00 terminate.
now = datetime.datetime.now()
if now.hour >= 0 and now.hour < 8:
sys.exit(0)
# Check if there was a log made in the last 30 minutes.
# If there was a file made, halt execution.
if CheckLogs.checkLogs():
sys.exit(0)
# Convert the port number and if incorrect let the user know.
portNum = int(sys.argv[2])
if portNum > 65535:
raise ValueError("To big port value")
if len(sys.argv) > 3:
PingServer.pingServer(sys.argv[1], portNum, sys.argv[3])
else:
PingServer.pingServer(sys.argv[1], portNum)
except ValueError as e:
print("Please enter a number between 0 and 65535 for the port.")
except socket.gaierror as e:
print("Please enter a correctly formatted hostname or ip address.")