update for beem - get_blog, get_followers and get_following works for api.steemit.com

in #utopian-io7 years ago (edited)

Repository

https://github.com/holgern/beem


beem-logo

beem is a python library for steem. beem has now 495 unit tests and a coverage of 70 %. The current version is 0.20.18.
I created a discord channel for answering a question or discussing beem: https://discord.gg/4HM592V
The newest beem version can be installed by:

pip install -U beem

or when using conda:

conda install beem

beem can be updated by:

conda update beem

New Features

public keys can be set in beempy newaccount for account creation

beempy newaccount --owner OWNER_PUB --active ACTIVE_PUB --memo MEMO_PUB --posting POSTING_PUB -a CREATOR_ACCOUNT NEW_ACCOUNT

When the owner, active, memo and posting parameter are used and 4 public keys are set, a new account is created with these 4 keys. Public/private keys can be created by beempy keygen

+-------------+-----------------------------------------------------------------------------------------------------------------+
| Key         | Value                                                                                                           |
+-------------+-----------------------------------------------------------------------------------------------------------------+
| Brain Key   | CENTO NOVENA CHIAUS ICEBERG DRAPE ORDERER YUSDRUM APHYLLY TORNUS YAWROOT OBEAH RIT CATELLA SILESIA HUBBA CULTCH |
| Private Key | 5JQZAHjvLf2Tncs6LU1P1nfwpvCaJWe8LKjbpworo5EUjdWL42G                                                             |
| Public Key  | STM7Bq295nbY3sm3RWoSRmQv2pFJdiNcxZZiazKmJw2epY25946D1                                                           |
+-------------+-----------------------------------------------------------------------------------------------------------------+

When now STM7Bq295nbY3sm3RWoSRmQv2pFJdiNcxZZiazKmJw2epY25946D1 is set as one of the four public keys, the new account will have 5JQZAHjvLf2Tncs6LU1P1nfwpvCaJWe8LKjbpworo5EUjdWL42G as one of the four private keys.

By this, it is possible to create 4 public/private keys and give only the public keys to someone else, who can then claim a new account using these 4 public keys.

Nodelist - api.steemit.com is handled as limited node

The get_nodes function has now an exclude_limited parameter. When set to True, https://api.steemit.com is excluded. The reason for doing this, is that https://api.steemit.com is not a feature-complete full node anymore. Several API calls do not work anymore.

from beem.nodelist import NodeList
nodelist = NodeList()
nodelist.update_nodes()
print(nodelist.get_nodes(exclude_limited=True))

returns nodes without api.steemit.com:

['https://steemd.minnowsupportproject.org', 'https://rpc.steemviz.com', 'https://anyx.io', 'https://rpc.usesteem.com', 'https://appbasetest.timcliff.com', 'https://steemd.privex.io', 'https://api.steem.house']

The https://rpc.usesteem.com was added to the nodelist.

Bug fixes

Issue #146 was caused by moving several API calls to hivemind. By this, the return structure of some calls were changed. The issue was
fixed by improving
get_blog, get_followers and get_following so that they works with api.steemit.com.
It was sufficient in this case to check of the returned object is a dict or a list.

When the returned object is a dict, it is converted into a list by returning the content in the blog field:

if isinstance(ret, dict) and "blog" in ret:
    ret = ret["blog"]

After doing this, both lists are similar and can be processed and returned.

Example call:

from beem import Steem
from beem.account import Account
stm = Steem(node="https://api.steemit.com")
acc = Account("holger80", steem_instance=stm)
print("%d followers, %d following" % (len(acc.get_followers()), len(acc.get_following())))
print("Last blog: %s" % (acc.get_blog(limit=1)[0]["title"]))

returns

1269 followers, 342 following
Last blog: steemrewarding.com - curation performance is shown and other improvements

Results for other nodes:

from beem import Steem
from beem.account import Account
stm = Steem(node="https://steemd.minnowsupportproject.org")
acc = Account("holger80", steem_instance=stm)
print("%d followers, %d following" % (len(acc.get_followers()), len(acc.get_following())))
print("Last blog: %s" % (acc.get_blog(limit=1)[0]["title"]))

returns

1272 followers, 342 following
Last blog: steemrewarding.com - curation performance is shown and other improvements

Unit tests are fixed

In all unit tests, the api.steemit.com node is excluded. This fixes all unit tests.

Commits

beempy newaccount - possible to provide owen, posting, active, and memo pub_key to create a new account

Fix get_follower and get_following for api.steemit.com

Fix get_blog for api.steemit.com

Nodelist udpated

  • commit a9972c4
  • normal and appbase option for Nodelist are deprecated.
  • exclude_limited added for getting a nodelist without api.steemit.com.
  • full node server added
  • unit tests adapted

Fix wrong full node api urls in unit tests

Fix unittests

  • commit 500f9a8
  • Remove not working steemitdev testnet
  • exclude api.steemit.com from some tests

Github account

https://github.com/holgern

Sort:  

Thank you very much for continuous development/maintainance of the library!

I would personally discourage the usage of a boolean parameter in a function, as this is likely a code smell, see this post

Also, you are changing multiple places to fix a issue - which is also likely a code smell - usually meaning that a common function/module could be extracted.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @justyy! Keep up the good work!

I appreciate all the work you put into beem. It is amazing and dwarfs the alternatives.

This post has been just added as new item to timeline of beem on Steem Projects.

If you want to be notified about new updates from this project, register on Steem Projects and add beem to your favorite projects.

Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Hi, @holger80!

You just got a 2.58% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.



Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 7.359 which ranks you at #62 across all Steem accounts.
Your rank has dropped 1 places in the last three days (old rank 61).

In our last Algorithmic Curation Round, consisting of 281 contributions, your post is ranked at #97.

Evaluation of your UA score:
  • Your follower network is great!
  • The readers appreciate your great work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

My head is spinning right now!

I should have not skipped a lot of my programming class lol

Hey, @holger80!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!