Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not download from Google #46

Closed
powtac opened this issue Dec 3, 2014 · 6 comments
Closed

Can not download from Google #46

powtac opened this issue Dec 3, 2014 · 6 comments

Comments

@powtac
Copy link
Contributor

powtac commented Dec 3, 2014

When I run sudo babelish csv2strings -i "iOS_Translations" --fetch --verbose I get a 400 error from Google.

Fetching csv file iOS_Translations from Google Drive
/Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/session.rb:472:in `request': Response code 400 for get https://docs.google.com/spreadsheets/d/14njfggrCyBliasdfg0yzf81tC7JWghf0QwH3dfg5fISM/export?usp=docslist_api&gid=0&format=csv: <!DOCTYPE html> [html message] </html>
    from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:150:in `export_as_string'
    from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:173:in `block in export_as_file'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:36:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:36:in `open'
    from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:172:in `export_as_file'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:29:in `download_spreadsheet'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:20:in `block in download'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `each_with_index'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `download'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:100:in `download'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:116:in `csv2base'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:34:in `block (2 levels) in <class:Commandline>'
    from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/bin/babelish:6:in `<top (required)>'
    from /usr/bin/babelish:23:in `load'
    from /usr/bin/babelish:23:in `<main>'

The funny thing is, when I change the filename to a not existing file like, "iOS_Translations X" the output is Fetching csv file iOS_Translations X from Google Drive Could not download the requested file: iOS_Translations X

So it looks like I set up the token thing correctly.

@powtac
Copy link
Contributor Author

powtac commented Dec 3, 2014

I ran the rake test:

sudo rake test
Password:
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I"lib:test" -I"/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib" "/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/babelish/commands/test_command_android2csv.rb" "test/babelish/commands/test_command_csv2android.rb" "test/babelish/commands/test_command_csv2strings.rb" "test/babelish/commands/test_command_strings2csv.rb" "test/babelish/test_android2csv.rb" "test/babelish/test_base2csv.rb" "test/babelish/test_bins.rb" "test/babelish/test_commandline.rb" "test/babelish/test_csv2android.rb" "test/babelish/test_csv2base.rb" "test/babelish/test_csv2json.rb" "test/babelish/test_csv2php.rb" "test/babelish/test_csv2strings.rb" "test/babelish/test_json2csv.rb" "test/babelish/test_php2csv.rb" "test/babelish/test_strings2csv.rb" "test/babelish/test_xcode_macros.rb" 
Loaded suite /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_test_loader
Started
........Creating translations.csv
Done
.[["app_name", "action_greetings", "ANOTHER_STRING", "empty"], {"test/data/android.xml"=>{"app_name"=>"android2csv", "action_greetings"=>"Hello", "ANOTHER_STRING"=>"testEN", "empty"=>""}}]
.Creating translations.csv
Done
.Creating myfile.csv
Done
.Creating enfr.csv
Done
.Done
....Created 1 files.
List of created files:
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/en.lproj/Localizable.strings
.Fetching csv file my_strings from Google Drive

1. Open this page:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=asdf0-egr1f18o96acjjvpadfo1d.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive%20https://spreadsheets.google.com/feeds/%20https://docs.google.com/feeds/%20https://docs.googleusercontent.com/

2. Enter the authorization code shown in the page: 4/AdfgmuYqKasdf3autaLPhmpAg9H3df_k.0h-WidOIE80fgfg038sCsdfKAwilAI
Could not download the requested file: my_strings
F
===============================================================================
Failure:
test_csv2strings_with_google_doc(TestBins)
/Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/test/babelish/test_bins.rb:9:in `test_csv2strings_with_google_doc'
      6:     assert_nothing_raised do
      7:       system("./bin/babelish csv2strings --fetch --filename my_strings --langs English:en")
      8:     end
  =>  9:     assert_equal $?.exitstatus, 0
     10:   end
     11: 
     12:   def test_csv2strings_with_google_doc_missing_langs
<1> expected but was
<0>

diff:
? 1
? 0
===============================================================================
Fetching csv file my_strings from Google Drive
Could not download the requested file: my_strings
...Created 2 files.
List of created files:
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/values-en/strings.xml
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/values-fr/strings.xml
.Created 2 files.
List of created files:
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/mynewlocation/values-en/strings.xml
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/mynewlocation/values-fr/strings.xml
...............Created 1 files.
List of created files:
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/en.lproj/Localizable.strings
generating macros
.Created 1 files.
List of created files:
- /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/en.lproj/Localizable.strings
.Fetching csv file my_strings from Google Drive
Could not download the requested file: my_strings
F
===============================================================================
Failure:
  Exception raised:
  SystemExit(<exit>)
test_csv2strings_with_fetch_google_doc(TestCSV2StringsCommand)
/Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/test/babelish/commands/test_command_csv2strings.rb:42:in `test_csv2strings_with_fetch_google_doc'
     39:       :langs => {"English" => "en", "French" => "fr"},
     40:       :fetch => true
     41:     }
  => 42:     assert_nothing_raised do
     43:       Commandline.new([], options).csv2strings
     44:     end
     45: 
===============================================================================
Fetching csv file my_strings from Google Drive
Could not download the requested file: my_strings


Finished in 21.562059 seconds.

41 tests, 53 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.122% passed

1.90 tests/s, 2.46 assertions/s
[Coveralls] Outside the Travis environment, not sending data.
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib" "/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/babelish/commands/test_command_android2csv.rb" "test/babelish/commands/test_command_csv2android.rb" "test/babelish/commands/test_command_csv2strings.rb" "test/babelish/commands/test_command_strings2csv.rb" "test/babelish/test_android2csv.rb" "test/babelish/test_base2csv.rb" "test/babelish/test_bins.rb" "test/babelish/test_commandline.rb" "test/babelish/test_csv2android.rb" "test/babelish/test_csv2base.rb" "test/babelish/test_csv2json.rb" "test/babelish/test_csv2php.rb" "test/babelish/test_csv2strings.rb" "test/babelish/test_json2csv.rb" "test/babelish/test_php2csv.rb" "test/babelish/test_strings2csv.rb" "test/babelish/test_xcode_macros.rb" ]

Tasks: TOP => test
(See full trace by running task with --trace)

@netbe netbe closed this as completed Dec 4, 2014
@powtac
Copy link
Contributor Author

powtac commented Dec 4, 2014

This was NOT solved by deleting the .babelish.token file! I only discovered that functionality while debugging.

Please reopen this issue.

@powtac
Copy link
Contributor Author

powtac commented Dec 4, 2014

This was NOT solved by deleting the .babelish.token file! I only discovered that functionality while debugging.

Please reopen this issue.

I found the solution

Problem

The Google Drive file I used was the "test_data_multiple_langs.csv" file from the examples. I uploaded it to Google Drive and converted it to a Google Spreadsheet file. But somehow this seems to break the babelish or Google Drive and throws this 400 error (which does not make sense here and confused me).

Solution

Create a blank Google Spreadsheet file and use that, don't upload a csv file.

@netbe
Copy link
Owner

netbe commented Dec 4, 2014

Interesting, I'll have a look when possible, but probably related to https://github.com/gimite/google-drive-ruby

@netbe netbe reopened this Dec 4, 2014
@powtac
Copy link
Contributor Author

powtac commented Dec 4, 2014

I think it is more related to Google than the drive-ruby thing. Google returns wrong information for those kinds of files.

Anyway I will open a ticket at google-drive-ruby

@powtac
Copy link
Contributor Author

powtac commented Dec 4, 2014

See gimite/google-drive-ruby#122

@powtac powtac closed this as completed Dec 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants