【问题标题】:Using googlecl inside Python script to d/l Google doc在 Python 脚本中使用 googlecl 来 d/l Google doc
【发布时间】:2012-11-03 02:07:48
【问题描述】:

subprocess.check_output(('/Applications/googlecl-0.9.13/build/scripts-2.7/google', 'docs', 'get', r'"重新评估请求"', r'--format', 'csv', r'/Users/myaccount/Desktop'), shell=True)

此代码不会拉下文档,但运行相同的行将在终端内工作。它可能没有时间完成?从命令行运行它需要一段时间。

有一个 Python 错误: “回溯(最近一次通话最后一次): 文件“/Users/myaccount/Desktop/reassess2.py”,第 17 行,在 subprocess.call('google docs get "Reassesment Request" --format csv /Users/myaccount/Desktop') 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第 493 行,调用中 返回 Popen(*popenargs, **kwargs).wait() init 中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第 679 行 读错,写错) _execute_child 中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第 1249 行 引发 child_exception OSError: [Errno 2] 没有这样的文件或目录"

当我尝试在 OSX 脚本中运行它时,我遇到了类似的问题: 当我运行 shell 脚本(运行上面的命令行)时,我得到: ?/Users/myaccount/Desktop/ReScript.sh ;出口; .csvloading 重新评估请求到 /users/myaccount/Desktop 登出

[处理完成]", 但实际上并没有下载任何文件。

OSX 山狮; 0.9.13 厘升; 2.0.17 gdata(我认为 - 不是最新的,而是与 cl 一起使用的)

感谢您的帮助!

【问题讨论】:

    标签: python googlecl


    【解决方案1】:

    Google CL 几乎即将淘汰,而 Google Drive 的新表单更新已经打破了这些类型的操作。我使用 Gdata 作为解决方法有一段时间了,但如果有人尝试使用其中任何一个并偶然发现这一点,这是当前最好的答案:Gspread。它安装简单(不像其他版本兼容性问题),需要更少的代码,而且速度更快。

    使用 Gspread,此代码将替换为:

    username = 'jimjam@gmail.com'
    password = 'bwdfsdfsafadlhsw'
    sheetname = "Reassessment Requesttemp"
    
    client = gspread.login(username, password)
    spreadsheet = client.open(sheetname)
    
    worksheet = spreadsheet.sheet1
    contents = worksheet.get_all_values()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多