Пример #1
0
def startsession():
    """Saves your login session in the app config folder"""

    user_id = click.prompt("User ID >")
    password = click.prompt("Password >", hide_input=True)
    z = Zerodha()
    z.user_id = user_id
    z.password = password
    j = z.login_step1()
    if j['status'] == 'error':
        click.echo(click.style("Error: {}".format(j['message']), fg="red"))
        return
    z.twofa = click.prompt("Pin >", hide_input=True)
    j = z.login_step2(j)
    if j['status'] == 'error':
        click.echo(click.style("Error: {}".format(j['message']), fg="red"))
        return
    z.enc_token = z.r.cookies['enctoken']
    p = z.profile()

    click.echo(
        click.style("Logged in successfully as {}".format(p['user_name']),
                    fg='green'))
    with open(os.path.join(app_dir, session_file), "wb") as fp:
        pickle.dump(z.reqsession, fp)
    click.echo("Saved session successfully")
Пример #2
0
 def test_login_step1_invalid_creds(self):
     z = Zerodha("randomcreds", "randomstring123324", "2231212")
     step1_result = z.login_step1()
     self.assertEqual(step1_result['status'], 'error')
     z.close()