[Twisted-Python] adding endpoint plugins

David Stainton dstainton415 at gmail.com
Wed Apr 30 11:29:27 MDT 2014


ah ok... i made it work. Thanks!

On Wed, Apr 30, 2014 at 5:00 PM,  <exarkun at twistedmatrix.com> wrote:
> On 03:50 pm, dstainton415 at gmail.com wrote:
>>
>> Hi Jean-Paul,
>>
>> Thanks for the suggestions.
>> OK... here's my SSCCE:
>
>
> It looks like you need to make an instance of
> `TorClientEndpointStringParser`.  If a class `implements´ an interface then
> instances of that class `provide´ the interface.
>
> The plugin system searches for objects that `project´ the requested
> interface.
>
> Jean-Paul
>>
>> cd projects/virtualenv-1.11.1/
>> ./virtualenv.py ~/virtenv-endpoints-test
>> . ~/virtenv-endpoints-test/bin/activate
>> usewithtor pip install twisted
>> cd ~/projects
>> git clone https://github.com/david415/txsocksx.git
>> cd txsocksx
>> git checkout endpoint_parsers
>> usewithtor python setup.py install
>> cd examples # CWD is now /home/human/projects/txsocksx/examples
>> cp tor_client_endpoint_parser.py
>> /home/human/virtenv-endpoints-test/lib/python2.7/site-
>> packages/twisted/plugins
>> find /home/human/virtenv-endpoints-test/ -name "*.pyc" | xargs rm
>> find /home/human/virtenv-endpoints-test/ -name "dropin.cache" | xargs rm
>> python tor-http.py
>> Traceback (most recent call last):
>>  File "tor-http.py", line 32, in <module>
>>    torEndpoint = clientFromString(reactor,
>> "tor:host=timaq4ygg2iegci7.onion:port=80")
>>  File "/home/human/virtenv-endpoints-test/local/lib/python2.7/site-
>> packages/twisted/internet/endpoints.py",
>>
>> line 1737, in clientFromString
>>    raise ValueError("Unknown endpoint type: %r" % (aname,))
>> ValueError: Unknown endpoint type: 'tor'
>>
>>
>> I also tried the PYTHONPATH trick:
>>
>> mkdir -p fu/twisted/plugins
>> cp tor_client_endpoint_parser.py fu/twisted/plugins
>> PYTHONPATH=/home/projects/txsocks/examples/fu python tor-http.py
>> Traceback (most recent call last):
>>  File "tor-http.py", line 32, in <module>
>>    torEndpoint = clientFromString(reactor,
>> "tor:host=timaq4ygg2iegci7.onion:port=80")
>>  File "/home/human/virtenv-endpoints-test/local/lib/python2.7/site-
>> packages/twisted/internet/endpoints.py",
>>
>> line 1737, in clientFromString
>>    raise ValueError("Unknown endpoint type: %r" % (aname,))
>> ValueError: Unknown endpoint type: 'tor'
>>
>>
>> I wonder if I am having a deployment problem here or if my code has
>> got problems.
>>
>> https://github.com/david415/txsocksx/blob/endpoint_parsers/examples/tor_client_endpoint_parser.py
>> https://github.com/david415/txsocksx/blob/endpoint_parsers/examples
>> /tor-http.py
>>
>>
>> Cheers!
>>
>> David
>>
>> On Wed, Apr 30, 2014 at 2:14 PM,  <exarkun at twistedmatrix.com> wrote:
>>>
>>> On 01:42 pm, dstainton415 at gmail.com wrote:
>>>>
>>>>
>>>> Greetings,
>>>>
>>>>
>>>> http://twistedsphinx.funsize.net/projects/core/howto/plugin.html
>>>
>>>
>>>
>>> Note that's a random version of the documentation from who knows how long
>>> ago.  If you want a random version of the documentation then I suggest
>>> using
>>> http://twisted.readthedocs.org/en/latest/ instead.
>>>>
>>>>
>>>> suggests that I can also set the PYTHONPATH to a directory:
>>>
>>>
>>>
>>> Sure.  As a development environment trick.  Putting the module defining
>>> your
>>> plugin into *the* twisted/plugins/ directory will reduce your runtime
>>> cost.
>>> This is purely a deployment decision, though, so if you'd rather expand
>>> PYTHONPATH then you can.
>>>>
>>>>
>>>> """if a directory which has been added to sys.path (typically by
>>>> adding it to the PYTHONPATH environment variable) contains a directory
>>>> named twisted/plugins/ , each .py file in that directory will be
>>>> loaded as a source of plugins."""
>>>>
>>>> I'm using twisted 13.2.0 in a virtualenv... and I've tried setting
>>>> PYTHONPATH to a "twisted/plugins" directory no avail. I must be doing
>>>> something wrong here but after scouring the docs and twisted source
>>>> code... I'm just not sure.
>>>
>>>
>>>
>>> I don't think there's enough information here to debug your problem. Try
>>> coming up with an http://sscce.org/ or at least providing all of the
>>> details
>>> about your setup - the exact value of PYTHONPATH, the command you use to
>>> launch the program, the working directory you use, the complete, exact
>>> filesystem hierarchy starting at the top-most directory containing any
>>> code
>>> you wrote or expect to be in use, etc.
>>>
>>> Some random suggestions that have helped other people and might help you
>>> but
>>> who knows:
>>>
>>>  * delete all the dropin.cache files you can find and try again
>>>  * delete all the .pyc files you can find and try again
>>>  * put absolute paths into PYTHONPATH, not relative paths
>>>  * don't put "/foo/bar/twisted/plugins" into PYTHONPATH, put "/foo/bar"
>>>  * Make sure your plugin *provides* the plugin interface and IPlugin.
>>> This
>>> is not the same *implementing* those interfaces.
>>>
>>> Good luck,
>>> Jean-Paul
>>>
>>> _______________________________________________
>>> Twisted-Python mailing list
>>> Twisted-Python at twistedmatrix.com
>>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python



More information about the Twisted-Python mailing list