Instapy: Console Logging for Interact with User Followers

Created on 9 Jun 2018  路  8Comments  路  Source: timgrossmann/InstaPy

Expected Behavior

In prior versions of InstaPy, interaction with a Users Followers provided a console log of the aggregated total of all the interactions.

screen shot 2018-06-09 at 9 01 35 am

Current Behavior

In the current version of InstaPy, the console log only shows the total number of interactions.

screen shot 2018-06-09 at 9 02 44 am

Desired Behavior

Is it possible to revert back to the previous console logging format? It is helpful to see how effective each run is via the console summary.

Most helpful comment

@uluQulu after hitting send, I kind of figured your answer would be as such. I'll see what I can do.

All 8 comments

Good idea! @gitpatrickhub
Can you implement it?
If not, if I implement, can you PR it? 馃槒

@uluQulu I can try to implement it, but need a bit of guidance on where this part of the code is managed. Just let me know which you prefer. Thanks!

That's amazing! @gitpatrickhub
There is always only one optimal solution to problems try to find it, challenge yourself! ^.^

Hint:

  • Always see other people's code which is doing the same (_or similar_) thing you want to write. By this, I mean look at source files and see if such kind of code already exist to use quickly.
  • To write code in correct place, you must find where that correct place is, to do it, use "GO TO ROOT" idea, it is done by following every function call to until finds your correct place.

If you have any detailed question, feel free to ask.
Good luck!

@uluQulu after hitting send, I kind of figured your answer would be as such. I'll see what I can do.

Yes @gitpatrickhub 馃槄
It's because I am quite a self learner.

But I will share a few more tips to help you get started

  • There are existing lines to use in InstaPy class
    e.g.
self.logger.info('Liked: {}'.format(liked_img))
self.logger.info('Already Liked: {}'.format(already_liked))
self.logger.info('Commented: {}'.format(commented))
self.logger.info('Followed: {}'.format(followed))
self.logger.info('Inappropriate: {}'.format(inap_img))
self.logger.info('Not valid users: {}\n'.format(not_valid_users))

_Find and see those blocks and get only the lines which are needed. (e.g. you may not need liked_img counts)_

  • Find out where you will add those line blocks .
    _They are probably gonna be added to the end of the feature just before the last return value._

Sure, there are difficulties to get those values right away. Cos e.g. in features like interact_user_followers _likes_, _comments_ are handled by a separate function which does not return useful information like _liked_, _commented_, _inappropriate images_ counts, etc.

What you can do is to use class variables of those values.
The thing is at the start of the feature initialize those variables and at the end of the feature, take comparison to find out the fresh amounts spent inside that feature.
_e.g._

def interact_user_followers():
    ##ready to go state

    #initialize and store current amounts in variables at top of feature
    liked_img = self.liked_img

    ##do lots of stuff here

    ##it has done everything and ready to leave the feature (near last `return` value if any- some features do not have a return value)
    #get fresh amounts by comparing old and new variables
    like_img_new = self.liked_img - liked_img
    #print that new amount
    self.logger.info('Liked: {}'.format(liked_img))

    #do other remaining last steps and leave feature

That is a simple example for doing reports at the end of the feature, but by using that idea and such kind of comparison, your can add reports inside desired steps, too, _e.g._ reporting after interaction with each user's followers/following or some other iterated container, etc.

And I noticed there are other features also missing this report.
Those I noticed are interact_user_followers, interact_user_following, follow_user_followers, follow_user_following.
_It could be great to add this report to them all,,,_

Regards

@uluQulu Thanks for the added guidance, I am working on a solution now, just need to run some tests.

@uluQulu my initial tests look good for interact_user_followers. In process of copying solution to the other features now. What's the best practice on git for others to test my changes? Push changes to my fork of the repo?

Sounds fantastic, @gitpatrickhub!
I have less git knowledge but I would recommend this:

  • Finalize your work with your personal tests
  • Merge it into up-to-date fork of main repo and then PR it
  • So that other programmers can see the difference you have done and it will be so much better than tests
  • And yes anybody can download your fork and do self tests

That's how I do all time ^.^

Cheers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tibor picture tibor  路  3Comments

drcyber975 picture drcyber975  路  3Comments

CharlesCCC picture CharlesCCC  路  3Comments

converge picture converge  路  3Comments

Spyd3r0us picture Spyd3r0us  路  3Comments