examples/pb_addNewServer.py
def getLogin(filename, user, passwd):
    '''
    write user/passwd to login file or get them from file.
    This method is not Py3 safe (byte vs. str)
    '''
    if filename is None:
        return (user, passwd)
    if os.path.exists(filename):
        print("Using file {} for Login".format(filename))
        with open(filename, "r") as loginfile:
            encoded_cred = loginfile.read()
            decoded_cred = b64decode(encoded_cred)
            login = decoded_cred.split(':', 1)
            return (login[0], login[1])
    else:
        if user is None or passwd is None:
            raise ValueError("user and password must not be None")
        print("Writing file {} for Login".format(filename))
        with open(filename, "w") as loginfile:
            encoded_cred = b64encode(user+":"+passwd)
            loginfile.write(encoded_cred)
        return (user, passwd)
def getLogin(filename, user, passwd):
    '''
    write user/passwd to login file or get them from file.
    This method is not Py3 safe (byte vs. str)
    '''
    if filename is None:
        return (user, passwd)
    if os.path.exists(filename):
        print("Using file {} for Login".format(filename))
        with open(filename, "r") as loginfile:
            encoded_cred = loginfile.read()
            decoded_cred = b64decode(encoded_cred)
            login = decoded_cred.split(':', 1)
            return (login[0], login[1])
    else:
        if user is None or passwd is None:
            raise ValueError("user and password must not be None")
        print("Writing file {} for Login".format(filename))
        with open(filename, "w") as loginfile:
            encoded_cred = b64encode(user+":"+passwd)
            loginfile.write(encoded_cred)
        return (user, passwd)
def getLogin ( filename , user , passwd ) : if filename is None : return ( user , passwd ) if os . path . exists ( filename ) : print ( "Using file {} for Login" . format ( filename ) ) with open ( filename , "r" ) as loginfile : encoded_cred = loginfile . read ( ) decoded_cred = b64decode ( encoded_cred ) login = decoded_cred . split ( ':' , 1 ) return ( login [ 0 ] , login [ 1 ] ) else : if user is None or passwd is None : raise ValueError ( "user and password must not be None" ) print ( "Writing file {} for Login" . format ( filename ) ) with open ( filename , "w" ) as loginfile : encoded_cred = b64encode ( user + ":" + passwd ) loginfile . write ( encoded_cred ) return ( user , passwd )
write user/passwd to login file or get them from file.
    This method is not Py3 safe (byte vs. str)
write user / passwd to login file or get them from file . This method is not Py3 safe ( byte vs . str )