Skip to content

Support to Retry on login, when fails#108

Open
nimitbhardwaj wants to merge 1 commit intoalthonos:masterfrom
nimitbhardwaj:retryOnLogin
Open

Support to Retry on login, when fails#108
nimitbhardwaj wants to merge 1 commit intoalthonos:masterfrom
nimitbhardwaj:retryOnLogin

Conversation

@nimitbhardwaj
Copy link

This is a small change, just added an option --try-count NUM, -c NUM, which says, that the program will try NUM times(with default = 3), if login process fails, after NUM times, the program will exit.

Just a beginner PR, when wandering around code.

@althonos
Copy link
Owner

althonos commented Nov 6, 2017

Hi there, welcome on board ! This is a nice idea, so I thing I'll merge once we fix the ongoing issues.

Unfortunately in the current state, the edits make InstaLooter always ask for a username, which is not what we want. I'm gonna push some fixes to your branch so that it works as expected.

In the meantime, please check the comments on the review, there are a few things you can probably fix yourself 😉

-W WARNINGCTL Change warning behaviour (same as python -W).
[default: default]
--try-count NUM, -c NUM Do the login process NUM times
[default: 3]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be moved to the Options - Credentials section !

if i != int(args['--try-count']) - 1:
console.warn('Wrong Username or Password')
continue
console.error(str(ve) + ', the number of tries exceeded')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just show the message here, the ValueError text is not needed since it can be displayed with --traceback if needed.

if args["--traceback"]:
traceback.print_exc()
return 1
for i in range(int(args['--try-count'])):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block can be rewritten this way (with less tests / local variables):

        args['--try-count'] = int(args['--try-count'])
        while args['--try-count']:
            try:
                args['--username'] = six.moves.input('Username: ')
                login(InstaLooter(), args)
                return 0
            except ValueError as ve:
                args['--try-count'] -= 1
                console.warn('Wrong Username or Password')
                if args["--traceback"]:
                    traceback.print_exc()
        return 1

@althonos
Copy link
Owner

althonos commented Nov 6, 2017

And by the way, don't be shy and add your name here 😄

@nimitbhardwaj
Copy link
Author

OKs, thanks I make the adjustments and commit again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pre-v1 relates to pre-v1 code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants