Получите больше деталей от исключения - PullRequest
0 голосов
/ 05 октября 2018

Попытка запуска таблицы Google образец приложения.

Получено исключение при загрузке учетных данных:

try:
    creds = store.get()
except Exception as e:
    print(e)
    print("exception end")

Странно то, что во время выполнения блока кода исключения была напечатана только строка _module.

Как понять, что именно былонеправильно?Что означает _module?

Весь код:

from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools

# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/spreadsheets.readonly'

# The ID and range of a sample spreadsheet.
SAMPLE_SPREADSHEET_ID = '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
SAMPLE_RANGE_NAME = 'Class Data!A2:E'

def main():

    print("starting")
    """Shows basic usage of the Sheets API.
    Prints values from a sample spreadsheet.
    """
    #store = file.Storage('token.json')
    store = file.Storage('D:\pyth_nonsens\workspace_python\PyhonTutorial\google\credentials.json')

    #store = file.Storage('My Project aaa-8102e33b9fef.json')
    try:
        creds = store.get()
    except Exception as e:
        print(e)
        print("exception end")

    if not creds or creds.invalid:
        flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
        creds = tools.run_flow(flow, store)
    service = build('sheets', 'v4', http=creds.authorize(Http()))

    # Call the Sheets API
    SPREADSHEET_ID = '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
    RANGE_NAME = 'Class Data!A2:E'
    result = service.spreadsheets().values().get(spreadsheetId=SPREADSHEET_ID,
                                                range=RANGE_NAME).execute()
    values = result.get('values', [])

    if not values:
        print('No data found.')
    else:
        print('Name, Major:')
        for row in values:
            # Print columns A and E, which correspond to indices 0 and 4.
            print('%s, %s' % (row[0], row[4]))



print(__name__)
if __name__ == 'test_spread':
    print("true")
    main()
...