Skip to content

script parameters#32

Merged
rishabhsingh971 merged 6 commits intomasterfrom
script-parameter
Oct 13, 2019
Merged

script parameters#32
rishabhsingh971 merged 6 commits intomasterfrom
script-parameter

Conversation

@rajat19
Copy link
Member

@rajat19 rajat19 commented Oct 9, 2019

Related Issue

Closes #23
Closes #24
Closes #28

Options to use while running script

Script hsc supports following options

  • help: -h or --help
  • username: -u or --username -> username of hackerrank profile
  • password: -p or --password -> password of hackerrank profile
  • limit: -l or --limit -> no. of solutions to be downloaded
  • config: -c or --config -> path of config file

Usage:
We can use above script helpers as

hsc -l 34 -p testpassword -u testuser

We can also use config file to download solutions
Let config file be /etc/user.yaml

username: testuser
hsc -c /etc/user.yaml -l 34 -p testpassword

@rajat19 rajat19 mentioned this pull request Oct 9, 2019
@rishabhsingh971 rishabhsingh971 added the enhancement New feature or request label Oct 10, 2019
hsc/crawler.py Outdated
print('Auth was unsuccessful')

limit = input('Enter limit needed to crawl: ')
limit = crawler.options.limit or crawler.get_number_of_submissions()
Copy link
Member

Choose a reason for hiding this comment

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

There's no need of requesting the number of submissions again, because we have stored the total number of submissions while authenticating the user. We can directly use crawler.total_submissions.

@rajatgoyal715
Copy link
Member

Testing Details:

Help

Screenshot from 2019-10-13 14-34-51

Config File

Screenshot from 2019-10-13 15-07-42

Username

Screenshot from 2019-10-13 14-34-15

Username, Password, Limit and Offset

Screenshot from 2019-10-13 14-39-04_censored

@rajatgoyal715
Copy link
Member

Issue Found

Description

When you pass wrong username and password either from the config file or from the command line, it will retry with those credentials only, because earlier when the credentials were being taken from the user, and if found wrong, then it used to ask the user again. But now it will go into an infinite loop (which can still be cancelled by pressing Ctrl + C), which is not the right way.

Reference Screenshot

Screenshot from 2019-10-13 14-37-02

Solution

We can check if the credentials are taken from either command line or config file, and accordingly terminate the program if auth was unsuccessful.

@rishabhsingh971
Copy link
Member

or we can just skip retry part now?

@rajatgoyal715
Copy link
Member

or we can just skip retry part now?

Making the changes in this PR only then.

Screenshot from 2019-10-13 15-31-33

@rishabhsingh971 rishabhsingh971 added this to the 1.2.0 milestone Oct 13, 2019
@rishabhsingh971 rishabhsingh971 merged commit 48e21c3 into master Oct 13, 2019
@rishabhsingh971 rishabhsingh971 deleted the script-parameter branch October 13, 2019 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow crawler to fetch all solutions CLI flag support Config file(s)

3 participants