Spaces:
Sleeping
Sleeping
Commit ·
a133e4f
1
Parent(s): 2ad2ab7
Project init
Browse files- app.py +48 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import winrm
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Uzak Windows makinesine bağlan
|
| 5 |
+
session = winrm.Session(
|
| 6 |
+
'http://ec2-13-51-205-29.eu-north-1.compute.amazonaws.com:5985/wsman',
|
| 7 |
+
auth=('Administrator', '(G40Si%D;L1YVzmKJB.ZZc@bGRfx6Sb;')
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
# Log okuma fonksiyonu
|
| 11 |
+
def read_logs():
|
| 12 |
+
command = 'Get-Content -Path "C:\\Users\\Administrator\\Documents\\win-x64\\publish\\PriceUpdater.log"'
|
| 13 |
+
result = session.run_ps(command)
|
| 14 |
+
|
| 15 |
+
# Farklı encodinglerle decode etmeyi dene
|
| 16 |
+
try:
|
| 17 |
+
return result.std_out.decode('utf-8') if result.std_out else "Log verisi yok."
|
| 18 |
+
except UnicodeDecodeError:
|
| 19 |
+
try:
|
| 20 |
+
return result.std_out.decode('latin-1')
|
| 21 |
+
except UnicodeDecodeError:
|
| 22 |
+
return result.std_out.decode('cp1254', errors='ignore') # Türkçe Windows için uygun
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# Gradio arayüzü fonksiyonu
|
| 26 |
+
def interface():
|
| 27 |
+
with gr.Blocks() as app:
|
| 28 |
+
gr.Markdown("## 📜 Uzak Log Takip Ekranı")
|
| 29 |
+
|
| 30 |
+
log_output = gr.Textbox(label="Log Çıktısı", interactive=False, lines=32)
|
| 31 |
+
|
| 32 |
+
# Logları güncelleyen fonksiyon
|
| 33 |
+
def update_logs():
|
| 34 |
+
logs = read_logs()
|
| 35 |
+
return logs
|
| 36 |
+
|
| 37 |
+
# Timer başlatma
|
| 38 |
+
log_timer = gr.Timer(0.2, True) # 1 saniyede bir çalışır
|
| 39 |
+
log_timer.tick(
|
| 40 |
+
update_logs, # Fonksiyon
|
| 41 |
+
outputs=log_output # Çıktıyı textbox'a bağla
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
return app
|
| 45 |
+
|
| 46 |
+
# Uygulamayı başlat
|
| 47 |
+
app = interface()
|
| 48 |
+
app.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==5.17.1
|
| 2 |
+
pywinrm==0.5.0
|
| 3 |
+
pandas==2.2.3
|