mirror of
https://github.com/FAUSheppy/config
synced 2025-12-06 07:01:36 +01:00
Added IP
This commit is contained in:
@@ -86,6 +86,12 @@ def vpn():
|
||||
tmp = ' '+tmp
|
||||
return tmp;
|
||||
|
||||
def ip():
|
||||
with open(hl_utils.hlpath("ip.log")) as f:
|
||||
tmp = f.read()
|
||||
tmp = ' '+tmp
|
||||
return tmp;
|
||||
|
||||
def battery():
|
||||
if hl_utils.is_laptop():
|
||||
try:
|
||||
@@ -115,29 +121,6 @@ def battery():
|
||||
else:
|
||||
return ""
|
||||
|
||||
def irc():
|
||||
if hl_utils.is_cip():
|
||||
ret_string = "IRC ERROR"
|
||||
try:
|
||||
fname = hl_utils.hlpath("irc.log")
|
||||
tmp = []
|
||||
with open(fname) as f:
|
||||
for l in f:
|
||||
tmp+=[l]
|
||||
if len(tmp) == 0:
|
||||
return ""
|
||||
msg = " ".join(tmp[-1].split(" ")[2:])[:50]
|
||||
user = tmp[-1].split(" ")[1][:15]
|
||||
if not "%push" in msg:
|
||||
return ""
|
||||
pattern = re.compile("\^+[fb]g[(]+#[0-9]+[)]+")
|
||||
msg = re.sub(pattern,"",msg)
|
||||
user = re.sub(pattern,"",user)
|
||||
ret_string = "MSG FROM: "+user+"-> "+msg.rstrip('\n')+" - [ "+str(len(tmp))+" total ]"
|
||||
return color_panel(ret_string,RED)
|
||||
except(IOError):
|
||||
pass
|
||||
else:
|
||||
return ''
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(vpn(),guthaben(),battery(),sep='')
|
||||
print(ip(),vpn(),guthaben(),battery(),sep='')
|
||||
|
||||
@@ -4,12 +4,15 @@ import sys
|
||||
import time
|
||||
import sys
|
||||
import subprocess
|
||||
from hl_panel_content import color_panel
|
||||
from hl_panel_content import color_panel, get_color
|
||||
from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop
|
||||
import re
|
||||
|
||||
RED = 0xff0000
|
||||
GREEN = 0x32CD32
|
||||
YELLOW = 0xffff00
|
||||
BAT_COLOR_OFFSET = 10
|
||||
|
||||
|
||||
#Druckerguthaben
|
||||
def pr_acct_status():
|
||||
@@ -43,7 +46,7 @@ def vpn_status():
|
||||
|
||||
def battery():
|
||||
try:
|
||||
bat = hl_utils.shexec("acpi -b")
|
||||
bat = shexec("acpi -b")
|
||||
if bat == '':
|
||||
return color_panel("BATTERY FAILURE",RED)
|
||||
bat = re.compile(r'Battery [0-9]+: ').sub('',bat)
|
||||
@@ -69,21 +72,28 @@ def battery():
|
||||
|
||||
def battery_status():
|
||||
if is_laptop:
|
||||
with open(hlpatch("battery.log")) as g:
|
||||
with open(hlpath("battery.log"),'w') as g:
|
||||
g.write(battery())
|
||||
|
||||
def ip_status():
|
||||
with open(hlpath("ip.log"),'w') as g:
|
||||
p="Public IP: "
|
||||
try:
|
||||
tmp=color_panel(p+shexec("wget --timeout=3 -O- --quiet https://atlantishq.de/ipcheck"),GREEN)
|
||||
except:
|
||||
tmp=color_panel("Offline",RED)
|
||||
g.write(tmp)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#print('"'+sys.argv[-1]+'"')
|
||||
if sys.argv[-1]=='--refresh':
|
||||
vpn_status()
|
||||
pr_acct_status()
|
||||
battery()
|
||||
sys.exit()
|
||||
while(True):
|
||||
vpn_status()
|
||||
pr_acct_status()
|
||||
battery_status()
|
||||
ip_status()
|
||||
if sys.argv[-1]=='--refresh':
|
||||
break
|
||||
time.sleep(30)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ def color_remove(s):
|
||||
return re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]').sub('',s)
|
||||
|
||||
def shexec(s):
|
||||
return subprocess.check_output(shlex.split(s),shell=True).decode()
|
||||
return subprocess.check_output(shlex.split(s),shell=False).decode()
|
||||
|
||||
def is_cip():
|
||||
u = os.uname()
|
||||
|
||||
Reference in New Issue
Block a user