@@ -35,12 +35,11 @@ def check_update(forced=False):
3535 r = requests .get ("https://pypi.python.org/pypi/keep/json" ).json ()
3636 version = r ['info' ]['version' ]
3737 curr_version = about .__version__
38- if version != curr_version :
38+ if version > curr_version :
3939 click .secho ("Keep seems to be outdated. Current version = "
4040 "{}, Latest version = {}" .format (curr_version , version ) +
4141 "\n \n Please update with " , bold = True , fg = 'red' )
42- click .secho ("\t pip --no-cache-dir install -U keep==" + str (version ), fg = 'green' )
43- sys .exit (0 )
42+ click .secho ("\t pip3 --no-cache-dir install -U keep==" + str (version ), fg = 'green' )
4443
4544
4645def first_time_use (ctx ):
@@ -52,16 +51,14 @@ def first_time_use(ctx):
5251
5352 os .mkdir (dir_path )
5453
55- register ()
54+ # register()
5655 sys .exit (0 )
5756
5857
5958def list_commands (ctx ):
6059 table_data = [['Command' , 'Description' , 'Alias' ]]
6160 commands = read_commands ()
6261
63- print (type (commands ))
64-
6562 for cmd , fields in commands .items ():
6663 table_data .append (['$ ' + cmd , fields ['desc' ], fields ['alias' ]])
6764
@@ -119,52 +116,52 @@ def pull(ctx, overwrite):
119116 click .echo ("Local database successfully updated." )
120117
121118
122- def register ():
123-
124- if not os .path .exists (dir_path ):
125- click .secho ("\n [CRITICAL] {0} does not exits.\n Please run 'keep init',"
126- " and try registering again.\n " .format (dir_path ),
127- fg = "red" , err = True )
128- sys .exit (1 )
129-
130- # User may not choose to register and work locally.
131- # Registration is required to push the commands to server
132- if click .confirm ('Proceed to register?' , abort = True , default = True ):
133- # Verify for existing user
134- click .echo ("Your credentials will be saved in the ~/.keep directory." )
135- email = click .prompt ('Email' , confirmation_prompt = True )
136- json_res = {'email' : email }
137- click .echo ('Verifying with existing users...' )
138- r = requests .post ('https://keep-cli.herokuapp.com/check-user' , json = json_res )
139- if r .json ()['exists' ]:
140- click .secho ('User already exists !' , fg = 'red' )
141- email = click .prompt ('Email' , confirmation_prompt = True )
142- json_res = {'email' : email }
143- r = requests .post ('https://keep-cli.herokuapp.com/check-user' , json = json_res )
144- # Generate password for the user
145- chars = string .ascii_letters + string .digits
146- password = '' .join (random .choice (chars ) for _ in range (255 ))
147- credentials_file = os .path .join (dir_path , '.credentials' )
148- credentials = {
149- 'email' : email ,
150- 'password' : password
151- }
152- click .secho ("Generated password for " + email , fg = 'cyan' )
153- # Register over the server
154- click .echo ("Registering new user ..." )
155- json_res = {
156- 'email' : email ,
157- 'password' : password
158- }
159- r = requests .post ('https://keep-cli.herokuapp.com/register' , json = json_res )
160- if r .status_code == 200 :
161- click .secho ("User successfully registered !" , fg = 'green' )
162- # Save the credentials into a file
163- with open (credentials_file , 'w+' ) as f :
164- f .write (json .dumps (credentials ))
165- click .secho (password , fg = 'cyan' )
166- click .secho ("Credentials file saved at ~/.keep/.credentials.json" , fg = 'green' )
167- sys .exit (0 )
119+ # def register():
120+
121+ # if not os.path.exists(dir_path):
122+ # click.secho("\n[CRITICAL] {0} does not exits.\nPlease run 'keep init',"
123+ # " and try registering again.\n".format(dir_path),
124+ # fg="red", err=True)
125+ # sys.exit(1)
126+
127+ # # User may not choose to register and work locally.
128+ # # Registration is required to push the commands to server
129+ # if click.confirm('Proceed to register?', abort=True, default=True):
130+ # # Verify for existing user
131+ # click.echo("Your credentials will be saved in the ~/.keep directory.")
132+ # email = click.prompt('Email', confirmation_prompt=True)
133+ # json_res = {'email': email}
134+ # click.echo('Verifying with existing users...')
135+ # r = requests.post('https://keep-cli.herokuapp.com/check-user', json=json_res)
136+ # if r.json()['exists']:
137+ # click.secho('User already exists !', fg='red')
138+ # email = click.prompt('Email', confirmation_prompt=True)
139+ # json_res = {'email': email}
140+ # r = requests.post('https://keep-cli.herokuapp.com/check-user', json=json_res)
141+ # # Generate password for the user
142+ # chars = string.ascii_letters + string.digits
143+ # password = ''.join(random.choice(chars) for _ in range(255))
144+ # credentials_file = os.path.join(dir_path, '.credentials')
145+ # credentials = {
146+ # 'email': email,
147+ # 'password': password
148+ # }
149+ # click.secho("Generated password for " + email, fg='cyan')
150+ # # Register over the server
151+ # click.echo("Registering new user ...")
152+ # json_res = {
153+ # 'email': email,
154+ # 'password': password
155+ # }
156+ # r = requests.post('https://keep-cli.herokuapp.com/register', json=json_res)
157+ # if r.status_code == 200:
158+ # click.secho("User successfully registered !", fg='green')
159+ # # Save the credentials into a file
160+ # with open(credentials_file, 'w+') as f:
161+ # f.write(json.dumps(credentials))
162+ # click.secho(password, fg='cyan')
163+ # click.secho("Credentials file saved at ~/.keep/.credentials.json", fg='green')
164+ # sys.exit(0)
168165
169166
170167def remove_command (cmd ):
0 commit comments