#!/usr/bin/env pythonimport timeimport osnumber = 0hashRateTresh = 3000 # HASHRATE that it will restarttry: # For Python 3.0 and later from urllib.request import urlopenexcept ImportError: # Fall back to Python 2's urllib2 from urllib2 import urlopenimport jsondef get_jsonparsed_data(url): """ Receive the content of ``url``, parse it as JSON and return the object. Parameters ---------- url : str Returns ------- dict """ response = urlopen(url) data = response.read().decode("utf-8") return json.loads(data)while number < 21: #GIVES TIME TO CONNECT url = ("https://www.litecoinpool.org/api?api_key=") #PUT YOUR LITECOINPOOL API HERE info = (get_jsonparsed_data(url)) y = json.dumps(info) file = json.loads(y) fileI = file["user"] q = json.dumps(fileI) w = json.loads(q) print (w["hash_rate"]) hashRate = w["hash_rate"] if(hashRate < hashRateTresh): #THIS WILL RESTART IN 20 SEC IF HASHRATE IS DOWN""" print ("LOW HASHRATE") time.sleep(1) number = number + 1 if(number > 20): print ("RESTART") os.system('sudo shutdown -r now') else: print (number) else: print ("OK") time.sleep(3)