Python Libraries: No More BEEM

in #hive-1635212 months ago

image.png

I spent the last weekend re-writing my voting BOT. It’s a thankless task, and I have been putting it off for months. When I get my Python hat on, I roll, but it's tough finding that headwear sometimes.

There are more interesting things to do like playing Assassin's Creed Odyssey or re-playing it. Wasted time, it surely is and after a 4 hour session I feel so guilty for not having achieved anything.


image.png
...'hunting down Mercenaries and Cultists is surely more fun than this?'... - Source

Gaining TWO levels does not count, as this is strictly escapism in the finest sense, though entertaining.

So I wasted two days, re-writing my abortion of a legacy script that works very well but looks fucking awful. ‘BEEM the deprecated', it had to go and nearly has.

The idea of showing some deserving UK Hivers love, due to @c0ff33a's old @teamuksupport ceasing to be sounded great, but this was not my idea.

@livingktaiwan asked me if I could convert my old BOT, and suddenly that elusive Python hat appeared in front of my eyes as if by magic.


image.png
...'thanks @steevc, these lists of yours came in very handy'...

@steevc’s large list of UK people helped me out and I have to say a big thanks to @livingktaiwan for supplying me the data formatted in a list.

After a very productive Saturday and an equally unproductive Sunday, the BOT was ready for its first run-through and crashed spectacularly.

It’s my fault for naming it v1.0. It should have been at least v1.1 for as everyone knows v.1.0 of anything does not work.

Running scripts against lists always surprises me with the data it feeds out. It's one of the joys of being able to code; to see that 'thing' you are developing spring into life.

There are still some bugs in it, but it's kind of working though hardly draining my voting power.


image.png
...'a common sight, hardly anyone posts content on HIVE, at least from the UK'...

There's barely anyone posting and a single run-through didn't quite achieve what I was looking for.

My old BOT relied heavily on BEEM and Saturday was bliss, with not a BEEM Import on the horizon.

Then Sunday arrived, the BOT was 90% done and that last 10% was going to give me some shit. I wanted to use the Condenser API calls and had found functions for almost everything except a couple of pertinent ones.

- get_voting_power

I had used BEEM previously and try as I may, I could not get a condenser function to return the correct values. After fucking around for a couple of hours I caved in and added the BEEM library.

# -----------------------------------------------------------------------------
# Function to get the voting power of an account using fucking BEEM :(
def get_voting_power(voter):
    try:
        account = Account(voter, blockchain_instance=hive)
        vp = round(account.get_voting_power(), 2)  # Convert to percentage
        return vp
    except Exception as e:
        print(f"Error retrieving voting power for @{voter}: {e}")
        return None
# -----------------------------------------------------------------------------

As you can see, I was far from happy but I wanted the new toy to be finished by the end of the weekend. I knew once my coding head was off the rails, it would be tough for me to re-attach.

- vote

This was puzzling, there must be a way to vote using clear-text credential posting keys. Yet again, I could not find a way to do it, nothing was working and Sunday afternoon was turning into dusk.

# -------------------------------------------------------------------------------
def vote(post, author, ivoteweight, voter, lasestpost):

    print()
    if hasAuthorVoted(voter, author, lasestpost):
        print (bcolors.RED + f" Post has already been voted by @{voter}, skipping..." +     bcolors.END)
        return
    else:
        print(bcolors.YELLOW + f" Post has NOT previously been voted by @{voter}..." + bcolors.END)
        print(bcolors.YELLOW + f' Post will be voted at {ivoteweight:.2f}%' + bcolors.END)

        if not debugmode:
            post.upvote(weight=ivoteweight, voter=voter)

        print()
        print(bcolors.GREEN + " STATUS: Success!!!"+ bcolors.END)

    return
# -------------------------------------------------------------------------------

'lasestpost'- I was getting tired, but spelling mistake or not, it would work!

BEEM again to the rescue, and thanks @felixxx for helping me out converting a permalink string to a BEEM comment.

The documentation may seem extensive for this ageing library but as all my other functions DON'T use BEEM, the permalinks I had were not BEEM comments, and I needed them to be in that specific format for the vote function to work.

# ---------------------------------------------------------------------------
def permalink_to_beem_comment(permalink):

    hive = Hive(node = activenode)
    post = Comment(permalink, hive_instance=hive)
    return post
# ---------------------------------------------------------------------------

It's easy enough so long as you have a definition within activenode, otherwise, you get a 'String Indices’ error that tells you nothing. Luckily I have friends who know the idiosyncrasies of this library.

So… for the moment:

activenode = "https://api.deathwing.me"

Thanks @deathwing, I find your node particularly reliable and you have a cool name, so I used you.

As for the BOT and who it’s going to vote that will remain a secret. If you are from the UK or are an ex-patriot I will know about you via @steevc's list, so maybe not so secret.

I want to thank several other Orca's (who will remain nameless) who have thrown in and, supported this BOT by following a specific account that triggers further votes.


image.png
...'Orca Support - don't expect $$, but it's better than nothing'... - Source

If it was just @livingktaiwan and me it would have been decent but having that handful of other voters makes it more significant.

Please don’t ask to be added to the list, if you are deserving and from the UK then I will seek you out and give you support.

Lastly, I will give big comment votes out to anyone who can replace these fucking BEEM functions with working Condenser ones!

RedLine.png

Do you like posting your Urbex content and photography for FREE on Facebook and YouTube? I like to get some form of reward for my work and every time I create I do just that. Take a look at The Urbex Community on HIVE.

If you want to keep creating for FREE then ignore what you are reading. If you want to be like me and gain something other than BUGGER ALL for your work then click here and learn about posting on the HIVE blockchain.


My Urban Exploration Tales can be found directly on the internet via my
Website: 'Tales of the Urban Explorer'.

RedLine.png

TalesLogo.JPG

RedLine.png


CurieCurator.jpg

RedLine.png

Drooling Maniac.JPG

If you found this article so invigorating that you are now a positively googly-eyed, drooling lunatic with dripping saliva or even if you liked it just a bit, then please upvote, comment, rehive, engage me or all of these things.

Sort:  

Awesome work mate, yer a champ for seeing it through!

I do love your snarky code comments 🤣

do love your snarky code comments

They are absolutely unnecessary, it's just me being silly.

I know, it's fun to read though 😀

Understood every single individual word above but not them stringed together 😵‍💫

Hopefully the support will make some difference to deserving Brits and encourage more to be active. Pay it forward is a great way to make Hive grow

LOL, there's other stuff in there, for non-geeks, I had to write it that way. Almost BEEM free, but it's not going to for away for the moment.

"Looks like a weekend well spent! Honestly, a lot of this feels like gibberish to me, but I’m thinking I should probably learn some programming myself. That way I can help my kids down the road, if they’re interested, of course!

That way I can help my kids down the road, if they’re interested

Sadly mine was not, and opted out of Computer Studies at school. Now she's grown up and at University.

I think those are time well spent, even the gaming ones. I don't know how to code in python, but I remember the pain of fixing code bugs and errors. I think it's great that you guys decided to continue supporting the UK hivers.

I think it's great that you guys decided to continue supporting the UK hivers.

If peeps in the other countries did the same, it would be an incentive to write better stuff.

Loading...

Genius!

I find AC quite repetitive these days, I can't find anything worthy of my time, we need a new fallout

A new Fallout would be awesome, but it's not going to end up on Sony's platform. Bethesda was bought out by Microsoft.

fuck me is there anything you don't know!!!!!

I think it's a wknd well spent! Something constructive came out of it! Can you extend it to other countries...? Just not THOSE two!

I do plan to have it fall through the the other BOT code that includes the rest of the world, it's not tough to do and ensure I use all that spare VP.

Good to hear! Does it have a lower mana limit for voters..?

Yes, it cuts off at 75% for the small accounts and 86% for my big one. All configurable.

OK cheers!

playing Assassin's Creed Odyssey

Doing everything on that game required me an indecent amount of hours, back when I had a lot of spare time to waste 😅 but as an old AC player I felt for years the need to 100% complete every one of them.

with not a BEEM Import on the horizon.

I'm trying to use the condenser API for my latest script (as you suggested me), but I feel that it's going to be a long journey before I can remove BEEM from my imports 😂

Tonight I'm going to see if I can make some progress and, if I have time, I'd also like to give a second look at your snippets: having some working scripts without (or almost without) BEEM is gold for me!

but as an old AC player I felt for years the need to 100% complete every one of them.

LOL, it's a great game with such atmosphere. I like most of them, but was disappointed with Mirage which I felt was small and compromised.

Tonight I'm going to see if I can make some progress and, if I have time, I'd also like to give a second look at your snippets: having some working scripts without (or almost without) BEEM is gold for me!

BEEM is handy, but I am afraid of it breaking without notice.

I still have to play both Mirage and the previous one, Valhalla: I've read mostly negative review about Mirage, but still I'd like to play again an AC similar to the original ones, just for the vides ahhaah

About BEEM, may I ask you a (surely stupid) question? Python tutorials on developers.hive.io use BEEM, so they are outdated, right? Because I was going through all of them, but looking at your first snippet I finally grasped (a little) how I should use the condenser API and realized that those tutorials must have been written before the deprecation of BEEM.

It seems we are stuck with BEEM for certain transactions unless you want to build a transaction signing function. I'm happy to be 90% BEEM free, it cuts down on the errors.

What we need is someone to either update BEEM or build a new API that is just as good as that was. Some have been attempted but I haven't seen any updates lately.

@emrebeyler did one, have a look here.

It seems we are stuck with BEEM for certain transactions unless you want to build a transaction signing function.

Ok, that's exactly what I couldn't find anywhere in the condenser API: I was looking everywhere for a way to sign a transaction, but I couldn't find it 😅

@emrebeyler did one, have a look here.

Going to check it now :)

Can I use that also with Python? I mean, by "translating" it into Python?

I'm not a real coder, so I ask sorry in advance in case I said a blasphemy 😂

The tutorial linked above, also contains a link to a Python example from 8(!) years ago.

You can translate it to any language, of course.
But the whole signing procedure is a bit complicated and if you just want to build something, I would recommend you just use an existing library for signing.
Posted the link, so you can see how much trouble it is.

Nothing against python since I use mostly in, I am more fluent for sure. But since I stepped a bit in javascript I felt that the Hive client in JS is easier to get what you want... you look good in general logics , I recommend you try it out!

I will do at some point, I don't have an issue switching languages, other than getting used to the weird things (python and its annoying indentation insistence) and syntax.

weird things (python and its annoying indentation insistence)
hhehe the old debate of the pro and con indentation ahahha I was forced to give up on Perl because of that hehehe

I could never get to grips with Perl, a very cryptic looking language.

Loading...

Appreciate your time and effort mate, I see it as a good way to support brits wherever they are. count me in.

Thanks for your support, I appreciate it! 😀

Cool stuff. We need a supported library of essential functions. Maybe someone can fork beem and improve it.

Yeah, that would be nice. It was probably a thankless task for @holger80 and that's why he abandoned it.

Thanks @deathwing, I find your node particularly reliable and you have a cool name, so I used you.

@deathwing's node seems to also be the only one that supports ipv6.
A witness worth supporting, I think.

Lastly, I will give big comment votes out to anyone who can replace these fucking BEEM functions with working Condenser ones!

Unless you want to build your own transaction signing, using a library like BEEM is ok.
I just avoid BEEM's higher level object stuff and stick to the underlying core functions.

I just hope the functions in that library don't suddenly stop working due to changes made by the developers. I know @sagarkothari88 uses Javascript for his routines, but how about the vote method?

Hello @slobberchops
Is that a question for me?
We are working on integrating Post Details, Vote, Comment within HiFind App.

Is that a question for me?

It was, care to share your vote function?

Loading...
from beem import Hive

hive = Hive(keys=['postingkey'])
hive.vote(weight=weight, account=account, identifier=authorperm)

That looks very simple, will give it a try... thanks.

I just hope the functions in that library don't suddenly stop working due to changes made by the developers.

I think you misunderstand.
BEEM is abandoned. There will be no changes.
Even if there were any - it's on github and you can always clone into an older version - the one that was working for you.

As long as there are no significant changes to how Hive nodes work, it will keep working, especially if you stick to the core functions, like I showed above.
Problematic with BEEM are the more abstract, higher level functions - some of them broke, when Hive changed.

The core features still work all the same and never changed since block 0.

I mean the HIVE developers, not @holger80. His API is reliant on the base infrastructure code being as it was (3 years ago). Am I getting this wrong...?

Hive's core features still work all the same and never changed since the first block, 8 years ago.

Likewise, BEEM's core functions (inherited from Piston) also never changed for those 8 years.

If you stay away from the higher level, abstract classes of BEEM, or at least use them consciously, you can probably use it forever.

OK,... I was under the impression some BEEM functions might stop working due to HIVE tinkering.., good to know.

Loading...
Loading...

everyone knows v.1.0 of anything does not work

But that is where you start :), I never could start even. May be I should look at the APIs again.

Updating BEEM had been on my list of things to do a few years ago when I was working with Python more frequently, but these days I'm more closely working with C# and JS so the 'extra practice' of getting into the weeds of understanding BEEM hasn't been high on my to-do list as a result. Maybe one day I'll cycle back to that but a few folks have forked the library already and haven't made much progress it seems so we may see this library slowly move more and more to only working on core functions and nothing else.

Delegated: 4,046,288 HP
Search
@buildawhale 2,308,692 HP Sep 29, 2017
@ocdb 1,171,244 HP May 25, 2018
@usainvote 566,245 HP Aug 16, 2020
@blocktrades.spk 106 HP Aug 8, 2022
Received: 54,605 HP
@kriborin 18,559 HP Aug 9, 2017
@kevtorin 18,559 HP Aug 9, 2017
@lessys 17,093 HP Aug 9, 2017
@aprendizinfinito 129 HP Mar 11, 2022
@klinckify 111 HP Apr 19, 2021
@rt-international 109 HP Dec 14, 2023
@augusto2021 11 HP Dec 22, 2021
@spearhead1976 11 HP Nov 20, 2022
@titovieira 10 HP 5 days ago
@realazazel 4 HP Jun 15, 2020
@stunod 4 HP Feb 8, 2022
@pumpkinmimi 2 HP Oct 15, 2021
@logiczombie 1 HP Dec 24, 2021
@africka 1 HP May 12, 2020

https://peakd.com/@blocktrades/wallet