import getpass


def get_opal_password(opal_password, password_file):
    """
    Retrieve the OPAL password form the user, either from the command line arguments, the file they specified or
      by asking them to input it
    :param opal_password: The actual password, if provided via the command line
    :param password_file: The file containing the password, if provided.
    :return: The password
    """
    if opal_password:
        return opal_password

    if password_file:
        with open(password_file, 'r') as fd:
            password = fd.readlines()[0].strip()
    else:
        password = getpass.getpass(str("Enter your OPAL password: "))

    return password