Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 49a8db8

Browse files
committed
Release 0.20.12
* pep8 formating improved * Too Many Requests error handled * different limit handling in WLS fixed for account history * percent-steem-dollars and max-accepted-payout added to beempy post
1 parent 51b0322 commit 49a8db8

13 files changed

Lines changed: 71 additions & 54 deletions

File tree

beem/account.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,10 @@ def total_balances(self):
891891
symbols.append(balance["symbol"])
892892
ret = []
893893
for i in range(len(symbols)):
894-
ret.append(self.get_balance(self.available_balances, symbols[i]) + self.get_balance(self.saving_balances, symbols[i]) +
895-
self.get_balance(self.reward_balances, symbols[i]))
894+
balance_sum = self.get_balance(self.available_balances, symbols[i])
895+
balance_sum += self.get_balance(self.saving_balances, symbols[i])
896+
balance_sum += self.get_balance(self.reward_balances, symbols[i])
897+
ret.append(balance_sum)
896898
return ret
897899

898900
@property
@@ -1449,6 +1451,8 @@ def _get_account_history(self, account=None, start=-1, limit=0):
14491451
ret = self.steem.rpc.get_account_history(account["name"], start, limit, api="condenser")
14501452
else:
14511453
ret = self.steem.rpc.get_account_history(account["name"], start, limit, api="database")
1454+
if len(ret) == 0 and limit == 0:
1455+
ret = self.steem.rpc.get_account_history(account["name"], start, limit + 1, api="database")
14521456
return ret
14531457

14541458
def estimate_virtual_op_num(self, blocktime, stop_diff=0, max_count=100):
@@ -1544,9 +1548,7 @@ def get_blocknum(index):
15441548
# linear approximation between the known upper and
15451549
# lower bounds for the first iteration
15461550
if cnt < 1:
1547-
op_num = int((target_blocknum - block_lower) /
1548-
(block_upper - block_lower) *
1549-
(op_upper - op_lower) + op_lower)
1551+
op_num = int((target_blocknum - block_lower) / (block_upper - block_lower) * (op_upper - op_lower) + op_lower)
15501552
else:
15511553
# divide and conquer for the following iterations
15521554
op_num = int((op_upper + op_lower) / 2)
@@ -2234,25 +2236,22 @@ def update_account_keys(self, new_password, account=None, **kwargs):
22342236
key_auths = {}
22352237
for role in ['owner', 'active', 'posting', 'memo']:
22362238
pk = PasswordKey(account['name'], new_password, role=role)
2237-
key_auths[role] = format(pk.get_public_key(), self.steem.prefix)
2239+
key_auths[role] = format(pk.get_public_key(), self.steem.prefix)
22382240

22392241
op = operations.Account_update(**{
22402242
"account": account["name"],
2241-
'owner': {
2242-
'account_auths': [],
2243-
'key_auths': [[key_auths['owner'], 1]],
2244-
"address_auths": [],
2245-
'weight_threshold': 1},
2246-
'active': {
2247-
'account_auths': [],
2248-
'key_auths': [[key_auths['active'], 1]],
2249-
"address_auths": [],
2250-
'weight_threshold': 1},
2251-
'posting': {
2252-
'account_auths': account['posting']['account_auths'],
2253-
'key_auths': [[key_auths['posting'], 1]],
2254-
"address_auths": [],
2255-
'weight_threshold': 1},
2243+
'owner': {'account_auths': [],
2244+
'key_auths': [[key_auths['owner'], 1]],
2245+
"address_auths": [],
2246+
'weight_threshold': 1},
2247+
'active': {'account_auths': [],
2248+
'key_auths': [[key_auths['active'], 1]],
2249+
"address_auths": [],
2250+
'weight_threshold': 1},
2251+
'posting': {'account_auths': account['posting']['account_auths'],
2252+
'key_auths': [[key_auths['posting'], 1]],
2253+
"address_auths": [],
2254+
'weight_threshold': 1},
22562255
'memo_key': key_auths['memo'],
22572256
"json_metadata": account['json_metadata'],
22582257
"prefix": self.steem.prefix,
@@ -2527,7 +2526,7 @@ def claim_reward_balance(self,
25272526
"reward_sbd": reward_sbd,
25282527
"reward_vests": reward_vests,
25292528
"prefix": self.steem.prefix,
2530-
})
2529+
})
25312530
else:
25322531
reward_steem = account.balances["rewards"][0]
25332532
reward_vests = account.balances["rewards"][1]

beem/amount.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,12 @@ def __init__(self, amount, asset=None, new_appbase_format=True, steem_instance=N
9696
self["amount"], self["symbol"] = amount.split(" ")
9797
self["asset"] = Asset(self["symbol"], steem_instance=self.steem)
9898

99-
elif (amount and asset is None and
100-
isinstance(amount, dict) and
101-
"amount" in amount and
102-
"asset_id" in amount):
99+
elif (amount and asset is None and isinstance(amount, dict) and "amount" in amount and "asset_id" in amount):
103100
self["asset"] = Asset(amount["asset_id"], steem_instance=self.steem)
104101
self["symbol"] = self["asset"]["symbol"]
105102
self["amount"] = int(amount["amount"]) / 10 ** self["asset"]["precision"]
106103

107-
elif (amount and asset is None and
108-
isinstance(amount, dict) and
109-
"amount" in amount and
110-
"asset" in amount):
104+
elif (amount and asset is None and isinstance(amount, dict) and "amount" in amount and "asset" in amount):
111105
self["asset"] = Asset(amount["asset"], steem_instance=self.steem)
112106
self["symbol"] = self["asset"]["symbol"]
113107
self["amount"] = int(amount["amount"]) / 10 ** self["asset"]["precision"]

beem/cli.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,8 +1520,10 @@ def beneficiaries(authorperm, beneficiaries):
15201520
@click.option('--reply_identifier', help=' Identifier of the parent post/comment, when set a comment is broadcasted')
15211521
@click.option('--community', help=' Name of the community (optional)')
15221522
@click.option('--beneficiaries', '-b', help='Post beneficiaries (komma separated, e.g. a:10%,b:20%)')
1523+
@click.option('--percent-steem-dollars', '-b', help='50% SBD /50% SP is 10000 (default), 100% SP is 0')
1524+
@click.option('--max-accepted-payout', '-b', help='Default is 1000000.000 [SBD]')
15231525
@click.option('--no-parse-body', help='Disable parsing of links, tags and images', is_flag=True, default=False)
1524-
def post(body, account, title, permlink, tags, reply_identifier, community, beneficiaries, no_parse_body):
1526+
def post(body, account, title, permlink, tags, reply_identifier, community, beneficiaries, percent_steem_dollars, max_accepted_payout, no_parse_body):
15251527
"""broadcasts a post/comment"""
15261528
stm = shared_steem_instance()
15271529
if stm.rpc is not None:
@@ -1539,9 +1541,9 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene
15391541
if len(content.split("---")) > 1:
15401542
body = content.split("---")[-1]
15411543
docs = yaml.load_all(content.split("---")[-2])
1542-
1544+
15431545
for doc in docs:
1544-
for k,v in doc.items():
1546+
for k, v in doc.items():
15451547
parameter[k] = v
15461548
else:
15471549
body = content
@@ -1555,6 +1557,14 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene
15551557
parameter["beneficiaries"] = beneficiaries
15561558
if reply_identifier is not None:
15571559
parameter["reply_identifier"] = reply_identifier
1560+
if percent_steem_dollars is not None:
1561+
parameter["percent_steem_dollars"] = percent_steem_dollars
1562+
elif "percent-steem-dollars" in parameter:
1563+
parameter["percent_steem_dollars"] = parameter["percent-steem-dollars"]
1564+
if max_accepted_payout is not None:
1565+
parameter["max_accepted_payout"] = max_accepted_payout
1566+
elif "max-accepted-payout" in parameter:
1567+
parameter["max_accepted_payout"] = parameter["max-accepted-payout"]
15581568
tags = None
15591569
if "tags" in parameter:
15601570
tags = []
@@ -1582,6 +1592,23 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene
15821592
parse_body = bool(parameter["parse_body"])
15831593
else:
15841594
parse_body = not no_parse_body
1595+
max_accepted_payout = None
1596+
1597+
percent_steem_dollars = None
1598+
if "percent_steem_dollars" in parameter:
1599+
percent_steem_dollars = parameter["percent_steem_dollars"]
1600+
max_accepted_payout = None
1601+
if "max_accepted_payout" in parameter:
1602+
max_accepted_payout = parameter["max_accepted_payout"]
1603+
comment_options = None
1604+
if max_accepted_payout is not None or percent_steem_dollars is not None:
1605+
comment_options = {}
1606+
if max_accepted_payout is not None:
1607+
if stm.sbd_symbol not in max_accepted_payout:
1608+
max_accepted_payout = str(Amount(float(max_accepted_payout), stm.sbd_symbol, steem_instance=stm))
1609+
comment_options["max_accepted_payout"] = max_accepted_payout
1610+
if percent_steem_dollars is not None:
1611+
comment_options["percent_steem_dollars"] = percent_steem_dollars
15851612
beneficiaries = None
15861613
if "beneficiaries" in parameter:
15871614
beneficiaries_list = []
@@ -1604,7 +1631,7 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene
16041631
beneficiaries_sum += percentage
16051632
beneficiaries_list.append({"account": a["name"], "weight": int(percentage * 100)})
16061633
beneficiaries_accounts.append(a["name"])
1607-
1634+
16081635
missing = 0
16091636
for bene in beneficiaries_list:
16101637
if bene["weight"] < 0:
@@ -1615,8 +1642,9 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene
16151642
beneficiaries_list[index]["weight"] = int((int(100 * 100) - int(beneficiaries_sum * 100)) / missing)
16161643
index += 1
16171644
beneficiaries = sorted(beneficiaries_list, key=lambda beneficiaries_list: beneficiaries_list["account"])
1645+
16181646
tx = stm.post(title, body, author=author, permlink=permlink, reply_identifier=reply_identifier, community=community,
1619-
tags=tags, beneficiaries=beneficiaries, parse_body=parse_body)
1647+
tags=tags, comment_options=comment_options, beneficiaries=beneficiaries, parse_body=parse_body)
16201648
if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None:
16211649
tx = stm.steemconnect.url_from_tx(tx)
16221650
tx = json.dumps(tx, indent=4)
@@ -1645,7 +1673,7 @@ def reply(authorperm, body, account, title):
16451673
if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None:
16461674
tx = stm.steemconnect.url_from_tx(tx)
16471675
tx = json.dumps(tx, indent=4)
1648-
print(tx)
1676+
print(tx)
16491677

16501678

16511679
@cli.command()
@@ -3203,8 +3231,7 @@ def info(objects):
32033231
median_price = stm.get_current_median_history()
32043232
steem_per_mvest = stm.get_steem_per_mvest()
32053233
chain_props = stm.get_chain_properties()
3206-
price = (Amount(median_price["base"], steem_instance=stm).amount / Amount(
3207-
median_price["quote"], steem_instance=stm).amount)
3234+
price = (Amount(median_price["base"], steem_instance=stm).amount / Amount(median_price["quote"], steem_instance=stm).amount)
32083235
for key in info:
32093236
t.add_row([key, info[key]])
32103237
t.add_row(["steem per mvest", steem_per_mvest])

beem/conveyor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def prehash_message(self, timestamp, account, method, params, nonce):
7575
:param bytes nonce: random 8 bytes
7676
7777
"""
78-
first = hashlib.sha256(py23_bytes(timestamp + account + method +
79-
params, self.ENCODING))
78+
first = hashlib.sha256(py23_bytes(timestamp + account + method + params, self.ENCODING))
8079
return self.K + first.digest() + nonce
8180

8281
def _request(self, account, method, params, key):

beem/nodelist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def __init__(self):
221221
"type": "appbase",
222222
"owner": "anyx",
223223
"score": 50
224-
},
224+
},
225225
{
226226
"url": "https://rpc.curiesteem.com",
227227
"version": "0.20.2",

beem/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
2-
version = '0.20.11'
2+
version = '0.20.12'

beem/wallet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ def unlock(self, pwd=None):
203203
if not pwd:
204204
self.tryUnlockFromEnv()
205205
else:
206-
if (self.masterpassword is None and
207-
config[self.MasterPassword.config_key]):
206+
if (self.masterpassword is None and config[self.MasterPassword.config_key]):
208207
self.masterpwd = self.MasterPassword(pwd)
209208
self.masterpassword = self.masterpwd.decrypted_master
210209

beemapi/graphenerpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ def _check_for_server_error(self, reply):
335335
raise RPCError("Not Implemented")
336336
elif re.search("Bad Gateway", reply) or re.search("502", reply):
337337
raise RPCErrorDoRetry("Bad Gateway")
338+
elif re.search("Too Many Requests", reply) or re.search("429", reply):
339+
raise RPCErrorDoRetry("Too Many Requests")
338340
elif re.search("Service Temporarily Unavailable", reply) or re.search("Service Unavailable", reply) or re.search("503", reply):
339341
raise RPCErrorDoRetry("Service Temporarily Unavailable")
340342
elif re.search("Gateway Time-out", reply) or re.search("Gateway Timeout", reply) or re.search("504", reply):

beemapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
2-
version = '0.20.11'
2+
version = '0.20.12'

beemapi/websocket.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ def on_message(self, ws, reply, *args):
177177
# print(data)
178178

179179
if id >= len(self.__events__):
180-
log.critical(
181-
"Received an id that is out of range\n\n" +
182-
str(data)
183-
)
180+
log.critical("Received an id that is out of range\n\n" + str(data))
184181
return
185182

186183
# This is a "general" object change notification
@@ -241,10 +238,10 @@ def run_forever(self):
241238
on_open=self.on_open,
242239
)
243240
self.ws.run_forever()
244-
except websocket.WebSocketException as exc:
241+
except websocket.WebSocketException:
245242
self.nodes.increase_error_cnt()
246243
self.nodes.sleep_and_check_retries()
247-
except websocket.WebSocketTimeoutException as exc:
244+
except websocket.WebSocketTimeoutException:
248245
self.nodes.increase_error_cnt()
249246
self.nodes.sleep_and_check_retries()
250247
except KeyboardInterrupt:

0 commit comments

Comments
 (0)