<s> import sys <EOL> import samples_common <EOL> from matrix_client . client import MatrixClient <EOL> from matrix_client . api import MatrixRequestError <EOL> from requests . exceptions import MissingSchema <EOL> host , username , password = samples_common . get_user_details ( sys . argv ) <EOL> client = MatrixClient ( host ) <EOL> try : <EOL> client . login_with_password ( username , password ) <EOL> except MatrixRequestError as e : <EOL> print ( e ) <EOL> if e . code == <NUM_LIT> : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:4> ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:3> ) <EOL> except MissingSchema as e : <EOL> print ( "<STR_LIT>" ) <EOL> print ( e ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> user = client . get_user ( client . user_id ) <EOL> if len ( sys . argv ) < <NUM_LIT:5> : <EOL> print ( "<STR_LIT>" % user . get_display_name ( ) ) <EOL> displayname = input ( "<STR_LIT>" ) <EOL> else : <EOL> displayname = sys . argv [ <NUM_LIT:4> ] <EOL> try : <EOL> user . set_display_name ( displayname ) <EOL> except MatrixRequestError as e : <EOL> print ( e ) <EOL> sys . exit ( <NUM_LIT:11> ) </s>
