How can I start using twill?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 04:50:01

问题


I am sorry I have already asked this question on "Superuser", but nobody answers there, so I deleted it from "Superuser" and decided to post it here. Hope it's not a big crime, especially given the fact that I was firstly advised to use twill here on "StackOverflow" (not on "SuperUser")

How do I start using twill? I have just downloaded it, unpacked it and clicked on the setup .py file in the folder. The black window (terminal) appeared for a moment and vanished.

(I do have Python 2.5 installed on my computer - along with SDK from Google App Engine)

In the twill documentation section it says:


Downloading twill

The latest release of twill is twill 0.9, released Thursday, December 27th, 2007; it is available for download at http://darcs.idyll.org/~t/projects/twill-0.9.tar.gz. You can also use Python's easy_install to install or upgrade twill.

twill works with Python 2.3 or later.

To start using twill, install it and then type twill-sh. At the prompt type:

go http://www.slashdot.org/
show
showforms
showhistory


I am not clear from this passage what I am supposed to type (only "twill-sh" or "twill-sh" and all the words under that line) and where (I tried typing it in the command prompt window of my computer - to no avail)

Can, anyone, please, help me out here?

Thank You in advance.


Update 1:

(This update is a response to the answer given by S.Mark)

Hello, S.Mark!!!! I’ve tried to follow Your instructions. Here is what happened:

Firstly, I created a folder on my D disk and named it “tmp”. Then I downloaded and extracted twill-0.9 into that folder. So, now the path to this file on my computer was just as same as the one in Your example: D:\tmp\twill-0.9 :
(source: narod.ru)


(source: narod.ru)

Then, I tried to open the command prompt on my computer:
(source: narod.ru)


(source: narod.ru)


(source: narod.ru)


(source: narod.ru)


(source: narod.ru)

Then, following step 2 of Your instructions, I tried to switch to D disk:


(source: narod.ru)

But for some reason it didn’t work:


(source: narod.ru)

This Chinese line says something like “This action has been rejected.” Why is it so? Well, I tried to proceed to step 3 anyway, and here is what I’ve got:


(source: narod.ru)

As far as I can understand, this Chinese line says something like “ ’C:\’ is neither internal nor external command, thus, it cannot be carried out. ” Why is it so? Is there something wrong with my computer?


Update 2:

(This update is my second response to the answer given by S.Mark)

Hello, S.Mark!!! Thank You for Your answer again.

Yes, this time it worked when I just typed those parts that You highlighted in Your post. So, when I typed just “d:” in the very beginning, it worked!!!

But then, when I typed “python setup.py build”, I got the same error message (“ ’python’is neither an internal or external command; it can’t be carried out. “) :
(source: narod.ru)

I tried to repeat this command and accidentally omitted the word “python”:

(source: narod.ru)

When I pressed “Enter” key, the build process seemed to launch - at least what I saw then resembled the step 4 of Your instructions (“start the build process”) very much:
(source: narod.ru)

(source: narod.ru)

(source: narod.ru)

But now I am a little bit hesitant about proceeding to step 5 (“Install It”) as I am not sure if what I have done is the right thing.

If what I did in step 4 was okay, should I also omit the word “python” in step 5?

A side question: How did You manage to put the contents of the terminal into Your post without making screenshots? Is it like there is some way of putting the terminal’s contents into the clipboard? Making screenshots all the time and hosting them prior to posting is quite cumbersome.


Update 3:

(This update is my third response to S.Mark)

S.Mark, hello again!!!

(Hope you are not sick and tired of me yet)

“…and yeah you could omit python and directly run setup.py because your python installation registered *.py in registry… regarding step 5, you could just run setup.py install” – I followed these words of Yours and install process ran successfully! Thank You.

But as for the following steps (“then open python prompt from start menu, and test step 6 and 8”), there wasn’t much success in the Python prompt:
(source: narod.ru)

Neither was it successful in the usual command prompt (terminal):
(source: narod.ru)

(It again says in Chinese that python “is neither an internal nor external command and, therefore, can’t be carried out”). Do You have any idea why it didn’t work?

“…where is your python installation? C:\Python25?” - Yes, that’s right.

“…there is a setting (command prompt properties - easy edit mode) to enable selection of text on the command prompt, could you ask that in superuser.com?” - Sure, I will ask this question there. Thanks for telling me.


回答1:


You cannot just double click setup.py

You need to open command prompt or shell and go to that folder

and need to do

python setup.py build
python setup.py install

install step should automatically do build normally, so only last one will work


Edit: ok, here is superuser way of installation steps

  1. I have extracted twill-0.9.tar.gz to D:\tmp\twill-0.9

  2. I am on drive C, so I switched to D:

    C:\>d:
  3. Now, change the folder by using cd command

    C:\>cd D:\tmp\twill-0.9
  4. start the build process

    D:\tmp\twill-0.9>python setup.py build
    (WARNING: importing distutils, not setuptools!)
    D:\data\program\Python26\lib\distutils\dist.py:266: UserWarning: Unknown distribution option: 'entry_points'
      warnings.warn(msg)
    D:\data\program\Python26\lib\distutils\dist.py:266: UserWarning: Unknown distribution option: 'test_suite'
      warnings.warn(msg)
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\twill
    ......
    running build_scripts
    creating build\scripts-2.6
    copying and adjusting twill-fork -> build\scripts-2.6
  5. Install it

    D:\tmp\twill-0.9>python setup.py install
    (WARNING: importing distutils, not setuptools!)
    running install
    running build
    running build_py
    ......
    running install_scripts
    copying build\scripts-2.6\twill-fork -> D:\data\program\Python26\Scripts
    running install_egg_info
    Writing D:\data\program\Python26\Lib\site-packages\twill-0.9-py2.6.egg-info
  6. Test for import is or not

    D:\tmp\twill-0.9>python
    Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.  
    >>> import twill
      import re, base64, urlparse, posixpath, md5, sha, sys, copy
    twill\other_packages\_mechanize_dist\_auth.py:14: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
      import re, base64, urlparse, posixpath, md5, sha, sys, copy
    >>>
  7. Import was fine, but there is DeprecationWarnings on python 2.6, but this should be ok and should be no warnings at all with python 2.5

  8. confirm its properly imported or not, you will see twill and its functions there, so yes.

    >>> dir()
    ['__builtins__', '__doc__', '__name__', '__package__', 'twill']
    >>> from twill.commands import *
    >>> dir()
    ['__builtins__', '__doc__', '__name__', '__package__', 'add_auth', 'add_extra_header', 'agent', 'back', 'clear_cookies', 'clear_extra_headers', 'code', 'config', 'debug', 'echo', 'exit', 'extend_with', 'fa', 'find', 'follow
    >>>


来源:https://stackoverflow.com/questions/2651334/how-can-i-start-using-twill

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!