def getLogin(filename, user, passwd):
if filename is None:<EOL><INDENT>return (user, passwd)<EOL><DEDENT>if os.path.exists(filename):<EOL><INDENT>print("<STR_LIT>".format(filename))<EOL>with open(filename, "<STR_LIT:r>") as loginfile:<EOL><INDENT>encoded_cred = loginfile.read()<EOL>decoded_cred = b64decode(encoded_cred)<EOL>login = decoded_cred.split('<STR_LIT::>', <NUM_LIT:1>)<EOL>return (login[<NUM_LIT:0>], login[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if user is None or passwd is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>print("<STR_LIT>".format(filename))<EOL>with open(filename, "<STR_LIT:w>") as loginfile:<EOL><INDENT>encoded_cred = b64encode(user+"<STR_LIT::>"+passwd)<EOL>loginfile.write(encoded_cred)<EOL><DEDENT>return (user, passwd)<EOL><DEDENT>
write user/passwd to login file or get them from file.
This method is not Py3 safe (byte vs. str)