mirror of
https://gitlab.sectorq.eu/jaydee/python.git
synced 2025-12-14 02:34:53 +01:00
asa
This commit is contained in:
56
mqtt_srv.py
56
mqtt_srv.py
@@ -27,43 +27,49 @@ if curos == "Windows":
|
||||
import winreg
|
||||
def uptime():
|
||||
|
||||
try:
|
||||
f = open( "/proc/uptime" )
|
||||
contents = f.read().split()
|
||||
f.close()
|
||||
except:
|
||||
try:
|
||||
f = open( "/proc/uptime" )
|
||||
contents = f.read().split()
|
||||
f.close()
|
||||
except:
|
||||
return "Cannot open uptime file: /proc/uptime"
|
||||
|
||||
total_seconds = float(contents[0])
|
||||
total_seconds = float(contents[0])
|
||||
|
||||
# Helper vars:
|
||||
MINUTE = 60
|
||||
HOUR = MINUTE * 60
|
||||
DAY = HOUR * 24
|
||||
# Helper vars:
|
||||
MINUTE = 60
|
||||
HOUR = MINUTE * 60
|
||||
DAY = HOUR * 24
|
||||
|
||||
# Get the days, hours, etc:
|
||||
days = int( total_seconds / DAY )
|
||||
hours = int( ( total_seconds % DAY ) / HOUR )
|
||||
minutes = int( ( total_seconds % HOUR ) / MINUTE )
|
||||
seconds = int( total_seconds % MINUTE )
|
||||
# Get the days, hours, etc:
|
||||
days = int( total_seconds / DAY )
|
||||
hours = int( ( total_seconds % DAY ) / HOUR )
|
||||
minutes = int( ( total_seconds % HOUR ) / MINUTE )
|
||||
seconds = int( total_seconds % MINUTE )
|
||||
|
||||
# Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
|
||||
string = ""
|
||||
string = ""
|
||||
# if days > 0:
|
||||
# string += str(days) + " " + (days == 1 and "d" or "d" ) + ", "
|
||||
# if len(string) > 0 or hours > 0:
|
||||
# string += str(hours) + " " + (hours == 1 and "h" or "h" ) + ", "
|
||||
# if len(string) > 0 or minutes > 0:
|
||||
# string += str(minutes) + " " + (minutes == 1 and "m" or "m" ) + ", "
|
||||
if days > 0:
|
||||
string += str(days) + " " + (days == 1 and "d" or "d" ) + ", "
|
||||
if len(string) > 0 or hours > 0:
|
||||
string += str(hours) + ":"
|
||||
if len(string) > 0 or minutes > 0:
|
||||
string += str(minutes) + ":"
|
||||
string += str(seconds)
|
||||
if days > 0:
|
||||
string += str(days) + " " + (days == 1 and "d" or "d" ) + ", "
|
||||
if len(string) > 0 or hours > 0:
|
||||
if hours < 10:
|
||||
hours = "0{}".format(hours)
|
||||
string += str(hours) + ":"
|
||||
if len(string) > 0 or minutes > 0:
|
||||
if minutes < 10:
|
||||
minutes = "0{}".format(minutes)
|
||||
string += str(minutes) + ":"
|
||||
|
||||
return string;
|
||||
if seconds < 10:
|
||||
seconds = "0{}".format(seconds)
|
||||
string += str(seconds)
|
||||
return string;
|
||||
|
||||
def writeLog(msg, svr="INFO"):
|
||||
ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
@@ -319,7 +325,7 @@ IP = get_ip()
|
||||
print("OS : " + curos)
|
||||
writeLog("OS : " + curos)
|
||||
if curos != "Windows":
|
||||
import autorandr
|
||||
import autorandr
|
||||
else:
|
||||
import winreg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user