jettero / googlecl

Automatically exported from code.google.com/p/googlecl
0 stars 0 forks source link

Problem of AttributeError: __len__ when invoking googlecl from Java by Jython #325

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Actually, I am not sure it's bug, what I don't know who I can turn to for help.

Problem: when service related problem will appear.

Environment: jvm 1.6, jython 2.5.1, googlecl latest from svn

Test source:
import org.python.util.PythonInterpreter;

public class Test {
public static void main(String[] args) {
    Properties postProperties = new Properties();
    postProperties.put("python.path", "./war/WEB-INF/google_cl/Lib.zip");

    PythonInterpreter.initialize(System.getProperties(), postProperties, new String[0]);
    PythonInterpreter interp = new PythonInterpreter();
    interp.execfile("./war/WEB-INF/google_cl/google.py");

}

}

Lib.zip contains all the python lib and googlecl related py files.

Result:

> help
Welcome to the Google CL tool!
  Commands are broken into several parts: 
    service, task, options, and arguments.
  For example, in the command
      "> picasa post --title "My Cat Photos" photos/cats/*"
  the service is "picasa", the task is "post", the single
  option is a title of "My Cat Photos", and the argument is the 
  path to the photos.

  The available services are 
'picasa', 'blogger', 'youtube', 'docs', 'contacts', 'calendar', 'finance'
  Enter "> help <service>" for more information on a service.
  Or, just "quit" to quit.
> help docs
Traceback (most recent call last):
  File "./war/WEB-INF/google_cl/google.py", line 495, in run_interactive
    run_once(options, args)
  File "./war/WEB-INF/google_cl/google.py", line 541, in run_once
    service_class, tasks, section_header = import_service(task_name)
  File "./war/WEB-INF/google_cl/google.py", line 381, in import_service
    service_module = __import__('googlecl.' + service + '.client',
  File "./war/WEB-INF/google_cl/google.py", line 381, in import_service
    service_module = __import__('googlecl.' + service + '.client',
AttributeError: __len__

Original issue reported on code.google.com by kouxing2...@gmail.com on 10 Nov 2010 at 5:14

GoogleCodeExporter commented 9 years ago
Forget to mention, the gdata version is 2.0.12 , also already included in the 
Lib.zip

Original comment by kouxing2...@gmail.com on 10 Nov 2010 at 5:23

GoogleCodeExporter commented 9 years ago
I just committed r508, which might fix the problem. Could you try it out and 
let me know one way or the other? Thanks.

Original comment by thmil...@google.com on 10 Nov 2010 at 7:47

GoogleCodeExporter commented 9 years ago
thank you thmil.
After using the newest googlecl code, another problem appeared:

Exception in thread "MainThread" Traceback (most recent call last):
  File "./war/WEB-INF/google_cl/google.py", line 52, in <module>
    import googlecl
  File "C:\shark\StandardDirectories\java-projects\Personal\e-majordomo\.\war\WEB-INF\google_cl\Lib.zip\googlecl\__init__.py", line 23, in <module>
  File "C:\shark\StandardDirectories\java-projects\Personal\e-majordomo\.\war\WEB-INF\google_cl\Lib.zip\googlecl\config\__init__.py", line 17, in <module>
SyntaxError: ("'with' will become a reserved keyword in Python 2.6", 
('C:\\shark\\StandardDirectories\\java-projects\\Personal\\e-majordomo\\.\\war\\
WEB-INF\\google_cl\\Lib.zip\\googlecl\\config\\parser.py', 164, 4, ''))

It seems not a big problem, but I really not sure how to solve it.

Original comment by kouxing2...@gmail.com on 11 Nov 2010 at 2:10

GoogleCodeExporter commented 9 years ago
Try r509 -- forgot the "from __future__" import statement for early Python 
versions.

Original comment by thmil...@google.com on 11 Nov 2010 at 7:28

GoogleCodeExporter commented 9 years ago
Great, it works, thanks you for so fast response.

> help
Welcome to the Google CL tool!
  Commands are broken into several parts: 
    service, task, options, and arguments.
  For example, in the command
      "> picasa post --title "My Cat Photos" photos/cats/*"
  the service is "picasa", the task is "post", the single
  option is a title of "My Cat Photos", and the argument is the 
  path to the photos.

  The available services are 
'picasa', 'blogger', 'youtube', 'docs', 'contacts', 'calendar', 'finance'
  Enter "> help <service>" for more information on a service.
  Or, just "quit" to quit.
> help docs
Available tasks for service docs: 'delete', 'edit', 'get', 'upload', 'list'
 delete: Delete documents
  Requires: title Optional: folder

 edit: Edit a document
  Requires: title Optional: format, editor, folder

 get: Download a document
  Requires: (title OR folder) AND dest Optional: format

 upload: Upload a document
  Requires: src Optional: title, folder, format

 list: List documents
  Requires: fields AND delimiter Optional: title, folder

Original comment by kouxing2...@gmail.com on 11 Nov 2010 at 10:11

GoogleCodeExporter commented 9 years ago
but when try one example

> calendar add "Lunch with Jim at noon tomorrow"
Please specify user: xxxxx
Traceback (most recent call last):
  File "./war/WEB-INF/google_cl/google.py", line 513, in run_interactive
    run_once(options, args)
  File "./war/WEB-INF/google_cl/google.py", line 642, in run_once
    authenticated = authenticate(service, client, options, config, section_header)
  File "./war/WEB-INF/google_cl/google.py", line 84, in authenticate
    set_token = set_access_token(service, client)
  File "./war/WEB-INF/google_cl/google.py", line 662, in set_access_token
    token = googlecl.read_access_token(service_name, client.email)
  File "./war/WEB-INF/google_cl/google.py", line 662, in set_access_token
    token = googlecl.read_access_token(service_name, client.email)
AttributeError: 'module' object has no attribute 'read_access_token'

what about this one?

Original comment by kouxing2...@gmail.com on 11 Nov 2010 at 10:14

GoogleCodeExporter commented 9 years ago
Looks like google.py isn't updated. Try pulling again, you should be at r511.

Original comment by tom.h.mi...@gmail.com on 11 Nov 2010 at 6:58