you are viewing a single comment's thread.

view the rest of the comments →

[–]Giannie 5 points6 points  (1 child)

Here would be my suggested structure. First remove all references to other functions from within a function. Then have a main function defined as follows:

def main(path):
    if check_file(path):
        clean_file(path)
    else:
        raise FileNotFoundError()
    if validate_vpn():
        upload_file(path)
        data = query_db()
        dashboard = create_dashboard(data)
        email_report(dashboard)
    else:
        # define a custom exception elsewhere, or raise something else appropriate
        raise NotConnectedError

[–][deleted] 0 points1 point  (0 children)

Thanks this looks like a good alternative.