create account

Find inactive witnesses you vote for - with python by crokkon

View this thread on steemit.com
· @crokkon ·
$6.74
Find inactive witnesses you vote for - with python
<center>![witnesses.png](https://ipfs.busy.org/ipfs/QmTML5cYW1Eae6F2voENHjWCzFmrddruzsbSXotoccUmBi)
<sup>Screenshot: https://steemd.com/witnesses</sup></center>

Inspired by @gadrian's recent post ["Had a look at my approved witness list [...]"](https://staging.busy.org/@gadrian/had-a-look-at-my-approved-witness-list-and-a-list-of-tools-for-new-and-not-so-new-steemians) I decided to take a look to my own witness votes. One aspect here was: do I vote for inactive witnesses. While there's nothing wrong with voting for (permanently) inactive witnesses, it just doesn't benefit anybody. There are probably a couple of tools already out there to get the same information, but I'll take the occasion to show how this can be done with [beem](https://github.com/holgern/beem)/python:

Steps involved:
* get a list of all witnesses an account votes for
* get the witness details of those
* check if they have set the 'disabled' signing key STM1111111111111111111111111111111114T1Anm
* check for how long they haven't been scheduled a block

Code:
```python
import sys
from beem import Steem
from beem.blockchain import Blockchain
from beem.account import Account
from beem.witness import GetWitnesses
from prettytable import PrettyTable
from datetime import timedelta, datetime

s = Steem(use_condenser=True)
a = Account(sys.argv[1], steem_instance=s)
pt = PrettyTable(['Witness', 'inactive since'])
head = Blockchain(mode='head', steem_instance=s).get_current_block_num()

for w in GetWitnesses(a['witness_votes'], steem_instance=s):
    if w.is_active is True:
        inactive_date = "active"
    else:
        inactive = timedelta(seconds=(head - w['last_aslot']) * 3)
        inactive_date = (datetime.utcnow() - inactive).date()
    pt.add_row([w['owner'], inactive_date])

print(pt)
```

Remarks:
* The list of voted witnesses is only available via the condenser API (for whatever reason?!) - this is why it needs a dedicated `Steem()` instance.
* The last scheduled block is given as a block number. In order to get the time since then, I take the difference in blocks to the current head block and calculate the time with the Steem block time (3s).

Save the snippet above as a .py file and run it with python (assuming beem is installed):
```
python [filename].py [your_account]
```


Here's the result for me
<center>
![inactive_witnesses.png](https://ipfs.busy.org/ipfs/QmVA9umkBS8DEG8M9ZyZm9R4rdTT995BJ7Aq6yTrQuQENE)
</center>

There are two candidates who shut down their witnesses and were last scheduled around half a year ago. I'll probably unvote those.
I realize I have quite a couple of free slots - not that my stake moves the ranks, but time to have a look for new witnesses to vote. Every vote counts.

Feel free to leave a comment if you want to have your witness votes checked, I can run the same script for you.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 267 others
properties (23)
post_id83,345,557
authorcrokkon
permlinkfind-inactive-witnesses-you-vote-for-with-python
categorywitness
json_metadata{"community":"busy","app":"busy\/2.5.6","format":"markdown","tags":["witness","inactive","python","how-to","stem","busy","palnet","neoxian"],"users":["gadrian"],"links":["https:\/\/steemd.com\/witnesses","\/@gadrian","https:\/\/staging.busy.org\/@gadrian\/had-a-look-at-my-approved-witness-list-and-a-list-of-tools-for-new-and-not-so-new-steemians","https:\/\/github.com\/holgern\/beem"],"image":["https:\/\/ipfs.busy.org\/ipfs\/QmTML5cYW1Eae6F2voENHjWCzFmrddruzsbSXotoccUmBi","https:\/\/ipfs.busy.org\/ipfs\/QmVA9umkBS8DEG8M9ZyZm9R4rdTT995BJ7Aq6yTrQuQENE"]}
created2020-01-11 13:00:18
last_update2020-01-11 13:00:18
depth0
children19
net_rshares27,660,339,818,323
last_payout2020-01-18 13:00:18
cashout_time1969-12-31 23:59:59
total_payout_value3.956 SBD
curator_payout_value2.784 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,834
author_reputation74,511,314,002,547
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (331)
@city-of-truth ·
# According to the Bible, *What is the danger of not spreading the Gospel of Christ worldwide as you do today?*
https://youtu.be/yPzxpJboWiU
https://i.postimg.cc/SxmKZFY2/image.jpg
Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to **Thank you, our beloved friend.**  
Check our [Discord Chat](https://discord.gg/vzHFNd6) 
Join our Official Community: https://beta.steemit.com/trending/hive-182074
👍  
👎  , , ,
properties (23)
post_id83,345,712
authorcity-of-truth
permlinkldp8pambk9
categorywitness
json_metadata{}
created2020-01-11 13:08:33
last_update2020-01-11 13:08:33
depth1
children0
net_rshares-155,897,956,344
last_payout2020-01-18 13:08:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length475
author_reputation-11,569,999,317,502
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout10,000.000 SBD
percent_steem_dollars100
author_curate_reward""
vote details (5)
@gadrian ·
Thanks for the tutorial! I'll put it to practice.
properties (22)
post_id83,345,934
authorgadrian
permlinkre-crokkon-q3y2f1
categorywitness
json_metadata{"tags":["witness"],"app":"steempeak\/2.2.6"}
created2020-01-11 13:21:03
last_update2020-01-11 13:21:03
depth1
children2
net_rshares0
last_payout2020-01-18 13:21:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length49
author_reputation27,331,701,354,422
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@crokkon ·
thanks for the resteem!
👍  
properties (23)
post_id83,374,464
authorcrokkon
permlinkq402zk
categorywitness
json_metadata{"app":"steemit\/0.1"}
created2020-01-12 15:28:33
last_update2020-01-12 15:28:33
depth2
children1
net_rshares5,491,941,291
last_payout2020-01-19 15:28:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length23
author_reputation74,511,314,002,547
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@gadrian · (edited)
you're welcome! I find it very useful, and if anyone is like me, new to ubuntu and to python (and wanting to learn a bit more), they will appreciate it.
properties (22)
post_id83,374,539
authorgadrian
permlinkre-crokkon-q4034l
categorywitness
json_metadata{"tags":["witness"],"app":"steempeak\/2.2.6"}
created2020-01-12 15:31:33
last_update2020-01-12 15:34:57
depth3
children0
net_rshares0
last_payout2020-01-19 15:31:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length152
author_reputation27,331,701,354,422
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@contrabourdon ·
!witness-vote-check crokkon 😜
👍  
properties (23)
post_id83,372,024
authorcontrabourdon
permlinkre-crokkon-q3zxiz
categorywitness
json_metadata{"tags":["witness"],"app":"steempeak\/2.2.6"}
created2020-01-12 13:30:39
last_update2020-01-12 13:30:39
depth1
children10
net_rshares562,475,764
last_payout2020-01-19 13:30:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length29
author_reputation81,700,031,169,771
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@untersatz ·
@crokkon, these <a href="https://steemit.com/~witnesses">witnesses</a> you have voted for have retired (or are running a zombie server):<br>
### krnel, noblewitness
<br>You have **12 <a href="https://steemit.com/~witnesses">witness votes</a>** left to use.
<br>You are voting for: actifit, arcange, busy.witness, c0ff33a, c-squared, curie, dpoll.witness, emrebeyler, holger80, krnel, lukestokes.mhth, noblewitness, ocd-witness, patrice, qurator, stem.witness, therealwolf, wise-team.
<br><hr>Powered by witness <a href="https://untersatz.steem.design">untersatz</a>!
properties (22)
post_id83,372,034
authoruntersatz
permlinkdr226fm67zo
categorywitness
json_metadata{}
created2020-01-12 13:31:03
last_update2020-01-12 13:31:03
depth2
children3
net_rshares0
last_payout2020-01-19 13:31:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length566
author_reputation2,078,632,808,514
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@contrabourdon ·
Now, go and vote my witness 🤓 (only if you want to). 
properties (22)
post_id83,372,053
authorcontrabourdon
permlinkre-untersatz-q3zxli
categorywitness
json_metadata{"tags":["witness"],"app":"steempeak\/2.2.6"}
created2020-01-12 13:32:09
last_update2020-01-12 13:32:09
depth3
children2
net_rshares0
last_payout2020-01-19 13:32:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length53
author_reputation81,700,031,169,771
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@abh12345.stem ·
!witness-vote-check abh12345
properties (22)
post_id83,372,302
authorabh12345.stem
permlinkq3zy5f
categorywitness
json_metadata{"tags":["witness","stem"],"app":"stemgeeks\/0.1","canonical_url":"https:\/\/stemgeeks.net\/@abh12345.stem\/q3zy5f"}
created2020-01-12 13:44:03
last_update2020-01-12 13:44:03
depth2
children5
net_rshares0
last_payout2020-01-19 13:44:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length28
author_reputation343,206,540,447
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@untersatz ·
@abh12345, these <a href="https://steemit.com/~witnesses">witnesses</a> you have voted for have retired (or are running a zombie server):<br>
### demotruk, pjau
<br>You have **0 <a href="https://steemit.com/~witnesses">witness votes</a>** left to use.
<br>You are voting for: actifit, aggroed, arcange, ausbitbank, blockbrothers, blocktrades, busy.witness, c0ff33a, c-squared, curie, danielsaori, demotruk, drakos, emrebeyler, followbtcnews, good-karma, gtg, holger80, kevinwong, lukestokes.mhth, ocd-witness, pharesim, pjau, qurator, roelandp, steemgigs, stoodkev, timcliff, ura-soul, yabapmatt.
<br><hr>Powered by witness <a href="https://untersatz.steem.design">untersatz</a>!
properties (22)
post_id83,372,317
authoruntersatz
permlink78pvfcbt41l
categorywitness
json_metadata{}
created2020-01-12 13:44:33
last_update2020-01-12 13:44:33
depth3
children4
net_rshares0
last_payout2020-01-19 13:44:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length679
author_reputation2,078,632,808,514
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@emrebeyler ·
!witness-vote-check emrebeyler
👍  
properties (23)
post_id83,373,027
authoremrebeyler
permlinkq3zzue
categorywitness
json_metadata{"app":"steemit\/0.1"}
created2020-01-12 14:20:39
last_update2020-01-12 14:20:39
depth1
children1
net_rshares5,549,381,170
last_payout2020-01-19 14:20:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length30
author_reputation290,625,242,982,087
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@untersatz ·
@emrebeyler, these <a href="https://steemit.com/~witnesses">witnesses</a> you have voted for have retired (or are running a zombie server):<br>
### provenezuela
<br>You have **0 <a href="https://steemit.com/~witnesses">witness votes</a>** left to use.
<br>You are voting for: actifit, adsactly-witness, ausbitbank, blockbrothers, bobinson, c0ff33a, crowdwitness, danielsaori, dpoll.witness, emrebeyler, fyrst-witness, guiltyparties, helpie, holger80, isnochys, kevinwong, lux-witness, mahdiyari, mysia, neoxian, nextgencrypto, ocd-witness, pharesim, provenezuela, ro-witness, steempress, themarkymark, therealwolf, untersatz, yehey.
<br><hr>Powered by witness <a href="https://untersatz.steem.design">untersatz</a>!
properties (22)
post_id83,373,038
authoruntersatz
permlink3k8nbnkaark
categorywitness
json_metadata{}
created2020-01-12 14:21:15
last_update2020-01-12 14:21:15
depth2
children0
net_rshares0
last_payout2020-01-19 14:21:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length715
author_reputation2,078,632,808,514
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@geekgirl ·
!witness-vote-check geekgirl
👍  
properties (23)
post_id83,550,269
authorgeekgirl
permlinkq4bnla
categorywitness
json_metadata{"app":"steemit\/0.1"}
created2020-01-18 21:27:09
last_update2020-01-18 21:27:09
depth1
children1
net_rshares0
last_payout2020-01-25 21:27:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length28
author_reputation138,038,426,460,288
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@untersatz ·
@geekgirl, these <a href="https://steemit.com/~witnesses">witnesses</a> you have voted for have retired (or are running a zombie server):<br>
### demotruk, felixxx
<br>You have **0 <a href="https://steemit.com/~witnesses">witness votes</a>** left to use.
<br>You are voting for: adsactly-witness, arcange, ats-witness, blockbrothers, c0ff33a, clayop, crowdwitness, curie, demotruk, drakos, emrebeyler, felixxx, gtg, guiltyparties, holger80, justyy, kevinwong, mahdiyari, neoxian, oflyhigh, pharesim, proxy.token, quochuy, ro-witness, steemgigs, steemhunt, stoodkev, thecryptodrive, themarkymark, therealwolf.
<br><hr>Powered by witness <a href="https://untersatz.steem.design">untersatz</a>!
properties (22)
post_id83,550,279
authoruntersatz
permlinkbwdh52tkkin
categorywitness
json_metadata{}
created2020-01-18 21:27:36
last_update2020-01-18 21:27:36
depth2
children0
net_rshares0
last_payout2020-01-25 21:27:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length691
author_reputation2,078,632,808,514
root_title"Find inactive witnesses you vote for - with python"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000