将csv上载到谷歌应用程序引擎时出错



我试图将csv文件上传到GAE,但出现错误。我正在关注这篇博客文章,并使用相同的yml文件。我可以下载数据,但上传命令给出以下错误:

C:UsersADMIN>appcfg.py upload_data --config_file=C:bulkconfig.yml --file
name=C:bulkdata.csv --url=http://encryptedsearch.appspot.com/remote_api --appl
ication=encryptedsearch --kind=Greeting
06:44 PM Uploading data records.
[INFO    ] Logging to bulkloader-log-20151206.184424
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
[INFO    ] Opening database: bulkloader-progress-20151206.184424.sql3
2015-12-06 18:44:24,763 INFO client.py:669 access_token is expired. Now: 2015-12
-06 13:44:24.763000, token_expiry: 2015-12-05 20:24:05
2015-12-06 18:44:25,891 INFO client.py:669 access_token is expired. Now: 2015-12
-06 13:44:25.891000, token_expiry: 2015-12-05 20:24:05
2015-12-06 18:44:26,576 INFO client.py:669 access_token is expired. Now: 2015-12
-06 13:44:26.577000, token_expiry: 2015-12-05 20:24:05
2015-12-06 18:44:27,687 INFO client.py:669 access_token is expired. Now: 2015-12
-06 13:44:27.687000, token_expiry: 2015-12-05 20:24:05
Traceback (most recent call last):
  File "C:Program Files (x86)Googlegoogle_appengineappcfg.py", line 133, in
<module>
    run_file(__file__, globals())
  File "C:Program Files (x86)Googlegoogle_appengineappcfg.py", line 129, in
run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 5469, in <module>
    main(sys.argv)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 5460, in main
    result = AppCfgApp(argv).Run()
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 3010, in Run
    self.action(self)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 5116, in __call__
    return method()
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 4919, in PerformUpload
    run_fn(args)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsap
pcfg.py", line 4803, in RunBulkloader
    sys.exit(bulkloader.Run(arg_dict, self._GetOAuth2Parameters()))
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsbu
lkloader.py", line 4349, in Run
    return _PerformBulkload(arg_dict, oauth2_parameters)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsbu
lkloader.py", line 4211, in _PerformBulkload
    loader.finalize()
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineextbulk
loadbulkloader_config.py", line 383, in finalize
    self.reserve_keys(self.keys_to_reserve)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginetoolsbu
lkloader.py", line 1211, in ReserveKeys
    datastore._GetConnection()._reserve_keys(ConvertKeys(keys))
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginedatastor
edatastore_rpc.py", line 2172, in _reserve_keys
    self._async_reserve_keys(None, keys).get_result()
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginedatastor
edatastore_rpc.py", line 2210, in _async_reserve_keys
    service_name=_DATASTORE_V4))
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginedatastor
edatastore_rpc.py", line 1341, in _make_rpc_call
    rpc = self._create_rpc(config, service_name)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappenginedatastor
edatastore_rpc.py", line 1236, in _create_rpc
    rpc = apiproxy_stub_map.UserRPC(service_name, deadline, callback)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineapiapip
roxy_stub_map.py", line 414, in __init__
    self.__rpc = CreateRPC(service, stubmap)
  File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineapiapip
roxy_stub_map.py", line 68, in CreateRPC
    assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "datastore_v4"

我正在将相同的文件上传回我用命令下载的数据存储:

appcfg.py download_data --config_file=C:bulkconfig.yml --filename=C:bulkdata.csv --kind=Greeting --url=http://encryptedsearch.appspot.com/remote_api --application=encryptedsearch

我的配置yml如下:

# Autogenerated bulkloader.yaml file.
# You must edit this file before using it. TODO: Remove this line when done.
# At a minimum address the items marked with TODO:
#  * Fill in connector and connector_options
#  * Review the property_map.
#    - Ensure the 'external_name' matches the name of your CSV column,
#      XML tag, etc.
#    - Check that __key__ property is what you want. Its value will become
#      the key name on import, and on export the value will be the Key
#      object.  If you would like automatic key generation on import and
#      omitting the key on export, you can remove the entire __key__
#      property from the property map.
# If you have module(s) with your model classes, add them here. Also
# change the kind properties to model_class.
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.api.datastore
- import: google.appengine.api.users
transformers:
- kind: Greeting
  connector: csv
  connector_options:
    # TODO: Add connector options here--these are specific to each connector.
  property_map:
    - property: __key__
      external_name: key
      import_transform: transform.key_id_or_name_as_string
    - property: content
      external_name: content
      # Type: String Stats: 7 properties of this type in this kind.
    - property: date
      external_name: date
      # Type: Date/Time Stats: 7 properties of this type in this kind.
      import_transform: transform.import_date_time('%Y-%m-%dT%H:%M:%S')
      export_transform: transform.export_date_time('%Y-%m-%dT%H:%M:%S')
    - property: name
      external_name: name
      # Type: String Stats: 7 properties of this type in this kind.

CSV文件内容:

content,date,name,key
Hi,2015-12-05T17:24:14,,ahFzfmVuY3J5cHRlZHNlYXJjaHIrCxIJR3Vlc3Rib29rIgdkZWZhdWx0DAsSCEdyZWV0aW5nGICAgICAgIAKDA
3rd,2015-12-05T17:30:04,,ahFzfmVuY3J5cHRlZHNlYXJjaHIrCxIJR3Vlc3Rib29rIgdkZWZhdWx0DAsSCEdyZWV0aW5nGICAgICA8ogKDA
2nd,2015-12-05T17:25:59,,ahFzfmVuY3J5cHRlZHNlYXJjaHIrCxIJR3Vlc3Rib29rIgdkZWZhdWx0DAsSCEdyZWV0aW5nGICAgICA5JEKDA

数据存储条目:

链接到图像

对于所有其他正在与同一问题作斗争的人。我发现除了在实际的client.py中注释这一行之外,没有其他解决方案。

解决方案:

  • 找到client.py文件(在我的情况下是../google-cloud-sdk/platform/google_cloud/lib/oauth2client/oauth2client/client.py
  • 导航到access_token_expired()方法
  • 注释以下代码:

    if now >= self.token_expiry:
        logger.info('access_token is expired. Now: %s, token_expiry: %s',
              now, self.token_expiry)
        return True
    

相关内容

  • 没有找到相关文章