Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import urllib.request
- import time
- import smtplib
- import datetime
- url = "http://dbix.pool.sexy/api/accounts/0x1602928a5aeb0a1d73ea36891e134a3dddb9838c"
- data = json.load(urllib.request.urlopen(url))
- # print(data) - shows all data
- # Gets whether or not selected rig is offline or online
- def isRigOffline(rigName):
- return str(data["workers"][rigName]["offline"])
- def sendEmail(rigName):
- from email.mime.text import MIMEText
- fromx = 'minerslj@gmail.com'
- to = 'ljlimitedbusiness@gmail.com'
- msg = MIMEText(rigName + " is offline!")
- msg['Subject'] = rigName + " is offline!"
- msg['From'] = fromx
- msg['To'] = to
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.ehlo()
- server.login('minerslj@gmail.com', 'fazazjimmy123')
- server.sendmail(fromx, to, msg.as_string())
- server.quit()
- print('Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
- print("Email sent to notify that " + rigName + " is offline!")
- print("-------------------------------")
- global rigName, x
- while True:
- try:
- # loop through every selected rig
- rigName = ["c1r1", "c1r2",
- "c2r1", "c2r2",
- "c3r1", "c3r2",
- "c4r1-j", "c4r2",
- "c5r1-j", "c5r2",
- "c6r1-j", "c6r2-j",
- "c7r1", "c7r2",
- "c8r1", "c8r2",
- "c9r1", "c9r2",
- "c10r1", "c10r2",
- "c11r1", "c11r2",
- "c12r1", "c12r2",
- "c13r1", "c13r2",
- "c14r1", "c14r2",
- "c15r1"]
- size = len(rigName)
- x = 0
- while x < size:
- # only send an email if the rig is offline
- if (isRigOffline(rigName[x]) == "True"):
- sendEmail(rigName[x])
- x += 1
- except: # if we try to look specifically for the rig and it's not appearing then it's offline
- #sendEmail(rigName[x])
- print(rigName[x] + " is completely offline")
- # keep this looping every 10 minutes
- time.sleep(1200)
- # reload the data after 10 mins
- data = json.load(urllib.request.urlopen(url))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement