def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print('Found {} results.'.format(len(results)))

                for r in results:
                    print('{} -- {}'.format(r.Year, r.Title))

        # always except errors from most specific to least specific order
        # this is to avoid catching yourself excepting any error, with a generic message, before you except
        # a specific error
        except requests.exceptions.ConnectionError as ce:
            print(
                'There was a problem communicating with the server. Connection failed.'
            )
        except ValueError as ve:
            print('Please enter a valid search string.')
        except KeyError as ke:
            print('Your search term returned zero results.')
        except Exception as x:
            print("That didn't work: {}".format(type(x)))

    print('Exiting...')
Beispiel #2
0
def search_event_loop():
    search = "ONCE_THROUGH_LOOP"

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print("{} - - {}".format(r.Year, r.Title))

                # print(client.perform_search())
                print(client.perform_search())
        except requests.exceptions.ConnectionError:
            print("Cannot search, network is down.")
        except ValueError as ve:
            print("ERROR, your search entry is invalid: {}".format(ve))
        except Exception as x:
            print("ERROR: {}".format(x))

    print('exiting...')
Beispiel #3
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(r.Year, r.Title))
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, connection error.')
        except ValueError as ve:
            print('ERROR: Your search string is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))
    print('exiting...')
Beispiel #4
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print(f'Found {len(results)} results.')
                for r in results:
                    print(f'{r.year} — {r.title}')
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, you network is down')
        except ValueError as ve:
            print(f'ERROR: Your search string is invalid: {ve}')
        except Exception as x:
            print(f'ERROR: {type(x)}')

    print('exiting...')
Beispiel #5
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title to search ("x" to exit): ')
            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()
                print("Found {} results".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(r.Year, r.Title))
        except requests.exceptions.ConnectionError as ce:
            print('ERROR: Can\'t reach the network')
            print(ce)
        except ValueError as ve:
            print('ERROR: Your search string is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))

    print('exiting . . . ')
Beispiel #6
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))
        except requests.exceptions.ConnectionError:
            print('Error: Your network connection appears down.')
        except ValueError as ve:
            print('Error: Invalid search string. {}'.format(ve))
        except Exception as x:
            print("This went wrong: {}".format(x))
    print('exiting')
Beispiel #7
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)
                #client.perform_search())
                results = client.perform_search()
                print('Found {} results.'.format(len(results)))
                for r in results:
                    print('{}--{}'.format(r.Year, r.Title))
        except requests.exceptions.ConnectionError:
            print('ERROR: Your network is down.')
        except ValueError as ve:
            print('ERROR: Search string is invalid: {} '.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))

    print('exiting...')
Beispiel #8
0
def search_event_loop():
    search_text = "ONCE_THROUGH_LOOP"

    while search_text != 'x':
        try:
            search_text = input('Title search text (x to exit): ')

            if search_text != 'x':
                client = MovieClient(search_text)

                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, your network is down.')
        except ValueError as ve:
            print('ERROR: Your search text is invalid: {}'.format(ve))
        except Exception as x:
            print('That did not work: {}'.format(x));

    print('exiting...')
Beispiel #9
0
def search_event_loop():
    search = None

    while search != 'x':
        try:
            search = input('What are you seeking (x for exit): ')

            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()

                print('Found {} results'.format(len(results)))

                for r in results:
                    print('{} --- {}'.format(r.Year, r.Title))

        except requests.exceptions.ConnectionError as ce:
            print('ERROR: Network is down.')
        except KeyError as ve:
            print('ERROR: Search string is invalid {}'.format(ve))
        except Exception as x:
            print('Ah, something goes wrong. ERROR: {}'.format(x))

    print('exiting…')
Beispiel #10
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                # print(client.perform_search())
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))

        except requests.exceptions.ConnectionError:
            print('ERROR: Unable to connect to network.')
        except ValueError as ve:
            print('ERROR: Your search is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))

    print('exiting...')