【发布时间】:2018-01-06 00:54:43
【问题描述】:
我正在尝试使用 DS18b20 温度传感器设置温度记录器。我一直按照“Raspberry Pi projects for Dummies”一书第 10 章中的步骤进行操作。在 Googledocs 中创建温度记录电子表格后,下一章的下一步是将我的 Raspberry Pi 记录的数据存储到保存在 GoogleDocs 上的温度记录电子表格中。我创建了电子表格,下载了必备程序 templogger_gdocs.py、ds18b20.py 和 gdocs.py。我运行了 emplogger_gdocs.py 程序并输入了客户端 ID、密码和电子表格密钥并保存了更改。我已经仔细检查了错别字。然后我应该输入“python templogger_gdocs.py,它应该带我到 www.google.com/device 并给我一个代码,但我得到了以下信息:
**Traceback (most recent call last):
File "templogger_gdocs.py", line 58, in <module>
main()
File "templogger_gdocs.py", line 48, in main
LogRowInGDocSpreadsheet(client_id, client_secret, spreadsheet_key, headings, temperature, unit_of_measure);
File "/root/rpipfd/gdocs.py", line 14, in LogRowInGDocSpreadsheet
oauth = gaugette.oauth.OAuth(CLIENT_ID, CLIENT_SECRET)
AttributeError: 'module' object has no attribute 'OAuth'
我的问题是如何获取获取代码所需的 OAuth 模块?
从我过去 2 天的研究来看,我似乎也需要一个令牌。我有这个,但我不知道在哪里输入它。
下面(以 !/usr/bin/env.. 开头)是我运行 templogger_gdocs.py 程序时得到的。
!/usr/bin/env python
"""
Rapsberry Pi Projects For Dummies: temperature logger to google docs spreadsheet
For the Raspberry Pi
"""
import subprocess
import time
from ds18b20 import GetTemperature
from gdocs import LogRowInGDocSpreadsheet
ds18b20_dir = "XXXXX"
client_id = "XXXXX"
client_secret = "XXXXX"
spreadsheet_key = "XXXXX"
fahrenheit = False
headings = ["Temperature", "Date", "Unit"] #column headings can't have
spaces
def main():
# This is the main routine of the program
# set how long to wait between logs
poll_interval = 5
if fahrenheit:
unit_of_measure = 'F'
else:
unit_of_measure = 'C'
我感觉它需要更新。这本书是 2015 年出版的,可能已经过时了。现在好像有一个 OAuth2 和一个 json 令牌。
【问题讨论】:
标签: python oauth raspberry-pi