Mercurial > hg > gcmultimerge
changeset 99:4b84bb5bb8b5
Make credential_file and secret_file arguments to gcm_get_credentials().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Oct 2016 13:07:24 +0300 |
parents | fe3bfabf0b5f |
children | b4058d935560 |
files | multimerge.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/multimerge.py Thu Oct 06 15:49:05 2016 +0300 +++ b/multimerge.py Mon Oct 10 13:07:24 2016 +0300 @@ -102,18 +102,18 @@ ## Function for handling Google API credentials -def gcm_get_credentials(mcfg): +def gcm_get_credentials(mcfg, credential_file, secret_file): try: - store = oauth2client.file.Storage(mcfg.credential_file) + store = oauth2client.file.Storage(credential_file) except Exception as e: - gcm_fatal(u"Failed to read credential file:\n{0}\n\nERROR: {1}\n".format(mcfg.credential_file, str(e))) + gcm_fatal(u"Failed to read credential file:\n{0}\n\nERROR: {1}\n".format(credential_file, str(e))) credentials = store.get() if not credentials or credentials.invalid: try: - flow = client.flow_from_clientsecrets(mcfg.secret_file, mcfg.scope) + flow = client.flow_from_clientsecrets(secret_file, mcfg.scope) except Exception as e: - gcm_fatal(u"Failed to fetch client secret:\n{0}\n\nERROR: {1}\n".format(mcfg.secret_file, str(e))) + gcm_fatal(u"Failed to fetch client secret:\n{0}\n\nERROR: {1}\n".format(secret_file, str(e))) flow.user_agent = mcfg.app_name credentials = tools.run_flow(flow, store, mcfg) @@ -441,7 +441,7 @@ ## Initialize and authorize API connection -credentials = gcm_get_credentials(cfg) +credentials = gcm_get_credentials(cfg, cfg.credential_file, cfg.secret_file) http = credentials.authorize(httplib2.Http()) service = discovery.build("calendar", "v3", http=http)