Exemple #1
0
def set_bank_account_login():
    """
    This will ask for a username and Password.
    The password will be retrieved via getpass lib.
    Requires the password length to be at least 5 characters.
    """

    # Getting the login name from a raw_input.
    obp_logger.info("get username")
    username = raw_input("Username: "******"username is set")

    # Now getting the password via getpass lib.
    obp_logger.info("get password")
    password = getpass.getpass()
    obp_logger.debug("password has set")

    # We know from the Web Page that we need at least 5 characters.
    # This will check for the right length of the password.
    obp_logger.debug("start while loop")
    while len(password) < 5:
        obp_logger.error("Password was not 5 character long")
        print "Password has to contain at least 5 letters"
        password = getpass.getpass()
        obp_logger.debug("Password has set")

    obp_logger.debug("Will return username: %s ,password is set" % username)
    # Return username and password.
    return username, password
Exemple #2
0
def check_for_existing_cache(cache_file):
    """This will check for a existing cache_file"""

    obp_logger.debug("checking for existing cache_file: %s" % cache_file)
    if os.path.exists(cache_file) == False:
        print "ERROR! - NO CACHE FILE!"
        obp_logger.error("ERROR! - NO CACHE FILE!")
        raise

    else:
        obp_logger.debug("cache file exist")
Exemple #3
0
def check_for_existing_csv(csv_file_path):
    """
    This function will check that the csv file exists.
    TODO:
        Increase the detail of this check, to ensure there
        really is a CSV file.
    """

    obp_logger.debug("checking if csv_file_path %s exists" % csv_file_path)
    if os.path.exists(csv_file_path) == False:
        print "ERROR! - NO CSV FILE!"
        obp_logger.error("ERROR! - NO CSV FILE!")
        raise

    else:
        obp_logger.debug("csv_file_path %s exist" % csv_file_path)
Exemple #4
0
def check_and_return_csv_file_name(path_to_saved_csv):
    """
    Check that there is only one csv file, and then return it.
    """

    obp_logger.debug("check and return filename")
    #obp_logger.debug("path_to_saved_csv is: %s" % path_to_saved_csv)
    #We expect that in the folder is only one file:
    csv_folder = os.listdir(path_to_saved_csv)
    # We expect only one file in this folder
    file_count = len(csv_folder)
    obp_logger.debug("File count in csv_folder: %s" % file_count)

    if file_count == 0:
        obp_logger.error("ERROR - We didn't get the CSV file.")
        print "ERROR - We didn't get the CSV file."
    elif file_count != 1:
        obp_logger.error("ERROR - We found too many files.")
        print "ERROR - We found too many files."

    obp_logger.debug("return csv_folder")
    return csv_folder[0]