Change Create Windows Task to main.py
This commit is contained in:
@@ -3,6 +3,7 @@ from Controller import adcontroller_export, exchange_export, rds_export, smtp_ex
|
||||
import Controller.mysql_connect as mysql_connect
|
||||
import random
|
||||
import subprocess
|
||||
import socket
|
||||
|
||||
def get_local_ip():
|
||||
try:
|
||||
@@ -78,14 +79,22 @@ def create_windows_task(task_name, command, schedule):
|
||||
print(f"Failed to create Windows task. Error: {e}")
|
||||
|
||||
query = "SELECT * FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format(get_local_ip())
|
||||
|
||||
# query = "SELECT * FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format("172.18.1.6")
|
||||
|
||||
list = mysql_connect.get_ip(query)
|
||||
|
||||
if list == []:
|
||||
query_insert = f"INSERT INTO `Kunden-Server` (Name,`Server-Name`,`IP-Adresse`,Funktion,CPU,RAM,Speicher) VALUES ('unkown','{socket.gethostname()}','{get_local_ip()}','-','{system_info.get_cpu_info()}','{system_info.get_ram_info()}','{system_info.get_hdd_info()}')"
|
||||
mysql_connect.add_user(query_insert,"Stines-GmbH","")
|
||||
|
||||
set_ipaddress = []
|
||||
|
||||
# Ergebnisse durchlaufen und ausgeben
|
||||
for row in list:
|
||||
name = row[2]
|
||||
ipadress = row[4]
|
||||
set_ipaddress = row[4]
|
||||
lastchange = row[6]
|
||||
funktion = row[7]
|
||||
token = row[8]
|
||||
@@ -99,6 +108,8 @@ for row in list:
|
||||
for (db_name,) in cursor:
|
||||
if name in str(db_name):
|
||||
database_exists = True
|
||||
if "-" in str(db_name):
|
||||
database_exists = True
|
||||
|
||||
# Datenbank erstellen, wenn sie noch nicht existiert
|
||||
if not database_exists:
|
||||
@@ -111,7 +122,13 @@ for row in list:
|
||||
if token is not None:
|
||||
eval(funktion + '("' + ipadress + '","' + name + '","' + token + '")')
|
||||
else:
|
||||
eval(funktion + '("' + ipadress + '","' + name + '")')
|
||||
if funktion == "-":
|
||||
break
|
||||
else:
|
||||
eval(funktion + '("' + ipadress + '","' + name + '")')
|
||||
|
||||
print(set_ipaddress)
|
||||
system_info_get(f"{set_ipaddress}","Stines-GmbH")
|
||||
|
||||
task_name = "Reports"
|
||||
command_to_execute = "C:\\Scripte\\Start.exe"
|
||||
|
||||
Reference in New Issue
Block a user