views:

57

answers:

1

Hello, I have created my GAE application in directory "my_application". Inside this directory I created a .py file and named it "my_scrypt".

The contents of "my_scrypt" in the beginning were as following:


print 'Content-Type: text/plain'
print ''
print 'This is my first application'

Then I ran it locally on my machine (Windows XP) in the installed browser (Mozilla FireFox) with "GAE Launcher" - everything was fine - I could see that sentence ("This is my first application") on the screen.

Then I deployed this application to GAE (again with the help of "GAE Launcher") - everything was fine again - I could see the same sentence on the screen.

Then I changed the contents of "my_scrypt" a bit:


from twill.commands import *
config('use_tidy', '0')
go ("http://us.yahoo.com/")
showlinks()

Downloaded "twill0.9" (from here), chose and copied "twill" folder from there, and pasted it in "my_application" directory.

When I ran this new application locally (with "GAE Launcher") everything was fine - I could see a list of yahoo.com links on the screen, but when I uploaded this application to GAE, I received only an error message.

Why is it so? I don't think it's because the version of mechanize being used by twill here is too old - the code in "my_script" is so simple, any version of mechanize must be able to handle it.

Does GAE accept twill (as an external module) at all?

You can view the stack trace of the error in the "Update 1" section right below (↓).


UPDATE 1:

(This update is my answer to Nick)

Hello, Nick. I checked the admin console, so here is the stack trace:

<type 'exceptions.ImportError'>: No module named fcntl
Traceback (most recent call last):
  File "/base/data/home/apps/silkybutton/1.344911014283513184/bumper.py", line 1, in <module>
    from twill.commands import *
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/__init__.py", line 52, in <module>
    from shell import TwillCommandLoop
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/shell.py", line 9, in <module>
    from twill import commands, parse, __version__
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/commands.py", line 70, in <module>
    from browser import TwillBrowser
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/browser.py", line 17, in <module>
    from _browser import PatchedMechanizeBrowser
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/_browser.py", line 9, in <module>
    from utils import FixedHTTPBasicAuthHandler, FunctioningHTTPRefreshProcessor
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/utils.py", line 12, in <module>
    import subprocess
  File "/base/data/home/apps/silkybutton/1.344911014283513184/twill/other_packages/subprocess.py", line 378, in <module>
    import fcntl

+1  A: 

Twill is trying to import 'subprocess'. This is a Python module for spawning threads, and it's not available on App Engine. You'll either need to see if you can persuade Twill to work without spawning processes (probably by modifying the code), or you'll need to use mechanize or simply urlfetch directly.

Nick Johnson
Thank You, Nick!!! I think I'll take the way of trying to persuade Twill to work without spawning processes, except I have no idea how to do it or even where to start. One small question: How come there was no such need in this module when I was running exactly the same application on my computer locally?
brilliant
Were you running Python 2.6 on your local machine? App Engine only supports 2.5, and the subprocess module was introduced in Python 2.6.
Nick Johnson
I am running Python 2.5.4. Do You think I could just look into Python 2.6 pack and transfer that module from there into my application?
brilliant
No. Subprocess is a native C module that's part of 2.6; you can't simply copy it from 2.5. Also, as I said, you can't fork processes on App Engine. Are you sure the SDK wasn't running under 2.6? If you have multiple versions of Python installed, you could be running a different version to what you thought you were.
Nick Johnson
I used to have python 2.6 long ime ago. When I found out that GAP didn't support python 2.6 I uninstalled it and installed python 2.5 insteadBut I don't remember if I changed the SDK, though, as I didn't know I had to change SDK too. Perhaps, there are some "leftovers" of Python 2.6 on my machine. Do You know of any way of how I could check it?
brilliant
I am sorry, Nick, I just had a second look at the stack trace of the error and noticed that the last line was not "import subprocess", but rather "import fcntl", and the upmost line there says "No module named fcntl". I also looked into the "twill" folder in my application and found "subprocess.py" file in it. Are You sure the problem is still in not having the right "subrocess" module? Or, perhaps, "subprocess" is fine (since I have it in "twill"), but what I really need is some "fcntl" module?
brilliant
Yes, but the import of fcntl is itself inside the subprocess module, which is not supported on App Engine.
Nick Johnson
I see. You know what I did? I looked into that subprocess module and deleted the whole def section, in which the words "fcntl" were. Surprizingly, it woked for me!!!
brilliant