A friend of mine wrote this script for me :
Both have Python 2.7.14
In windows I just changed
#!/usr/bin/env python2.7 import requests; import json # Configurable Variables #Current mining coin path MINING_COIN_PATH = './smartMiner_Coin.json'; # Default coin DEFAULT_COIN = {'tag': "DUAL_SOIL_PASC"}; # Avoid switching for small benefits PERCENTAGE_VARIED = 10; def refreshTopCoin(): # Get current mining coin object currentCoin = DEFAULT_COIN; with open(MINING_COIN_PATH, 'r') as coinFile: currentCoin = json.load(coinFile) coinFile.close() r = requests.get("https://whattomine.com/coins.json"); coinsData = r.json()['coins']; coins = coinsData.keys(); topRevenue = {}; includeTags = ['HUSH', 'ZEC', 'ZEN', 'ZCL', 'SIB', 'XDN', 'LBC' , 'DGB' ] filterdCoins = {k: v for k, v in coinsData.iteritems() if v['tag'] in includeTags} coins = filterdCoins.keys() # print len(filterdCoins) def findDifficulty(d1, d2): return ((d1 - d2) / ((d1 + d2) / 2)) * 100 for coin in coins: coinObj = coinsData[coin] coinObj['smartProfitability'] = coinObj['btc_revenue'] topRevenue[coin] = coinObj # for k in topRevenue: # print topRevenue[k]['tag'], ' - ', topRevenue[k]['smartProfitability'] # print sorted(filterdCoins.values(), key=lambda d: d['smartProfitability']); difficultySort = sorted(filterdCoins.values(), key=lambda d: d['smartProfitability'], reverse=True); # print difficultySort; topCoin = DEFAULT_COIN; if (len(difficultySort) > 1): topCoin = difficultySort[0] # print topCoin['tag']; # print 'Current Coin: ', currentCoin['btc_revenue'] switchingRequired = isSwitchingRequired(currentCoin=currentCoin, topCoin=topCoin) if (switchingRequired): updateCoinFile = open(MINING_COIN_PATH, 'w') json.dump(topCoin, updateCoinFile, indent=4, sort_keys=True) updateCoinFile.close() def isSwitchingRequired(currentCoin, topCoin): print '#Coins: ', currentCoin['tag'], topCoin['tag'] if (currentCoin['tag'] != topCoin['tag']): currentRevenue = float(currentCoin['btc_revenue']) topRevenue = float(topCoin['btc_revenue']) print '#Revenue: ', currentRevenue, topRevenue revenueDiff = ((topRevenue - currentRevenue) / topRevenue) * 100 print "#Difference in Percentage", revenueDiff print "#Switch ", revenueDiff > PERCENTAGE_VARIED return revenueDiff > PERCENTAGE_VARIED return False refreshTopCoin()It works ok on windows but in ubuntu it gives me error :
python2.7 smartMiner_BTC.py Traceback (most recent call last): File "smartMiner_BTC.py", line 79, in <module> refreshTopCoin() File "smartMiner_BTC.py", line 20, in refreshTopCoin currentCoin = json.load(coinFile) File "/usr/lib/python2.7/json/__init__.py", line 291, in load **kw) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 367, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 27 column 1 - line 27 column 21 (char 812 - 832)Can any one help please ?
Both have Python 2.7.14
In windows I just changed
MINING_COIN_PATH = './smartMiner_Coin.json';to:
MINING_COIN_PATH = 'smartMiner_Coin.json';