minds-ai / zoom-drive-connector

Automatically uploads Zoom meeting recordings to Google Drive.
Other
33 stars 8 forks source link

Handle broken network connectivity #4

Closed jbedorf closed 5 years ago

jbedorf commented 6 years ago

When connections fail it creates exceptions that propagate until main and then kill the running program. Should put main loop in a try-except structure to handle this more gracefully.

Also figure out why upload is called when the first exception came from the download/zoom part.


HTTPSConnectionPool(host='api.zoom.us', port=443): Max retries exceeded with url: /v2/meetings/<ID>/recordings?access_token=<token> (Caused by NewConnectionError('<urllib3.connectio
n.VerifiedHTTPSConnection object at 0x7f5b7d9083c8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/httplib2/__init__.py", line 1187, in _conn_request
    conn.connect()
  File "/usr/local/lib/python3.5/dist-packages/httplib2/__init__.py", line 999, in connect
    address_info = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 113, in <module>
    schedule.run_pending()
  File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 493, in run_pending
    default_scheduler.run_pending()
  File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 78, in run_pending
    self._run_job(job)
  File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 131, in _run_job
    ret = job.run()
  File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 411, in run
    ret = self.job_func()
  File "main.py", line 57, in all_steps
    upload(download_files, config.drive_conf)
  File "main.py", line 78, in upload
    drive = DriveAPI("", drive_conf.key, drive_conf.secret, drive_conf.folder_id)
  File "/app/drive/drive_api.py", line 33, in __init__
    self.setup()
  File "/app/drive/drive_api.py", line 46, in setup
    self._service = apiclient.discovery.build('drive', 'v3', http=creds.authorize(httplib2.Http()))
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/discovery.py", line 222, in build
    requested_url, discovery_http, cache_discovery, cache)
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/discovery.py", line 269, in _retrieve_discovery_doc
    resp, content = http.request(actual_url)
  File "/usr/local/lib/python3.5/dist-packages/oauth2client/transport.py", line 175, in new_request
    redirections, connection_type)
  File "/usr/local/lib/python3.5/dist-packages/oauth2client/transport.py", line 282, in request
    connection_type=connection_type)
  File "/usr/local/lib/python3.5/dist-packages/httplib2/__init__.py", line 1514, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python3.5/dist-packages/httplib2/__init__.py", line 1264, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/local/lib/python3.5/dist-packages/httplib2/__init__.py", line 1194, in _conn_request
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at www.googleapis.com
jbedorf commented 6 years ago

I'm unable to reproduce this in the latest code version. Will see how it behaves after a couple of weeks of running.