Thanks so very much to @holger80 for his post How to claim all pending token rewards at once - improved claim command I was able to make a python script that did exactly as advertised. The instructions are very straight forward for anyone who has dinked around in python.
NOTE: I am on Ubuntu
From Holger's post linked above.
from beem import Steem
from beem.nodelist import NodeList
import json
import six
import requests
import getpass
if __name__ == "__main__":
if six.PY2:
username = raw_input("Username: ")
else:
username = input("Username: ")
url = "http://scot-api.steem-engine.com/@" + username
r = requests.get(url)
result = r.json()
json_data = []
for token in result:
scot = result[token]
if int(scot["pending_token"]) > 0:
json_data.append({"symbol": token})
print("%s can be claimed" % (token))
if len(json_data) > 0:
nodes = NodeList()
nodes.update_nodes()
stm = Steem(nodes.get_nodes())
pwd = getpass.getpass("Enter Walletpassword or posting key for %s" % username)
try:
stm.unlock(pwd)
except:
stm = Steem(node=nodes.get_nodes(), keys=[pwd])
stm.custom_json("scot_claim_token", json_data, required_posting_auths=[username])
else:
print("Nothing to claim")
In order to run this script, beem and steemengine must be installed:
pip install beem steemengine
When the script is saved as claim_all_scot.py
it can be run by
python claim_all_scot.py
The script asks for the username and checks of there is something to claim. When token can be claimed, it asks for the beem wallet password or for the posting key. One of both can be entered. Then the custom_json is broadcasted.
The above process is a very simple way to run the script. The basic steps:
First copy the script text and paste to a new document. Save the document as claim_all_scot.py
Second pip install beem steemengine
at a command line. If pip is not installed then you will be notified so then just need sudo apt install pip
and then try again.
Third is running it at the command line within the directory of the script you enter python claim_all_scot.py
Enter your username at the prompt, then your posting key.
You have now claimed your tokens.
Next is to automate the script a bit by inputting your username and posting key to the script. Username goes in the if six.PY2: username = raw_input("Username: ")
by replacing everything after the = sign with your username.
The posting key goes in pwd = getpass.getpass("Enter Walletpassword or posting key for %s" % username)
by replacing everything after the = sign with your posting key.
Save the file again and when you run the script next it should not require any input and will run and finish, exiting the window.
Now, I did not want to have to open the terminal to run my script constantly so I dug around and figured out how to run the script from a desktop icon. Since I am on Ubuntu I am missing hte luxury of Windows users with making a desktop shortcut or launcher. What I did was make a Claim.desktop file and saved it to my desktop. In this file I have:
[Desktop Entry]
Version=1.0
Name=Claim
Comment=Scot Claims
Exec=python /home/Steem/claim_all_scot.py
Icon=/home/Steem/Scot.png
Path=/home/Steem
Terminal=true
Type=Application
The location of my files differ from yours so change the exec to the location of your script file.
In your file manager go to the directory containing your script file.
Open the script file properties and change to allow the file to execute in the permissions tab.
This is all I did to make a working desktop launcher for the script. Now when I double click the icon I get a terminal window pop up, my account is checked and if anything is available to claim it is printed to the screen, then after a short wait the terminal window closes and my tokens are claimed.
EDIT: Made a crontab to run the script every morning at 6am. Now it is nicely automated for me.