From f30ef9d89fcb7c130dc21912af53434cae87bc3b Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Wed, 16 Aug 2017 14:56:08 -0500 Subject: [PATCH] Don't error out if the file isn't found. --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 70357b2..1a962e9 100755 --- a/main.py +++ b/main.py @@ -11,12 +11,17 @@ def no_credential(): lp = Launchpad.login_with('Mass package bug subscription adder', 'production', credential_save_failed=no_credential) teamtowrite = (input('What person/team would you like to use for this? (Launchpad ID) ')) -filepath = (input('Please specify the path of the input file: ')) -with open(filepath, "r") as ins: - filearray = [] - for line in ins: - filearray.append(line.strip()) +while True: + try: + filepath = (input('Please specify the path of the input file: ')) + with open(filepath, "r") as ins: + filearray = [] + for line in ins: + filearray.append(line.strip()) + break + except FileNotFoundError: + print("File not found.") for i in range(len(filearray)): print("Assigning:")