Created
December 8, 2017 02:50
-
-
Save 128keaton/519aa242fde5b1ab8e66466112b871dc to your computer and use it in GitHub Desktop.
DYN Coin Google Home notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import subprocess | |
import time | |
import json | |
import requests | |
EARL = 'http://10.0.0.145:5000/play/cha.m4a' | |
CMD = '~/dynamic-1.5.0/bin/dynamic-cli getwalletinfo' | |
BALANCE = -1.0 | |
def getBalance(): | |
output = subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) | |
json_str, _ = output.communicate() | |
jsonObject = json.loads(json_str) | |
global BALANCE | |
BALANCE = float(jsonObject["balance"]) | |
return BALANCE | |
def didChange(): | |
global BALANCE | |
prevBalance = BALANCE | |
BALANCE = getBalance() | |
if prevBalance < BALANCE and prevBalance != -1.0: | |
return True | |
return False | |
def sendNotification(): | |
requests.get(EARL) | |
while True: | |
if didChange() == True: | |
print(BALANCE) | |
sendNotification() | |
else: | |
print(BALANCE) | |
print 'Kahjit got warez if you got coin' | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment