Rsnarsna commited on
Commit
eb9f383
·
verified ·
1 Parent(s): 7248b15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -239,6 +239,19 @@ with gr.Blocks() as demo:
239
  # Add a manual timer without the interval parameter
240
  # gr.Timer.every(2, fn=update_status, outputs=status_display) # Run `update_status()` every 2 seconds
241
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  if __name__ == "__main__":
243
  logging.info('Starting project...')
 
244
  demo.launch()
 
239
  # Add a manual timer without the interval parameter
240
  # gr.Timer.every(2, fn=update_status, outputs=status_display) # Run `update_status()` every 2 seconds
241
 
242
+ def ping_test(hostname):
243
+ try:
244
+ # Run the ping command for 4 packets
245
+ result = subprocess.run(['ping', '-c', '4', hostname], stdout=subprocess.PIPE, text=True)
246
+ output = result.stdout
247
+ if "0% packet loss" in output:
248
+ return f"Ping successful:\n{output}"
249
+ else:
250
+ return f"Ping failed:\n{output}"
251
+ except Exception as e:
252
+ return f"Error running ping command: {e}"
253
+
254
  if __name__ == "__main__":
255
  logging.info('Starting project...')
256
+ ping_test()
257
  demo.launch()