#NEWLINE# def do_configcmd( ) : #NEWLINE# #INDENT# 'Create an oauth token.  Write the username and token to the config\nfile.  Should be called the first time the application is executed.' #NEWLINE# dummy_validator = ( lambda x : True ) #NEWLINE# username = utils . read_user_input ( 'Username' , dummy_validator ) #NEWLINE# password = getpass . getpass ( 'Password:' ) #NEWLINE# client = Github ( username , password ) #NEWLINE# user = client . get_user ( ) #NEWLINE# authorization = user . create_authorization ( scopes = [ 'user' , 'repo' , 'gist' , 'delete_repo' ] , note = 'cligh' , note_url = 'https://github.com/CMB/cligh' ) #NEWLINE# config_parser = configparser . ConfigParser ( ) #NEWLINE# config_parser . add_section ( 'credentials' ) #NEWLINE# config_parser . set ( 'credentials' , 'username' , username ) #NEWLINE# config_parser . set ( 'credentials' , 'token' , authorization . token ) #NEWLINE# os . umask ( 63 ) #NEWLINE# with open ( get_config_filename ( ) , 'w' ) as f : #NEWLINE# #INDENT# config_parser . write ( f ) #NEWLINE# #UNINDENT# print ( 'cligh configured and authorized for use with github.' )