Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-28 Thread Dieter Maurer
lucas wrote at 2021-3-27 18:53 +0100:
>Following our previous discussion:
> https://www.talkend.net/post/287193.html
>
>I finally took time (thanks to Florian R.) to get a reproducible example
>of my problem, as asked previously by ChrisA.

I compared `xmlrpc.client.ServerProxy.__init__`
for Python 3.6 and Python 3.9(a5):
Python 3.6 uses `splittype` and `splithost` to parse *uri*
while Python 3.9 uses `urlparse` to complete decompose *uri*
and then uses `scheme`, `netloc` and `path` from the result.
As a consequence Python 3.9 misses any information in the "query string".

In my view, Python 3.6 behaves as documented (in the `ServerProxy` "docstring")
while Python 3.9 does not. At your place, I would file a bug
report at "https://bugs.python.org/";.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-28 Thread Terry Reedy

On 3/27/2021 6:10 PM, lucas wrote:


I hope it will solve it too. Do i need to do anything ?


Review the patch by trying it out on your system.  If necessary because 
you do not have a local cpython clone, backup installed 3.9 
Lib/xmlrpc.py and hand-edit. Then report OS, python used, and result. 
(If it works, you can keep the patched version ;-).


For many issues, reviews are the bottleneck for getting fixes released.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-28 Thread Chris Angelico
On Sun, Mar 28, 2021 at 9:12 AM lucas  wrote:
>
> Thank you ChrisA !
>
> I hope it will solve it too. Do i need to do anything ?
>
> Thank you for your time and help.
>

There are a couple of things you can do actually! First off, here's
the pull request, which will be where further comments happen:

https://github.com/python/cpython/pull/25045

Since you actually use xmlrpc, you'd be the best person to devise some
useful tests. Also, the question has been raised regarding the
fragment. I suspect that a fragment is inappropriate here, since it's
effectively an external URL, but that's for you to answer; if
fragments are to be stripped, that definitely needs to be mentioned.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread Terry Reedy

On 3/27/2021 5:49 PM, Chris Angelico wrote:


https://bugs.python.org/issue38038

It seems to have been intended as a pure refactor, so I'd call this a
regression. Fortunately, it's not difficult to fix; but I'm not sure
if there are any other subtle changes.

The regression's already been reported so I'm adding to this issue:

https://bugs.python.org/issue43433


You added a PR, which is great, but useless unless a currently active 
coredev reviews and merges.  I requested such from the author and merger 
of the apparently offending commit.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas

Thank you ChrisA !

I hope it will solve it too. Do i need to do anything ?

Thank you for your time and help.

Best wishes,
--lucas



On 27/03/2021 22:49, Chris Angelico wrote:

On Sun, Mar 28, 2021 at 5:00 AM lucas  wrote:

I finally took time (thanks to Florian R.) to get a reproducible example
of my problem, as asked previously by ChrisA.


Thanks! With this in hand, I can play around with it.


On debian, Python 3.7, i got:

  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
HTTP/1.1" 404 -

On Arch, python 3.9, i got:

   aluriak@arch❯ python3.9 p.py server
  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


On Debian, with both versions having been built from source, the same
occurs. Furthermore, Python 3.8 behaves as 3.7 does. This definitely
changed in 3.9.


Note that the two outputs differs in two ways:

  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
HTTP/1.1" 404 -
  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path.
Sounds like there is something wrong with both modules.


One point of note is that the request as given actually doesn't have a
slash. I think that's technically wrong, but a lot of systems will
just implicitly add the slash. That, coupled with commit 9c4c45, is
why you're seeing "/RPC2" in there. That distinction vanishes if you
change your client thusly:

url = 'http://' + URL + '/?' + urlencode({'u': USER, 'p': PASSWD})

Actually, it looks like all the changes came in with that commit. The
old way used some internal functions from urllib.parse, and the new
way uses the public function urllib.parse.urlparse(), and there are
some subtle differences. For one thing, the old way would implicitly
readd the missing slash, thus hiding the above issue; the new way
leaves the path empty (thus triggering the "/RPC2" replacement). But
perhaps more significantly, the old way left query parameters in the
"path" portion, where the new way has a separate "query" portion that
is being lost. Here's the relevant BPO:

https://bugs.python.org/issue38038

It seems to have been intended as a pure refactor, so I'd call this a
regression. Fortunately, it's not difficult to fix; but I'm not sure
if there are any other subtle changes.

The regression's already been reported so I'm adding to this issue:

https://bugs.python.org/issue43433

Hopefully that solves the problem!

ChrisA


--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread Chris Angelico
On Sun, Mar 28, 2021 at 5:00 AM lucas  wrote:
> I finally took time (thanks to Florian R.) to get a reproducible example
> of my problem, as asked previously by ChrisA.

Thanks! With this in hand, I can play around with it.

> On debian, Python 3.7, i got:
>
>  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
> HTTP/1.1" 404 -
>
> On Arch, python 3.9, i got:
>
>   aluriak@arch❯ python3.9 p.py server
>  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

On Debian, with both versions having been built from source, the same
occurs. Furthermore, Python 3.8 behaves as 3.7 does. This definitely
changed in 3.9.

> Note that the two outputs differs in two ways:
>
>  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
> HTTP/1.1" 404 -
>  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -
>
> The first contains the arguments, and the second contains the path.
> Sounds like there is something wrong with both modules.

One point of note is that the request as given actually doesn't have a
slash. I think that's technically wrong, but a lot of systems will
just implicitly add the slash. That, coupled with commit 9c4c45, is
why you're seeing "/RPC2" in there. That distinction vanishes if you
change your client thusly:

url = 'http://' + URL + '/?' + urlencode({'u': USER, 'p': PASSWD})

Actually, it looks like all the changes came in with that commit. The
old way used some internal functions from urllib.parse, and the new
way uses the public function urllib.parse.urlparse(), and there are
some subtle differences. For one thing, the old way would implicitly
readd the missing slash, thus hiding the above issue; the new way
leaves the path empty (thus triggering the "/RPC2" replacement). But
perhaps more significantly, the old way left query parameters in the
"path" portion, where the new way has a separate "query" portion that
is being lost. Here's the relevant BPO:

https://bugs.python.org/issue38038

It seems to have been intended as a pure refactor, so I'd call this a
regression. Fortunately, it's not difficult to fix; but I'm not sure
if there are any other subtle changes.

The regression's already been reported so I'm adding to this issue:

https://bugs.python.org/issue43433

Hopefully that solves the problem!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas
And, in my outputs, a key part is missing: the received arguments as 
parsed by Flask:


Python 3.7:
REQUEST: ImmutableMultiDict([('u', 'user'), ('p', 'password')])

Python 3.9:
REQUEST: ImmutableMultiDict([])


Have a good day everyone,
--lucas


On 27/03/2021 18:53, lucas wrote:

Following our previous discussion:
     https://www.talkend.net/post/287193.html

I finally took time (thanks to Florian R.) to get a reproducible example 
of my problem, as asked previously by ChrisA.


The following code is implementing a webserver with Flask, and a client 
with the XMLRPC client:


     import sys
     from xmlrpc import server, client
     from urllib.parse import urlencode
     from flask import Flask, request


     PORT = 23456
     USER, PASSWD = 'user', 'password'
     URL = '127.0.0.1:' + str(PORT)

     if len(sys.argv) > 1 and sys.argv[1] == 'server':
     app = Flask(__name__)
     @app.route('/', methods=['POST'])
     @app.route('/RPC2', methods=['POST'])
     def login():
     print('REQUEST:', request.args)
     return 'ok'
     app.run(debug=True, host='localhost', port=PORT)

     else:
     url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD})
     print(url)
     proxy = client.ServerProxy(url)
     print(proxy, dir(proxy))
     print(proxy.add(2, 3))


You can run the client with `python3 p.py`, and the server with `python3 
p.py server`.


On debian, Python 3.7, i got:

     lucas@debianserver:~$ python3.7 p.py server
  * Serving Flask app "p" (lazy loading)
  * Environment: production
    WARNING: This is a development server. Do not use it in a 
production deployment.

    Use a production WSGI server instead.
  * Debug mode: on
  * Running on http://localhost:23456/ (Press CTRL+C to quit)
  * Restarting with stat
  * Debugger is active!
  * Debugger PIN: 249-992-288
     127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -



On Arch, python 3.9, i got:

  aluriak@arch❯ python3.9 p.py server
  * Serving Flask app "p" (lazy loading)
  * Environment: production
    WARNING: This is a development server. Do not use it in a 
production deployment.

    Use a production WSGI server instead.
  * Debug mode: on
  * Running on http://localhost:23456/ (Press CTRL+C to quit)
  * Restarting with stat
  * Debugger is active!
  * Debugger PIN: 821-276-100
     127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


Both systems return the same output on command `pip3 freeze | grep 
Flask`, which is `Flask==1.1.2`.



Note that the two outputs differs in two ways:

     127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -

     127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path. 
Sounds like there is something wrong with both modules.


This should be a reproducible example ; plus i'm not the only one to 
encounter that problem:
 
https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244


Best regards,
--lucas

--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas

Following our previous discussion:
https://www.talkend.net/post/287193.html

I finally took time (thanks to Florian R.) to get a reproducible example 
of my problem, as asked previously by ChrisA.


The following code is implementing a webserver with Flask, and a client 
with the XMLRPC client:


import sys
from xmlrpc import server, client
from urllib.parse import urlencode
from flask import Flask, request


PORT = 23456
USER, PASSWD = 'user', 'password'
URL = '127.0.0.1:' + str(PORT)

if len(sys.argv) > 1 and sys.argv[1] == 'server':
app = Flask(__name__)
@app.route('/', methods=['POST'])
@app.route('/RPC2', methods=['POST'])
def login():
print('REQUEST:', request.args)
return 'ok'
app.run(debug=True, host='localhost', port=PORT)

else:
url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD})
print(url)
proxy = client.ServerProxy(url)
print(proxy, dir(proxy))
print(proxy.add(2, 3))


You can run the client with `python3 p.py`, and the server with `python3 
p.py server`.


On debian, Python 3.7, i got:

lucas@debianserver:~$ python3.7 p.py server
 * Serving Flask app "p" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a 
production deployment.

   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://localhost:23456/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 249-992-288
127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -



On Arch, python 3.9, i got:

 aluriak@arch❯ python3.9 p.py server
 * Serving Flask app "p" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a 
production deployment.

   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://localhost:23456/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 821-276-100
127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


Both systems return the same output on command `pip3 freeze | grep 
Flask`, which is `Flask==1.1.2`.



Note that the two outputs differs in two ways:

127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -

127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path. 
Sounds like there is something wrong with both modules.


This should be a reproducible example ; plus i'm not the only one to 
encounter that problem:

https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244

Best regards,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 20:21, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 6:14 AM lucas  wrote:

I tested from the windows computer (Python 3.8, it appears, not 3.7 as i
thought), and got the following nginx log:

[LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
"DokuWikiXMLRPC  1.0  for testing windows"

That other laptop also had an ubuntu installed, with python 3.6.9, so i
ran the program and got the expected output, and the following nginx log:
[LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
"DokuWikiXMLRPC  1.0  for testing ubuntu"

Both accessed correctly the dokuwiki version. Unless this is a platform
specific problem, it seems to narrow it to 3.9.



Curious.

I think, at this point, we need a repeatable test case. Wonder how
hard it would be to make a single Python script that has a tiny server
and a tiny client, and tries to connect them.

ChrisA


I will work on that tomorrow.

Thanks for your guidance, i will come back with a repeatable test case.

Best regards,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 6:14 AM lucas  wrote:
> I tested from the windows computer (Python 3.8, it appears, not 3.7 as i
> thought), and got the following nginx log:
>
> [LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST
> /lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
> "DokuWikiXMLRPC  1.0  for testing windows"
>
> That other laptop also had an ubuntu installed, with python 3.6.9, so i
> ran the program and got the expected output, and the following nginx log:
> [LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST
> /lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
> "DokuWikiXMLRPC  1.0  for testing ubuntu"
>
> Both accessed correctly the dokuwiki version. Unless this is a platform
> specific problem, it seems to narrow it to 3.9.
>

Curious.

I think, at this point, we need a repeatable test case. Wonder how
hard it would be to make a single Python script that has a tiny server
and a tiny client, and tries to connect them.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 19:22, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 5:12 AM lucas  wrote:


On 24/02/2021 18:48, Chris Angelico wrote:
I added socket.gethostbyname("wiki.example.net") (i removed the https://
since it, obviously now i think about it, led to a socket error)
in the program, so i could verify both the URL and IP are equivalent.

I got the exact same URL and IP. To be sure, i let python run the
comparison instead of only relying on my eyes.

  >>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password' ==
'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password'
True
  >>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197'
True


Those URLs were printed out from each script, just before attempting the call?


Yes. The program is that one :

import socket
import xmlrpc.client as xmlrpclib
from xml.parsers.expat import ExpatError
from urllib.parse import urlencode

URL = 'https://wiki.example.net'
USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

script = '/lib/exe/xmlrpc.php'
url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
print(url)
print(socket.gethostbyname('wiki.example.net'))
# xmlrpclib.Transport.user_agent = USER_AGENT
# xmlrpclib.SafeTransport.user_agent = USER_AGENT

proxy = xmlrpclib.ServerProxy(url)
v = proxy.dokuwiki.getVersion()
print(v)





You gave me an idea: i checked the nginx log of the server hosting the
dokuwiki instance, and got something of interest :

[SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST
/lib/exe/xmlrpc.php?u=[USER]&p=[PASSWORD] HTTP/1.1" 200 209 "-"
"Python-xmlrpc/3.7"
[LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php
HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9"

It seems that the laptop is not sending the arguments, despite them
being fed in the python code ?


Fascinating! Well, that does at least simplify things somewhat -
instead of "why is this coming back 401", it's "why is this not
sending credentials".


Yes, we are going forward :)






More data is always good.

ChrisA


I tested from the windows computer (Python 3.8, it appears, not 3.7 as i 
thought), and got the following nginx log:


[LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST 
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-" 
"DokuWikiXMLRPC  1.0  for testing windows"


That other laptop also had an ubuntu installed, with python 3.6.9, so i 
ran the program and got the expected output, and the following nginx log:
[LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST 
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-" 
"DokuWikiXMLRPC  1.0  for testing ubuntu"


Both accessed correctly the dokuwiki version. Unless this is a platform 
specific problem, it seems to narrow it to 3.9.


--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 5:12 AM lucas  wrote:
>
> On 24/02/2021 18:48, Chris Angelico wrote:
> I added socket.gethostbyname("wiki.example.net") (i removed the https://
> since it, obviously now i think about it, led to a socket error)
> in the program, so i could verify both the URL and IP are equivalent.
>
> I got the exact same URL and IP. To be sure, i let python run the
> comparison instead of only relying on my eyes.
>
>  >>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password' ==
> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password'
> True
>  >>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197'
> True

Those URLs were printed out from each script, just before attempting the call?

> You gave me an idea: i checked the nginx log of the server hosting the
> dokuwiki instance, and got something of interest :
>
> [SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST
> /lib/exe/xmlrpc.php?u=[USER]&p=[PASSWORD] HTTP/1.1" 200 209 "-"
> "Python-xmlrpc/3.7"
> [LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php
> HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9"
>
> It seems that the laptop is not sending the arguments, despite them
> being fed in the python code ?

Fascinating! Well, that does at least simplify things somewhat -
instead of "why is this coming back 401", it's "why is this not
sending credentials".

> Now i think about it, my remote server host both the python program into
> 3.7, and the dokuwiki. One may think it could be the source of the problem.
> To prove it's not, i will test with another laptop (the one under
> windows, python 3.7, which successfully accessed the wiki while i was
> discovering the error on my manjaro laptop) as soon as possible.
>

More data is always good.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 18:48, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 4:36 AM lucas  wrote:

A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA



I did that, obtaining the following URL

https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]

on my two currently available computer (laptop on 3.9, remote on 3.7),
and the results is the same.

For information, i'm uploading the same python program to my remote
server (debian, 3.7), and running it with the same parameters as my
laptop (manjaro, 3.9). My laptop is getting the 401, my server is
getting the expected dokuwiki version.


(I'm aware that you have some other actual domain, but I'll continue
using "wiki.example.net" as per your original post.)

Is it possible that there's some kind of server-based restriction?
What happens if you call socket.gethostbyname("wiki.example.net") on
both the laptop and the server - do you get back the same IP address?
(Or use gethostbyname_ex, or possibly getaddrinfo if ipv6 support
matters.)

Also, just to make sure there's nothing stupid happening, try printing
out the URL on both machines. Obviously censor the password before
sharing it here, but mainly, make sure that the two are generating the
exact same URL, just in case. Both are running 3.7+, so dict iteration
order shouldn't be getting in your way, but I've seen crazier things
before :)

ChrisA



Thanks for taking time to help me !

I added socket.gethostbyname("wiki.example.net") (i removed the https:// 
since it, obviously now i think about it, led to a socket error)

in the program, so i could verify both the URL and IP are equivalent.

I got the exact same URL and IP. To be sure, i let python run the 
comparison instead of only relying on my eyes.


>>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password' == 
'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password'

True
>>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197'
True

You gave me an idea: i checked the nginx log of the server hosting the 
dokuwiki instance, and got something of interest :


[SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST 
/lib/exe/xmlrpc.php?u=[USER]&p=[PASSWORD] HTTP/1.1" 200 209 "-" 
"Python-xmlrpc/3.7"
[LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php 
HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9"


It seems that the laptop is not sending the arguments, despite them 
being fed in the python code ?



Now i think about it, my remote server host both the python program into 
3.7, and the dokuwiki. One may think it could be the source of the problem.
To prove it's not, i will test with another laptop (the one under 
windows, python 3.7, which successfully accessed the wiki while i was 
discovering the error on my manjaro laptop) as soon as possible.


--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 4:36 AM lucas  wrote:
> > A properly-formed URL will start with a protocol. I don't know
> > specifically what changed, but it's looking like something started
> > rejecting malformed URLs. Try adding "http://"; or "https://"; to your
> > URL (whichever is appropriate) and see if both versions will accept
> > it.
> >
> > ChrisA
> >
>
> I did that, obtaining the following URL
>
> https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]
>
> on my two currently available computer (laptop on 3.9, remote on 3.7),
> and the results is the same.
>
> For information, i'm uploading the same python program to my remote
> server (debian, 3.7), and running it with the same parameters as my
> laptop (manjaro, 3.9). My laptop is getting the 401, my server is
> getting the expected dokuwiki version.

(I'm aware that you have some other actual domain, but I'll continue
using "wiki.example.net" as per your original post.)

Is it possible that there's some kind of server-based restriction?
What happens if you call socket.gethostbyname("wiki.example.net") on
both the laptop and the server - do you get back the same IP address?
(Or use gethostbyname_ex, or possibly getaddrinfo if ipv6 support
matters.)

Also, just to make sure there's nothing stupid happening, try printing
out the URL on both machines. Obviously censor the password before
sharing it here, but mainly, make sure that the two are generating the
exact same URL, just in case. Both are running 3.7+, so dict iteration
order shouldn't be getting in your way, but I've seen crazier things
before :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 18:00, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 2:02 AM lucas  wrote:


Hi everyone,

(Sorry for the double-send if any, i'm not sure the first send was
performed, maybe because of bounce errors according to mailman.)


I'm currently trying to understand an error when using the
dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC
interface.

Another description of the problem :
 https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

  from urllib.parse import urlencode
  import xmlrpc.client as xmlrpclib

  URL = 'wiki.example.net'
  USER = 'user'
  PASSWD = 'password'
  USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

  script = '/lib/exe/xmlrpc.php'
  url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
  xmlrpclib.Transport.user_agent = USER_AGENT
  xmlrpclib.SafeTransport.user_agent = USER_AGENT
  proxy = xmlrpclib.ServerProxy(url)

  v = proxy.dokuwiki.getVersion()
  print(v)

When ran with Python 3.7 (a personnal debian server, or a personal
windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"'
as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
following stacktrace:

  Traceback (most recent call last):
File "/home/project/read.py", line 32, in 
  v = proxy.dokuwiki.getVersion()
File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
  return self.__send(self.__name, args)
File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
  response = self.__transport.request(
File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
  return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
single_request
  raise ProtocolError(
  xmlrpc.client.ProtocolError: 



A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA



I did that, obtaining the following URL

https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]

on my two currently available computer (laptop on 3.9, remote on 3.7), 
and the results is the same.


For information, i'm uploading the same python program to my remote 
server (debian, 3.7), and running it with the same parameters as my 
laptop (manjaro, 3.9). My laptop is getting the 401, my server is 
getting the expected dokuwiki version.


--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 2:02 AM lucas  wrote:
>
> Hi everyone,
>
> (Sorry for the double-send if any, i'm not sure the first send was
> performed, maybe because of bounce errors according to mailman.)
>
>
> I'm currently trying to understand an error when using the
> dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC
> interface.
>
> Another description of the problem :
> https://github.com/kynan/dokuwikixmlrpc/issues/8
>
> Here is the code, tailored to work with the DokuWiki RPC interface:
>
>  from urllib.parse import urlencode
>  import xmlrpc.client as xmlrpclib
>
>  URL = 'wiki.example.net'
>  USER = 'user'
>  PASSWD = 'password'
>  USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'
>
>  script = '/lib/exe/xmlrpc.php'
>  url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
>  xmlrpclib.Transport.user_agent = USER_AGENT
>  xmlrpclib.SafeTransport.user_agent = USER_AGENT
>  proxy = xmlrpclib.ServerProxy(url)
>
>  v = proxy.dokuwiki.getVersion()
>  print(v)
>
> When ran with Python 3.7 (a personnal debian server, or a personal
> windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"'
> as ouput.
> When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
> following stacktrace:
>
>  Traceback (most recent call last):
>File "/home/project/read.py", line 32, in 
>  v = proxy.dokuwiki.getVersion()
>File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
>  return self.__send(self.__name, args)
>File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
>  response = self.__transport.request(
>File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
>  return self.single_request(host, handler, request_body, verbose)
>File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
> single_request
>  raise ProtocolError(
>  xmlrpc.client.ProtocolError:  wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>
>

A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

Hi, thanks for your answer !

I updated everything, including certificates, while upgrading to python 
3.9, and retried today (no new certificates to install). I am the 
administrator of the wiki i try to access, and didn't do black magic in 
the configuration..


The error really seems to came from 3.8 or 3.9, since i can still reach 
the wiki nominally with my (some being non-updated) machines using 
python 3.7. This didn't evolve since i discovered the problem few days ago.


--lucas


On 24/02/2021 16:20, 2qdxy4rzwzuui...@potatochowder.com wrote:

On 2021-02-24 at 15:29:58 +0100,
lucas  wrote:


I'm currently trying to understand an error when using the dokuwikixmlrpc
python module, allowing to easily work with DokuWiki RPC interface.

Another description of the problem :
https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

 from urllib.parse import urlencode
 import xmlrpc.client as xmlrpclib

 URL = 'wiki.example.net'
 USER = 'user'
 PASSWD = 'password'
 USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

 script = '/lib/exe/xmlrpc.php'
 url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
 xmlrpclib.Transport.user_agent = USER_AGENT
 xmlrpclib.SafeTransport.user_agent = USER_AGENT
 proxy = xmlrpclib.ServerProxy(url)

 v = proxy.dokuwiki.getVersion()
 print(v)

When ran with Python 3.7 (a personnal debian server, or a personal windows
computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
following stacktrace:

 Traceback (most recent call last):
   File "/home/project/read.py", line 32, in 
 v = proxy.dokuwiki.getVersion()
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
 return self.__send(self.__name, args)
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
 response = self.__transport.request(
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
 return self.single_request(host, handler, request_body, verbose)
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
single_request
 raise ProtocolError(
 xmlrpc.client.ProtocolError: 


At the risk of stating the obvious, it might actually be an
authentication problem.  In addition to double checking the password:

(1) make sure all of your certificates (under Arch Linux, on which
Manjaro is based), that's the ca-certificates package) are up to date;
and

(2) check with whoever owns the wiki about any other certificates they
require.

After that, all I know about XML RPC is to avoid it.  :-)


I don't have the possibility to test this on python 3.8 specifically, but
since the XML and XMLRPC modules have been updated in 3.8, and since 3.9
doesn't seems to introduce any change for them, i would expect 3.8 to
introduce some change that dokuwikixmlrpc has somehow to take into
consideration.

Can anyone help me with that one ? I don't know anything about RPC and XML,
i don't know what i need to do know to fix dokuwikixmlrpc.

--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread 2QdxY4RzWzUUiLuE
On 2021-02-24 at 15:29:58 +0100,
lucas  wrote:

> I'm currently trying to understand an error when using the dokuwikixmlrpc
> python module, allowing to easily work with DokuWiki RPC interface.
> 
> Another description of the problem :
>   https://github.com/kynan/dokuwikixmlrpc/issues/8
> 
> Here is the code, tailored to work with the DokuWiki RPC interface:
> 
> from urllib.parse import urlencode
> import xmlrpc.client as xmlrpclib
> 
> URL = 'wiki.example.net'
> USER = 'user'
> PASSWD = 'password'
> USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'
> 
> script = '/lib/exe/xmlrpc.php'
> url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
> xmlrpclib.Transport.user_agent = USER_AGENT
> xmlrpclib.SafeTransport.user_agent = USER_AGENT
> proxy = xmlrpclib.ServerProxy(url)
> 
> v = proxy.dokuwiki.getVersion()
> print(v)
> 
> When ran with Python 3.7 (a personnal debian server, or a personal windows
> computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput.
> When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
> following stacktrace:
> 
> Traceback (most recent call last):
>   File "/home/project/read.py", line 32, in 
> v = proxy.dokuwiki.getVersion()
>   File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
> return self.__send(self.__name, args)
>   File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
> response = self.__transport.request(
>   File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
> return self.single_request(host, handler, request_body, verbose)
>   File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
> single_request
> raise ProtocolError(
> xmlrpc.client.ProtocolError:  wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>

At the risk of stating the obvious, it might actually be an
authentication problem.  In addition to double checking the password:

(1) make sure all of your certificates (under Arch Linux, on which
Manjaro is based), that's the ca-certificates package) are up to date;
and

(2) check with whoever owns the wiki about any other certificates they
require.

After that, all I know about XML RPC is to avoid it.  :-)

> I don't have the possibility to test this on python 3.8 specifically, but
> since the XML and XMLRPC modules have been updated in 3.8, and since 3.9
> doesn't seems to introduce any change for them, i would expect 3.8 to
> introduce some change that dokuwikixmlrpc has somehow to take into
> consideration.
> 
> Can anyone help me with that one ? I don't know anything about RPC and XML,
> i don't know what i need to do know to fix dokuwikixmlrpc.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: xml-rpc server on wine

2011-11-08 Thread Prasad, Ramit
>> Hi, I have a XML-RPC server python running on VM Windows (on Linux)
>> and a XML-RPC client python on Linux. Server and client have different
>> IP address. I'd like migrate server on wine. How can communicate
>> server and client? IP address is different or is the same?
>> Can you help me?

>Not really, this doesn't have much of anything to do with Python.  If
>you run a network application on wine [assuming that even works] the
>application will have the same IP/interface as any other application or
>service running on the host.  Wine is not a 'virtualization' solution.

Unless you have a specific need to run it in a virtual machine (which 
WINE is not), why not run it directly from Linux? I generally prefer
to use a DNS name or hostname to connect instead of IP because the
IP addresses can be dynamic (especially when you start accessing it 
from outside your local network). Even internally, I tend to use hostnames
and not IP addresses, but mostly because it is faster/easier for me 
to type (I assign static IPs internally).

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc server on wine

2011-11-07 Thread Adam Tauno Williams
On Sat, 2011-11-05 at 05:50 -0700, pacopyc wrote:
> Hi, I have a XML-RPC server python running on VM Windows (on Linux)
> and a XML-RPC client python on Linux. Server and client have different
> IP address. I'd like migrate server on wine. How can communicate
> server and client? IP address is different or is the same?
> Can you help me?

Not really, this doesn't have much of anything to do with Python.  If
you run a network application on wine [assuming that even works] the
application will have the same IP/interface as any other application or
service running on the host.  Wine is not a 'virtualization' solution.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc

2010-03-29 Thread Brian Quinlan


On Mar 14, 2010, at 12:14 AM, ahmet erdinc yilmaz wrote:


Hello,

Recenetly we are developing a senior project and decide to use  
xmlrpclib.
However I have some questions. In the documentation I could not find  
any clue about
handling requests? Does the server handles each request in a  
separate thread? Or is

there some queuing mechanism for client calls? Thanks in advance.


By default calls are processed serially. Look for ThreadingMixIn in:
http://docs.python.org/library/socketserver.html

And maybe read this too:
http://code.activestate.com/recipes/81549-a-simple-xml-rpc-server/

Cheers,
Brian




--erdinc
--
http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc

2010-03-16 Thread Gabriel Genellina
En Sun, 14 Mar 2010 05:14:49 -0300, ahmet erdinc yilmaz  
 escribió:



Recenetly we are developing a senior project and decide to use xmlrpclib.
However I have some questions. In the documentation I could not find any  
clue about
handling requests? Does the server handles each request in a separate  
thread? Or is

there some queuing mechanism for client calls? Thanks in advance.


xmlrpclib is a *client* library.
Python also provides an XMLRPC *server* in the SimpleXMLRPCServer module.  
It inherits from SocketServer.TCPServer. The default behavior is to  
process one request at a time, in a single process. You may alter such  
behavior by additionally inheriting from ForkingMixIn or ThreadingMixIn.


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc

2010-03-14 Thread Martin P. Hellwig

On 03/14/10 10:32, hackingKK wrote:

Instead of using the library directly,
isn't python-twisted a better choice?


Why?

--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc

2010-03-14 Thread hackingKK

Instead of using the library directly,
isn't python-twisted a better choice?

happy hacking.
Krishnakant.

On Sunday 14 March 2010 03:47 PM, Martin P. Hellwig wrote:

On 03/14/10 08:14, ahmet erdinc yilmaz wrote:

Hello,

Recenetly we are developing a senior project and decide to use 
xmlrpclib.

However I have some questions. In the documentation I could not find any
clue about
handling requests? Does the server handles each request in a separate
thread? Or is
there some queuing mechanism for client calls? Thanks in advance.


--erdinc


How I usually tackle stuff like this:
[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Jan 31 2010, 20:52:16)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import SimpleXMLRPCServer
>>> help(SimpleXMLRPCServer)

CLASSES

BaseHTTPServer.BaseHTTPRequestHandler(SocketServer.StreamRequestHandler)
SimpleXMLRPCRequestHandler
SimpleXMLRPCDispatcher
CGIXMLRPCRequestHandler
SimpleXMLRPCServer(SocketServer.TCPServer, 
SimpleXMLRPCDispatcher)

SocketServer.TCPServer(SocketServer.BaseServer)
SimpleXMLRPCServer(SocketServer.TCPServer, 
SimpleXMLRPCDispatcher)


Aah so it is based on SocketServer, lets have a look at that:

>>> import SocketServer
>>> help(SocketServer)
Help on module SocketServer:


There are five classes in an inheritance diagram, four of which 
represent

synchronous servers of four types:

++
| BaseServer |
++
  |
  v
+---++--+
| TCPServer |--->| UnixStreamServer |
+---++--+
  |
  v
+---+++
| UDPServer |--->| UnixDatagramServer |
+---+++

So the base of all these servers is BaseServer, hmm somebody must have 
a laugh right now :-)


Okay lets have a look at that then:

>>> import BaseServer
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named BaseServer

Hmmm okay, lets have a look at the SocketServer source itself then, 
but where is it?

>>> SocketServer.__file__
'/usr/local/lib/python2.6/SocketServer.pyc'

I bet that the non compiled file is in the same directory, let's have 
a look at it with less.


>>> quit()
[mar...@aspire8930 /usr/home/martin]$ less 
/usr/local/lib/python2.6/SocketServer.py


And there it says among other interesting stuff:

# The distinction between handling, getting, processing and
# finishing a request is fairly arbitrary.  Remember:
#
# - handle_request() is the top-level call.  It calls
#   select, get_request(), verify_request() and process_request()
# - get_request() is different for stream or datagram sockets
# - process_request() is the place that may fork a new process
#   or create a new thread to finish the request
# - finish_request() instantiates the request handler class;
#   this constructor will handle the request all by itself

def handle_request(self):
"""Handle one request, possibly blocking.

Respects self.timeout.
"""
# Support people who used socket.settimeout() to escape
# handle_request before self.timeout was available.
timeout = self.socket.gettimeout()
if timeout is None:
timeout = self.timeout
elif self.timeout is not None:
timeout = min(timeout, self.timeout)
fd_sets = select.select([self], [], [], timeout)
if not fd_sets[0]:
self.handle_timeout()
return
self._handle_request_noblock()

def _handle_request_noblock(self):
"""Handle one request, without blocking.

I assume that select.select has returned that the socket is
readable before this function was called, so there should be
no risk of blocking in get_request().
"""
try:
request, client_address = self.get_request()
except socket.error:
return
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
self.close_request(request)


I leave the remaining parts of your question as an exercise :-)



--
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc

2010-03-14 Thread Martin P. Hellwig

On 03/14/10 08:14, ahmet erdinc yilmaz wrote:

Hello,

Recenetly we are developing a senior project and decide to use xmlrpclib.
However I have some questions. In the documentation I could not find any
clue about
handling requests? Does the server handles each request in a separate
thread? Or is
there some queuing mechanism for client calls? Thanks in advance.


--erdinc


How I usually tackle stuff like this:
[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Jan 31 2010, 20:52:16)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import SimpleXMLRPCServer
>>> help(SimpleXMLRPCServer)

CLASSES

BaseHTTPServer.BaseHTTPRequestHandler(SocketServer.StreamRequestHandler)
SimpleXMLRPCRequestHandler
SimpleXMLRPCDispatcher
CGIXMLRPCRequestHandler
SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher)
SocketServer.TCPServer(SocketServer.BaseServer)
SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher)

Aah so it is based on SocketServer, lets have a look at that:

>>> import SocketServer
>>> help(SocketServer)
Help on module SocketServer:


There are five classes in an inheritance diagram, four of which 
represent

synchronous servers of four types:

++
| BaseServer |
++
  |
  v
+---++--+
| TCPServer |--->| UnixStreamServer |
+---++--+
  |
  v
+---+++
| UDPServer |--->| UnixDatagramServer |
+---+++

So the base of all these servers is BaseServer, hmm somebody must have a 
laugh right now :-)


Okay lets have a look at that then:

>>> import BaseServer
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named BaseServer

Hmmm okay, lets have a look at the SocketServer source itself then, but 
where is it?

>>> SocketServer.__file__
'/usr/local/lib/python2.6/SocketServer.pyc'

I bet that the non compiled file is in the same directory, let's have a 
look at it with less.


>>> quit()
[mar...@aspire8930 /usr/home/martin]$ less 
/usr/local/lib/python2.6/SocketServer.py


And there it says among other interesting stuff:

# The distinction between handling, getting, processing and
# finishing a request is fairly arbitrary.  Remember:
#
# - handle_request() is the top-level call.  It calls
#   select, get_request(), verify_request() and process_request()
# - get_request() is different for stream or datagram sockets
# - process_request() is the place that may fork a new process
#   or create a new thread to finish the request
# - finish_request() instantiates the request handler class;
#   this constructor will handle the request all by itself

def handle_request(self):
"""Handle one request, possibly blocking.

Respects self.timeout.
"""
# Support people who used socket.settimeout() to escape
# handle_request before self.timeout was available.
timeout = self.socket.gettimeout()
if timeout is None:
timeout = self.timeout
elif self.timeout is not None:
timeout = min(timeout, self.timeout)
fd_sets = select.select([self], [], [], timeout)
if not fd_sets[0]:
self.handle_timeout()
return
self._handle_request_noblock()

def _handle_request_noblock(self):
"""Handle one request, without blocking.

I assume that select.select has returned that the socket is
readable before this function was called, so there should be
no risk of blocking in get_request().
"""
try:
request, client_address = self.get_request()
except socket.error:
return
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
self.close_request(request)


I leave the remaining parts of your question as an exercise :-)

--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-14 Thread Mahi Haile
-- Forwarded message --
> From: "Gabriel Genellina" 
> To: python-list@python.org
> Date: Wed, 14 Oct 2009 00:52:13 -0300
> Subject: Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call
> En Mon, 12 Oct 2009 18:58:45 -0300, Mahi Haile 
> escribió:
>
>  Hello all,I have an xml-rpc server running on a machine in the same LAN as
>> the client. Both the server and the client are in Python.
>>
>> When I have a series of xmlrepc calls from the client to the server, the
>> first call usually takes much longer than it should - orders of magnitude.
>> The latency is usually sub-10ms on the other calls, but the first call
>> takes
>> up to 10 seconds or so. This are very simple functions, with almost no
>> computation.
>>
>> Do you have any ideas?
>>
>
> I doubt this is a Python problem. I'd look into the network: DNS
> resolution, IPv6 (Windows XP has some timeout issues with IPv6 enabled).
>
> --
> Gabriel Genellina
>
> That seems to be correct. The machine is behind a NAT, so that is probably
why. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-13 Thread Gabriel Genellina
En Mon, 12 Oct 2009 18:58:45 -0300, Mahi Haile  
 escribió:


Hello all,I have an xml-rpc server running on a machine in the same LAN  
as

the client. Both the server and the client are in Python.

When I have a series of xmlrepc calls from the client to the server, the
first call usually takes much longer than it should - orders of  
magnitude.
The latency is usually sub-10ms on the other calls, but the first call  
takes

up to 10 seconds or so. This are very simple functions, with almost no
computation.

Do you have any ideas?


I doubt this is a Python problem. I'd look into the network: DNS  
resolution, IPv6 (Windows XP has some timeout issues with IPv6 enabled).


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC

2008-10-26 Thread Stefan Behnel
asit wrote:
> what is XML-RPC System 

Doesn't Wikipedia tell you that?

Stefan
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML RPC Problem....

2008-09-13 Thread Usman Ajmal
Yeah right but i don't see something wrong in my server's code. Following is
my server's simple code

import SimpleXMLRPCServer
#server = ServerProxy("http://betty.userland.com";)
class AuthenticationFunctions:

def s(self):
print "something..."

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(AuthenticationFunctions())

server.serve_forever()

and following is what i get when i run my client.

Traceback (most recent call last):
  File "ppkey.py", line 48, in 
caller()
  File "ppkey.py", line 45, in caller
print server.s()
  File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
  File "/usr/lib/python2.5/xmlrpclib.py", line 1191, in request
headers
xmlrpclib.ProtocolError: 


On Sat, Sep 13, 2008 at 12:37 PM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> Usman Ajmal wrote:
>
>  Problem is that when i start client (while the server is already running),
>> i get an error i.e.
>> Error 500 Internal Server Error
>>
>
> that's a server error, not a client error.  check the server logs (e.g.
> error.log or similar).
>
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh

Usman Ajmal wrote:

Problem is that when i start client (while the server is already 
running), i get an error i.e.

Error 500 Internal Server Error


that's a server error, not a client error.  check the server logs (e.g. 
error.log or similar).




--
http://mail.python.org/mailman/listinfo/python-list


Re: XML RPC Problem....

2008-09-13 Thread Usman Ajmal
Problem is that when i start client (while the server is already running), i
get an error i.e.
Error 500 Internal Server Error

On Sat, Sep 13, 2008 at 3:58 PM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> Usman Ajmal wrote:
>
>  Where exactly should i call ServerProxy? Following is the code from my
>> client.py
>>
>
> ServerProxy is the preferred name.  Server is an old alias for the same
> class.
>
>  t = SecureTransport()
>>  t.set_authorization(ustring, text_ucert)
>>server = xmlrpclib.Server('http://localhost:8000/',transport=t)
>>print server.s()
>>
>
> that code looks correct.  so what's the problem?
>
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh

Usman Ajmal wrote:

Where exactly should i call ServerProxy? Following is the code from my 
client.py


ServerProxy is the preferred name.  Server is an old alias for the same 
class.



t = SecureTransport()
   
t.set_authorization(ustring, text_ucert)

server = xmlrpclib.Server('http://localhost:8000/',transport=t)
print server.s()


that code looks correct.  so what's the problem?



--
http://mail.python.org/mailman/listinfo/python-list


Re: XML RPC Problem....

2008-09-13 Thread Usman Ajmal
Where exactly should i call ServerProxy? Following is the code from my
client.py

t = SecureTransport()

   t.set_authorization(ustring, text_ucert)
server = xmlrpclib.Server('http://localhost:8000/',transport=t)
print server.s()

Note: Full code for client is here at http://privatepaste.com/b56oS1Xa7P

and following is my server code

import SimpleXMLRPCServer
#server = ServerProxy("http://betty.userland.com";)
class AuthenticationFunctions:

def s(self):
print "something..."

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(AuthenticationFunctions())

server.serve_forever()


On Sat, Sep 13, 2008 at 8:44 AM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> Usman Ajmal wrote:
>
>  Please explain the arguments of send_request. What exactly are the
>> connection, handler and request_body? It will be really helpful if you give
>> an example of how do i call send_request
>>
>
> you don't call send_request.  you should pass the SecureTransport instance
> as an argument to the ServerProxy, which will then use it to talk to the
> server.  see the "custom transport" example in the library reference that I
> pointed you to.
>
>  http://www.python.org/doc/lib/xmlrpc-client-example.html
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh

Usman Ajmal wrote:

Please explain the arguments of send_request. What exactly are the 
connection, handler and request_body? It will be really helpful if you 
give an example of how do i call send_request


you don't call send_request.  you should pass the SecureTransport 
instance as an argument to the ServerProxy, which will then use it to 
talk to the server.  see the "custom transport" example in the library 
reference that I pointed you to.


  http://www.python.org/doc/lib/xmlrpc-client-example.html



--
http://mail.python.org/mailman/listinfo/python-list


Re: XML RPC Problem....

2008-09-13 Thread Usman Ajmal
Please explain the arguments of send_request. What exactly are the
connection, handler and request_body? It will be really helpful if you give
an example of how do i call send_request

On Thu, Sep 11, 2008 at 7:18 AM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> Usman Ajmal wrote:
>
>  And i also fount that a typical system.auth call will look like:
>>
>> POST /xmlrpc/clarens_server.py HTTP/1.0
>> Host: localhost
>> User-Agent: xmlrpclib.py/0.9.9 (by www.pythonware.com <
>> http://www.pythonware.com>)
>>
>> Content-Type: text/xml
>> Content-Length: 105
>> AUTHORIZATION: Basic MkhVTm9VazYxbXArVEZLS0dCY2tIRlA3bjVzPQo6RnJvbSBi
>> 
>> 
>>  system.auth
>>
>>  
>>  
>> 
>>
>>
>> Problem is that i don't know how do i generate above xml system.auth call.
>> Can anyone please tell me how do call a function, setting the header of the
>> call too?
>>
>
> you need to plugin a custom transport.  see this page for an example:
>
>http://www.python.org/doc/lib/xmlrpc-client-example.html
>
> in your case, it should be sufficient to override send_request, e.g.
> (untested):
>
>class SecureTransport(xmlrpclib.Transport):
>
>def set_authorization(self, ustring, text_ucert):
>self.authoriation = encodestring(
>"%s:%s" % (ustring,text_ucert)
>)
>
>def send_request(self, connection, handler, request_body):
>connection.putrequest("POST", handler)
>connection.putheader("Authorization",
>"Basic %s" % self.authorization
>)
>
> and instantiate the transport by doing
>
>t = SecureTransport()
>t.set_authorization(ustring, text_ucert)
>
> before passing to the server proxy.
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: XML-RPC "filter"

2008-09-12 Thread luigi . paioro
On 11 Set, 18:45, Richard Levasseur <[EMAIL PROTECTED]> wrote:
> Because he wants to insert parameters at the very start, he can
> probably get away with modifying the xml directly.  Just find the
> position of the  (i think thats the tag) and insert the xml
> you need after it.  Its pretty dirty, but would work.  The wire format
> isn't that complicated.

I think this is exactly what I do... isn't it?
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC "filter"

2008-09-11 Thread Richard Levasseur
On Sep 10, 2:04 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] schrieb:
>
>
>
> > On 9 Set, 17:55, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> >> I would go for a slightly different approach: make your server have a
> >> dispatch-method that delegates the calls to the underlying actual
> >> implementation. But *before* that happens, extract the information as
> >> above, and either
>
> >>  - prepend it to the argument list
>
> >>  - stuff it into threadlocal variables, and only access these if needed in
> >> your implementation.
>
> >> Diez
>
> > Are you suggesting me to overwrite the _dispatch(self, method, params)
> > method of SimpleXMLRPCDispatcher? I thought to this possibility, but
> > it only accepts "method" and "params" as arguments, so, as far as I
> > know, I have no way to get the user and host address to append.
>
> > Perhaps I've misunderstood your suggestion... in that case can you
> > post a short example?
>
> Ah, darn. Yes, you are right of course, the information itself is not
> available, as you don't have access to the request. I gotta ponder this
> a bit more.
>
> Diez

Because he wants to insert parameters at the very start, he can
probably get away with modifying the xml directly.  Just find the
position of the  (i think thats the tag) and insert the xml
you need after it.  Its pretty dirty, but would work.  The wire format
isn't that complicated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML RPC Problem....

2008-09-11 Thread Usman Ajmal
Thanks for ur help. But now i am getting an error

xmlrpclib.ProtocolError: 


Here is my code at http://privatepaste.com/d81Kut9AFj

Any idea what wrong am i doing?

On Thu, Sep 11, 2008 at 7:18 AM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> Usman Ajmal wrote:
>
>  And i also fount that a typical system.auth call will look like:
>>
>> POST /xmlrpc/clarens_server.py HTTP/1.0
>> Host: localhost
>> User-Agent: xmlrpclib.py/0.9.9 (by www.pythonware.com <
>> http://www.pythonware.com>)
>>
>> Content-Type: text/xml
>> Content-Length: 105
>> AUTHORIZATION: Basic MkhVTm9VazYxbXArVEZLS0dCY2tIRlA3bjVzPQo6RnJvbSBi
>> 
>> 
>>  system.auth
>>
>>  
>>  
>> 
>>
>>
>> Problem is that i don't know how do i generate above xml system.auth call.
>> Can anyone please tell me how do call a function, setting the header of the
>> call too?
>>
>
> you need to plugin a custom transport.  see this page for an example:
>
>http://www.python.org/doc/lib/xmlrpc-client-example.html
>
> in your case, it should be sufficient to override send_request, e.g.
> (untested):
>
>class SecureTransport(xmlrpclib.Transport):
>
>def set_authorization(self, ustring, text_ucert):
>self.authoriation = encodestring(
>"%s:%s" % (ustring,text_ucert)
>)
>
>def send_request(self, connection, handler, request_body):
>connection.putrequest("POST", handler)
>connection.putheader("Authorization",
>"Basic %s" % self.authorization
>)
>
> and instantiate the transport by doing
>
>t = SecureTransport()
>t.set_authorization(ustring, text_ucert)
>
> before passing to the server proxy.
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: XML RPC Problem....

2008-09-11 Thread Fredrik Lundh

Usman Ajmal wrote:


And i also fount that a typical system.auth call will look like:

POST /xmlrpc/clarens_server.py HTTP/1.0
Host: localhost
User-Agent: xmlrpclib.py/0.9.9 (by www.pythonware.com 
)

Content-Type: text/xml
Content-Length: 105
AUTHORIZATION: Basic MkhVTm9VazYxbXArVEZLS0dCY2tIRlA3bjVzPQo6RnJvbSBi


  system.auth

  
  



Problem is that i don't know how do i generate above xml system.auth 
call. Can anyone please tell me how do call a function, setting the 
header of the call too?


you need to plugin a custom transport.  see this page for an example:

http://www.python.org/doc/lib/xmlrpc-client-example.html

in your case, it should be sufficient to override send_request, e.g. 
(untested):


class SecureTransport(xmlrpclib.Transport):

def set_authorization(self, ustring, text_ucert):
self.authoriation = encodestring(
"%s:%s" % (ustring,text_ucert)
)

def send_request(self, connection, handler, request_body):
connection.putrequest("POST", handler)
connection.putheader("Authorization",
"Basic %s" % self.authorization
)

and instantiate the transport by doing

t = SecureTransport()
t.set_authorization(ustring, text_ucert)

before passing to the server proxy.



--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC "filter"

2008-09-10 Thread Diez B. Roggisch

[EMAIL PROTECTED] schrieb:

On 9 Set, 17:55, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

I would go for a slightly different approach: make your server have a
dispatch-method that delegates the calls to the underlying actual
implementation. But *before* that happens, extract the information as
above, and either

 - prepend it to the argument list

 - stuff it into threadlocal variables, and only access these if needed in
your implementation.

Diez


Are you suggesting me to overwrite the _dispatch(self, method, params)
method of SimpleXMLRPCDispatcher? I thought to this possibility, but
it only accepts "method" and "params" as arguments, so, as far as I
know, I have no way to get the user and host address to append.

Perhaps I've misunderstood your suggestion... in that case can you
post a short example?


Ah, darn. Yes, you are right of course, the information itself is not 
available, as you don't have access to the request. I gotta ponder this 
a bit more.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC "filter"

2008-09-10 Thread Richard Levasseur
On Sep 9, 8:53 am, Luigi <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I'm writing an XML-RPC server which should be able to modify the
> incoming request before dispatching it. In particular I wand to added
> two fixed parameters to the method called: one is the client host
> address, and the other is the user name provided as for Basic
> Authentication (http://[EMAIL PROTECTED]).
>
> To do this, at the present I've overwritten the do_POST method of
> SimpleXMLRPCRequestHandler, including at a certain point this code:
>
> 
> data = ''.join(L)
>
> params, method = xmlrpclib.loads(data)
> user = "unknown"
> if self.headers.has_key('Authorization'):
>   # handle Basic authentication
>   (enctype, encstr) =  self.headers.get('Authorization').split()
>   user, password = base64.standard_b64decode(encstr).split(':')
> params = list(params)
> params.append(self.address_string())
> params.append(user)
> params = tuple(params)
> data = xmlrpclib.dumps(params, methodname=method)
>
> (I slightly modified it to make it more readable at mail level)
>
> It works, but I don't really like it because it completely overwrites
> the do_POST method that in the future Python releases is going to
> change (I verified it). Do you know a better way to do this?
>
> Thanks in advance.
>
> Luigi

I actually wrote a wsgi module for almost this -exact- use case
(having to prepend a user/password to the method calls).  The simple
rpc server and dispatchers didn't give me enough control over the
behavior, so I had to reimplement all the logic surround the loads/
dumps calls, and eventually that just turned into the bulk of the
whole SimpleXMLRPCServer module.  There's a lot of tight coupling in
the _dispatch method, so you'll have to override, monkey patch, or
reimplement it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC "filter"

2008-09-10 Thread luigi . paioro
On 9 Set, 17:55, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> I would go for a slightly different approach: make your server have a
> dispatch-method that delegates the calls to the underlying actual
> implementation. But *before* that happens, extract the information as
> above, and either
>
>  - prepend it to the argument list
>
>  - stuff it into threadlocal variables, and only access these if needed in
> your implementation.
>
> Diez

Are you suggesting me to overwrite the _dispatch(self, method, params)
method of SimpleXMLRPCDispatcher? I thought to this possibility, but
it only accepts "method" and "params" as arguments, so, as far as I
know, I have no way to get the user and host address to append.

Perhaps I've misunderstood your suggestion... in that case can you
post a short example?

Thank you very much!

Luigi
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC "filter"

2008-09-09 Thread Diez B. Roggisch
Luigi wrote:

> Dear all,
> 
> I'm writing an XML-RPC server which should be able to modify the
> incoming request before dispatching it. In particular I wand to added
> two fixed parameters to the method called: one is the client host
> address, and the other is the user name provided as for Basic
> Authentication (http://[EMAIL PROTECTED]).
> 
> To do this, at the present I've overwritten the do_POST method of
> SimpleXMLRPCRequestHandler, including at a certain point this code:
> 
> 
> data = ''.join(L)
> 
> params, method = xmlrpclib.loads(data)
> user = "unknown"
> if self.headers.has_key('Authorization'):
>   # handle Basic authentication
>   (enctype, encstr) =  self.headers.get('Authorization').split()
>   user, password = base64.standard_b64decode(encstr).split(':')
> params = list(params)
> params.append(self.address_string())
> params.append(user)
> params = tuple(params)
> data = xmlrpclib.dumps(params, methodname=method)
> 
> (I slightly modified it to make it more readable at mail level)
> 
> It works, but I don't really like it because it completely overwrites
> the do_POST method that in the future Python releases is going to
> change (I verified it). Do you know a better way to do this?

I would go for a slightly different approach: make your server have a
dispatch-method that delegates the calls to the underlying actual
implementation. But *before* that happens, extract the information as
above, and either

 - prepend it to the argument list

 - stuff it into threadlocal variables, and only access these if needed in
your implementation.

Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc timeout

2007-09-24 Thread Steve Holden
Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Steve
> Holden wrote:
> 
>> Timeouts shouldn't be a normal feature of TCP communications.
> 
> On the contrary, they should. How else are you going to detect that the
> other side has died?

You missed the point, which is that TCP hosts shouldn't normally die. In 
other words, if timeout code is regularly invoked in communicating with 
a specific host, that host is likely at fault.

Naturally timeouts are useful for detecting dropped communications.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc timeout

2007-09-22 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve
Holden wrote:

> Timeouts shouldn't be a normal feature of TCP communications.

On the contrary, they should. How else are you going to detect that the
other side has died?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc timeout

2007-09-21 Thread Steve Holden
Jd wrote:
> Steve Holden wrote:
>> Jd wrote:
>>> Hi
>>>I have a multi-threaded application. For certain operations to the
>>> server, I would like to explicitly set timeout so that I get correct
>>> status from the call and not timed out exception.
>>>Does anyone know how to go about doing it ?
>>>
>> The easiest way is to use socket.setdefaulttimeout() to establish a
>> longer timeout period for all sockets, I guess. It's difficult to
>> establish different timeouts for individual sockets when they aren't
>> opened directly by your own code (though each socket does also have a
>> method to set its timeout period).
>>
>> regards
>>  Steve
> 
> Ya.. the problem here is that I donot have acces to the socket. I have
> written my own transport etc.. but when the socket is getting created,
> there is no context for the method and where I know what method I am
> going to call, I do not have access to socket.
> 
But you are writing Python, so you can write

import socket
socket.setdefaulttimeout(60)

and this will apply to all sockets that on't have their own explicit 
timeouts applied. Give it a try.

> I would have thought this to be an easy thing to achieve. In order to
> make xml-rpc easy to use.. it has become difficult to control.
> 
You might also ask why your server *is* timing out. Timeouts shouldn't 
be a normal feature of TCP communications. Is there a reason of rthis 
anomalous behavior, or are you perhaps trying to solve the wrong problem?

> Anyone have any other ideas ?
> 
That's all from me!

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc timeout

2007-09-21 Thread Jd
Steve Holden wrote:
> Jd wrote:
>> Hi
>>I have a multi-threaded application. For certain operations to the
>> server, I would like to explicitly set timeout so that I get correct
>> status from the call and not timed out exception.
>>Does anyone know how to go about doing it ?
>>
> The easiest way is to use socket.setdefaulttimeout() to establish a
> longer timeout period for all sockets, I guess. It's difficult to
> establish different timeouts for individual sockets when they aren't
> opened directly by your own code (though each socket does also have a
> method to set its timeout period).
> 
> regards
>  Steve

Ya.. the problem here is that I donot have acces to the socket. I have
written my own transport etc.. but when the socket is getting created,
there is no context for the method and where I know what method I am
going to call, I do not have access to socket.

I would have thought this to be an easy thing to achieve. In order to
make xml-rpc easy to use.. it has become difficult to control.

Anyone have any other ideas ?

/Jd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc timeout

2007-09-21 Thread Steve Holden
Jd wrote:
> Hi
>I have a multi-threaded application. For certain operations to the
> server, I would like to explicitly set timeout so that I get correct
> status from the call and not timed out exception.
>Does anyone know how to go about doing it ?
> 
The easiest way is to use socket.setdefaulttimeout() to establish a 
longer timeout period for all sockets, I guess. It's difficult to 
establish different timeouts for individual sockets when they aren't 
opened directly by your own code (though each socket does also have a 
method to set its timeout period).

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC SSL and client side certs?

2007-04-11 Thread Martin v. Löwis
Jeff McNeil schrieb:
> I apologize for not giving you a Python specific answer, but for the
> XMLRPC services I've deployed, I front them with Apache and proxy back
> to localhost:8080.
> 
> I do all of the encryption and authentication from within the Apache
> proper and rely on mod_proxy to forward validated requests on.  I've
> settled on basic authentication, but I see no reason why you couldn't
> take advantage of mod_ssl.

There is an issue with forwarding SSL connections, of course: it
is not possible - at least not with the same client identity as
the original user.

In turn, it's not easy to forward the identity of the authenticated
user, either: even though Apache will know who he is, it has no
way of telling on the forwarded request.

So you would have to use CGI or mod_python in this case.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC SSL and client side certs?

2007-04-10 Thread Jeff McNeil
I apologize for not giving you a Python specific answer, but for the
XMLRPC services I've deployed, I front them with Apache and proxy back
to localhost:8080.

I do all of the encryption and authentication from within the Apache
proper and rely on mod_proxy to forward validated requests on.  I've
settled on basic authentication, but I see no reason why you couldn't
take advantage of mod_ssl.

Thanks, hope that helps. Just another option, really.

Jeff




On 10 Apr 2007 14:43:40 -0700, Eli Criffield <[EMAIL PROTECTED]> wrote:
>
> Does anyone have an example setup of a XML-RPC sever using client side
> certs for authentication?
>
> And instead of having a list of certs allowed to connect, I'd like to
> allow any cert signed by my CA.
>
> It doesn't seem like it would be to hard to do and I'll probably spend
> some time setting it up here soon, but would be interested if anyone
> else has already written a solution like this or has used one (in
> python of course).
>
> Eli Criffield
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-07 Thread jbrewer
Thank you very much, Fredrik.  Your code and suggestion worked
perfectly.  I haven't benchmarked the plain HTTP post vs Binary
wrapper, but strangely even using the naive Binary wrapper in Python
sends files much faster than how Java + Axis wraps byte arrays in SOAP
messages.

Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server-client communication

2006-07-06 Thread Stefka
no, its an extern IP adress. For my needs the server and the client
must be on different machines. But I opened the port and it worked.
Thanks anyway :)

Greetz,
Stefka

Marco Aschwanden wrote:
> > server = SimpleXMLRPCServer.SimpleXMLRPCServer(("xxx.xxx.xxx.xxx",
> > 22999))
>
> Could it be that xxx.xxx.xxx.xxx stands for '127.0.0.1'? If so... rename
> it to 'localhost'. If you bind a port to 127.0.0.1 it will be found only
> on the same machine.
> Greetings,
> Marco

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-06 Thread Tal Einat
I have recently implemented a system where clients connect to an RPC
server (RPyC in my case), run a webserver on the RPC server, and close
the webserver when they're done with it.

To do this I wrote a ServerThread class which wraps a SimpleHTTPServer,
runs as a thread, and can be signalled to stop. The ServerThread class
doesn't use the server_forever() method (which is just "while 1:
self.handle_request()"), instead it has a while loop which checks a
flag which is signalled from outside.

We need to set a timeout for the handle_request() call. The first thing
I tried was to use Python's socket object's new 'set_timeout' method,
but I found it caused mysterious errors to occur on my WindowsXP
machine :(  Instead I call select() on the server's listening socket to
check for incoming requests, and only then call handle_request().
select()'s timeout works :)


# This is the heart of the code - the request handling loop:
while not self.close_flag.isSet():
# Use select() to check if there is an incoming request
r,w,e = select.select([self.server.socket], [], [],
self.timeout)
if r:
self.server.handle_request()

# The stop method should be called to stop the request handling loop
def stop(self, wait=False):
self.close_flag.set()
if wait:
while self.isAlive(): # isAlive() is inherited from
threading.Thread
time.sleep(self.timeout/10.0)

(in my case, self.stop_flag is a threading.Event object)


Good luck!

jbrewer wrote:
> I'm currently implementing an XML-RPC service in Python where binary
> data is sent to the server via URLs.  However, some clients that need
> to access the server may not have access to a web server, and I need to
> find a solution.  I came up with the idea of embedding a simple HTTP
> server in the XML-RPC clients so that files can be sent in the
> following way:
>
> 1.  Start an HTTP server on the client using e.g SImpleHTTPServer on a
> user allowed port
> 2.  Call XML-RPC server with the URL to the file on the client to
> upload
> 3.  Get XML-RPC server response, then shut down HTTP server on client
>
> Does this sound reasonable?  I know that XML-RPC can send binary data,
> but I presume that the URL method would be faster because the XML
> parser could skip reading the binary file (is it base64 encoded as a
> string like in SOAP?).
>
> Anyway, I'm unsure of how to implement this in Python.  In particular,
> how do I shut down a web server once I've started it with
> server_forever()?  Should I run the server in a separate thread or run
> it asynchronously?  Since I'm only uploading one file I don't really
> need to handle multiple clients; I just need to be able to shut the
> server down once remote call has finished.
>
> Any help would be appreciated since I'm new to network programming.
> 
> Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server-client communication

2006-07-06 Thread Marco Aschwanden
> server = SimpleXMLRPCServer.SimpleXMLRPCServer(("xxx.xxx.xxx.xxx",
> 22999))

Could it be that xxx.xxx.xxx.xxx stands for '127.0.0.1'? If so... rename  
it to 'localhost'. If you bind a port to 127.0.0.1 it will be found only  
on the same machine.
Greetings,
Marco

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread jbrewer
OK, I posted my previous message before I saw your reply on how to
handle the server side.  On the client side, should I use
httplib.HTTPConnection.request() to upload the data or can I do this
through xmlrpc.ServerProxy objects?

Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread jbrewer
Fredrik Lundh wrote:

> the XML-RPC protocol uses HTTP POST, so if you can handle XML-RPC, you
> should be able to handle any POST request.  what server are you using ?

I need some clarification of your suggestion.  Instead of sending URLs,
I could read the file as a string, create a Binary object, and send
that via XML-RPC.  The parameters will be sent to the server via HTTP
POST.  However, the file will be encoded as a base64 string and
included in the body of the XML-RPC message, so it will have to be
parsed by the server.  In my experience with SOAP, I have found this to
be extremely inefficient.

Are you suggesting sending the file separately thought a 2nd HTTP POST
with no XML-RPC message body?  I guess the POST request would look
something like:

POST /path/file HTTP/1.0
From: ...
User-Agent: ...
Content-Type: /application/binary
Content-Length: 



I'm not sure how to add a 2nd request like this.  How would I alter a
simple call like that below to inlcude the 2nd post?  Do I need to use
httplib and the request() method of HTTPConnection?  Or can I make
POSTs through a ServerProxy object?

import xmlrpclib
server = xmlrpclib.ServerProxy("http://myserver";)
result = server.my_function(file, params)

Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread Fredrik Lundh
jbrewer wrote:

> Just SimpleXMLRPCServer from the standard library.

which means that you should be able to do something like

from SimpleXMLRPCServer import SimpleXMLRPCServer,\
  SimpleXMLRPCRequestHandler

class MyRequestHandler(SimpleXMLRPCRequestHandler):

 def do_POST(self):

if self.path != "/data":
return SimpleXMLRPCRequestHandler.do_POST(self)

 # handle POST to /data

bytes = int(self.headers["content-length"])

# copy 'bytes' bytes from self.rfile (in some way)
data = self.rfile.read(bytes)
# ... deal with data here ...

response = "OK"

self.send_response(200)
self.send_header("Content-type", "text/plain")
self.send_header("Content-length", str(len(response)))
self.end_headers()
self.wfile.write(response)
self.wfile.flush()
self.connection.shutdown(1)

SimpleXMLRPCServer((host, port), requestHandler=MyRequestHandler)



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread jbrewer
>What server are you using?

Just SimpleXMLRPCServer from the standard library.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread Fredrik Lundh
jbrewer wrote:

> Sorry for such a simple question, but how would I do this?  XML-RPC
> runs on top of HTTP, so can I do a POST without running a separate HTTP
> server?

the XML-RPC protocol uses HTTP POST, so if you can handle XML-RPC, you 
should be able to handle any POST request.  what server are you using ?



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread jbrewer
Fredrik Lundh wrote:

>why not just use an ordinary HTTP POST request ?

Sorry for such a simple question, but how would I do this?  XML-RPC
runs on top of HTTP, so can I do a POST without running a separate HTTP
server?

Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server-client communication

2006-07-05 Thread Stefka
Hi,

thanx for the hint :)! I ran a port scan and it turned out, that the
port was realy closed.
Thanx again!

greetz,
Stefka

Laszlo Nagy wrote:

> Please go to the machine where you php program resides, and check if the
> server is not blocked by firewall rules. For example, do
>
> telnet xxx.xxx.xxx.xxx 22999
>
> If it does not connect, then the problem is with your network or
> firewall settings. (I thought this is the most probable...)
> 
> Best,
> 
>Laszlo

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC + SimpleHTTPServer question

2006-07-05 Thread Fredrik Lundh
jbrewer wrote:

> I'm currently implementing an XML-RPC service in Python where binary
> data is sent to the server via URLs.  However, some clients that need
> to access the server may not have access to a web server, and I need to
> find a solution.  I came up with the idea of embedding a simple HTTP
> server in the XML-RPC clients so that files can be sent in the
> following way:
> 
> 1.  Start an HTTP server on the client using e.g SImpleHTTPServer on a
> user allowed port
> 2.  Call XML-RPC server with the URL to the file on the client to
> upload
> 3.  Get XML-RPC server response, then shut down HTTP server on client
> 
> Does this sound reasonable?

why not just use an ordinary HTTP POST request ?



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server-client communication

2006-07-05 Thread Laszlo Nagy
Stefka írta:
> Hi all,
>
> I try to implement a python xml-rpc server and call it from a php
> client. If the server and the client are on the same machine
> (localhost) the communication between them is just fine. When I start
> the server on a different host I don't get an answer.
>   
Please go to the machine where you php program resides, and check if the 
server is not blocked by firewall rules. For example, do

telnet xxx.xxx.xxx.xxx 22999

If it does not connect, then the problem is with your network or 
firewall settings. (I thought this is the most probable...)

Best,

   Laszlo
> What is missing there?? I tried also to set username and password,
> cause I thought there is an authenticate issue but it didn't work
> either.
>   

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc and 64-bit ints?

2006-05-02 Thread Martin v. Löwis
Mark Harrison wrote:
> I've got an API that deals with 64 bit int values.  Is there
> any way of handling this smoothly?  Right now I'm casting
> the values into and out of strings for the API.

In XML-RPC, everything is transmitted as a string, so I
don't think that choice is really that bad - except of
course for the additional clumsiness for invoking explicit
conversion functions.

But no, XML-RPC doesn't have a data type that can represent
integers above 2**32. If you can accept losing precision,
you can use doubles (but you still would have to convert
explicitly on the sender).

> If not, are there any nice alternatives to XML-RPC that
> support this?

CORBA certainly supports 64-bit integers.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jean-Paul Calderone
On Mon, 17 Apr 2006 14:17:51 +0200, Jos Vos <[EMAIL PROTECTED]> wrote:
>On Mon, Apr 17, 2006 at 12:42:00PM +0200, Fredrik Lundh wrote:
>
>> except that if the OP's expecting the other end to use an ordinary XML-RPC
>> library, he needs to implement some minimal HTTP handling as well.
>
>Which makes me wondering why the classes (this also applies to
>BaseHTTPServer / BaseHTTPRequestHandler) ae designed the way they
>are.  The underlying stream medium (TCP sockets or plain file
>streams like stdin/stdout) should not be integrated with the
>protocol (HTTP) handling, IMHO...
>

Twisted agrees.  A server that speaks real HTTP and real XML-RPC over stdin and 
stdout (untested ;):

from twisted.web import xmlrpc, server
from twisted.internet import stdio, reactor

class YourApplication(xmlrpc.XMLRPC):
def remote_somefunction(self, args):
...
return result

stdio.StandardIO(server.Site(YourApplication()))
reactor.run()

For more details, see .

Jean-Paul
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jos Vos
On Mon, Apr 17, 2006 at 12:42:00PM +0200, Fredrik Lundh wrote:

> except that if the OP's expecting the other end to use an ordinary XML-RPC
> library, he needs to implement some minimal HTTP handling as well.

Which makes me wondering why the classes (this also applies to
BaseHTTPServer / BaseHTTPRequestHandler) ae designed the way they
are.  The underlying stream medium (TCP sockets or plain file
streams like stdin/stdout) should not be integrated with the
protocol (HTTP) handling, IMHO...

-- 
--Jos Vos <[EMAIL PROTECTED]>
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jos Vos
On Mon, Apr 17, 2006 at 12:36:18PM +0200, Brian Quinlan wrote:

> I don't know exactly what your usage pattern is, but you might be able 
> to use SimpleXMLRPCDispatcher directly e.g.
> 
>  >>> s = SimpleXMLRPCDispatcher()
>  >>> s.register_function(pow)
>  >>> s._marshaled_dispatch(' '
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Fredrik Lundh
Nick Craig-Wood wrote:

> Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your
> distro) and in particular the definition of the CGIXMLRPCRequestHandler class.
>
> That looks as thought it almost, or maybe completely, does what you
> want, ie an XMLRPC subclass which reads from stdin and writes to
> stdout.

except that if the OP's expecting the other end to use an ordinary XML-RPC
library, he needs to implement some minimal HTTP handling as well.

import sys
import mimetools, xmlrpclib

command = sys.stdin.readline()
# optional: check command syntax (POST url HTTP/1.X)

headers = mimetools.Message(sys.stdin)
# optional: check content-type etc

bytes = int(headers.get("content-length", 0))
# optional: check request size, etc

params, method = xmlrpclib.loads(sys.stdin.read(bytes))

# handle the method
result = ...

# marshaller expects a tuple
result = (result, )

response = xmlrpclib.dumps(result, methodresponse=1)

print "HTTP/1.0 200 OK"
print "Content-Type: text/xml"
print "Content-Length:", len(response)
print
print response

(based on code from http://effbot.org/zone/xmlrpc-cgi.htm )





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Brian Quinlan
Jos Vos wrote:
> On Mon, Apr 17, 2006 at 03:30:04AM -0500, Nick Craig-Wood wrote:
> 
>> UTSL ;-)
>>
>> Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your
>> distro) and in particular the definition of the CGIXMLRPCRequestHandler 
>> class.
> 
> I did this before posting my question, in fact, but I did not look
> good enough maybe, as at first sight I thought tghe CGI... class
> would be too CGI-specific (it looks for environment variables etc.
> given by the HTTP server), but maybe it's good enough.

I don't know exactly what your usage pattern is, but you might be able 
to use SimpleXMLRPCDispatcher directly e.g.

 >>> s = SimpleXMLRPCDispatcher()
 >>> s.register_function(pow)
 >>> s._marshaled_dispatch('http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jos Vos
On Mon, Apr 17, 2006 at 03:30:04AM -0500, Nick Craig-Wood wrote:

> UTSL ;-)
> 
> Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your
> distro) and in particular the definition of the CGIXMLRPCRequestHandler class.

I did this before posting my question, in fact, but I did not look
good enough maybe, as at first sight I thought tghe CGI... class
would be too CGI-specific (it looks for environment variables etc.
given by the HTTP server), but maybe it's good enough.

> That looks as thought it almost, or maybe completely, does what you
> want, ie an XMLRPC subclass which reads from stdin and writes to
> stdout.

Will try...

-- 
--Jos Vos <[EMAIL PROTECTED]>
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jos Vos
On Mon, Apr 17, 2006 at 12:10:15PM +0200, Brian Quinlan wrote:

> If you take a look at CGIXMLRPCRequestHandler 
> (http://docs.python.org/lib/node564.html), you will see an example of 
> how to write an XMLRPCRequestHandler without HTTP.

Thanks, this might work for me, will try it.

-- 
--Jos Vos <[EMAIL PROTECTED]>
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Brian Quinlan
Jos Vos wrote:
> The problem is that I do not see how to let an SimpleXMLRPCServer
> instance *not* bind to a port or what other class I can use to just
> build a XML-RPC request handler reading/writing from stdin/stdout,
> i.s.o.  carrying all the server class stuff with it.

I think that the problem here is that we are confusing transport with 
request handling.

If you take a look at CGIXMLRPCRequestHandler 
(http://docs.python.org/lib/node564.html), you will see an example of 
how to write an XMLRPCRequestHandler without HTTP.

Cheers,
Brian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Jos Vos
On Mon, Apr 17, 2006 at 02:07:37AM +0200, Martin P. Hellwig wrote:

> If I understood it correctly you want the python server bind be 
> depending on whatever is configured in xinetd.conf and not be defined in 
> the your program itself?
> 
> I tested a bit around with my FreeBSD machine but indeed the OS 
> environment gives me nothing interesting back, leaving that option out 
> but I do can specify command line arguments so you could pick them up 
> with sys.argv.
> 
> I looked up how you can specify arguments in xinetd and according to 
> various resources I filtered out (gotta over these gnu type 
> documentation...) that you can use "server_args" in the per service 
> configuration to specify arguments.
> 
> Although not really elegant it is doable to do an on the fly port binding.
> 
> Now I just hope I understood your problem :-)

No, you didn't :-).  I could add these options or even write an
xinetd-only program, that's all fine with me.

The problem is that I do not see how to let an SimpleXMLRPCServer
instance *not* bind to a port or what other class I can use to just
build a XML-RPC request handler reading/writing from stdin/stdout,
i.s.o.  carrying all the server class stuff with it.

-- 
--Jos Vos <[EMAIL PROTECTED]>
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-17 Thread Nick Craig-Wood
Jos Vos <[EMAIL PROTECTED]> wrote:
>  I'm trying to figure out how to implement a XML-RPC server that
>  is called by xinetd i.s.o. listening on a TCP socket itself.
> 
>  I already have implemented a stand-alone XML-RPC server using
>  SimpleXMLRPCServer, but I now want something similar, that is
>  started via xinetd (i.e. reading/writing via stdin/stdout).
> 
>  Any hints or code examples?

UTSL ;-)

Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your
distro) and in particular the definition of the CGIXMLRPCRequestHandler class.

That looks as thought it almost, or maybe completely, does what you
want, ie an XMLRPC subclass which reads from stdin and writes to
stdout.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-16 Thread Martin P. Hellwig
Jos Vos wrote:

> 
> The problem is that the server initialization *requires* a server
> address (host, port pair), but I don't see how to tell it to use
> the stdin socket (and I'm afraid this is not possible, but I'm not
> sure).
> 

If I understood it correctly you want the python server bind be 
depending on whatever is configured in xinetd.conf and not be defined in 
the your program itself?

I tested a bit around with my FreeBSD machine but indeed the OS 
environment gives me nothing interesting back, leaving that option out 
but I do can specify command line arguments so you could pick them up 
with sys.argv.

I looked up how you can specify arguments in xinetd and according to 
various resources I filtered out (gotta over these gnu type 
documentation...) that you can use "server_args" in the per service 
configuration to specify arguments.

Although not really elegant it is doable to do an on the fly port binding.

Now I just hope I understood your problem :-)

-- 
mph
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-16 Thread Jos Vos
On Sun, Apr 16, 2006 at 10:13:19PM +0200, Martin P. Hellwig wrote:

> Isn't this just a standard daemon functionality?

What is "a standard daemon"? :-)

> So if you could wrap up your program in a daemon like fashion (e.g. 
> http://homepage.hispeed.ch/py430/python/daemon.py) and then point the 
> xinetd configuration to the right script, it should just work?

In fact, the standard use *is* a daemon (that is, accepting connections
on a certain port) and I want it to be *not* a daemon.  For the daemon
method I use something similar to "daemonize", but now I want it to
*not* do the binds etc. to listen on a port.

The problem is that the server initialization *requires* a server
address (host, port pair), but I don't see how to tell it to use
the stdin socket (and I'm afraid this is not possible, but I'm not
sure).

-- 
--Jos Vos <[EMAIL PROTECTED]>
--X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--Amsterdam, The Netherlands| Fax: +31 20 6948204
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC server via xinetd

2006-04-16 Thread Martin P. Hellwig
Jos Vos wrote:
> Hi,
> 
> I'm trying to figure out how to implement a XML-RPC server that
> is called by xinetd i.s.o. listening on a TCP socket itself.
> 
> I already have implemented a stand-alone XML-RPC server using
> SimpleXMLRPCServer, but I now want something similar, that is
> started via xinetd (i.e. reading/writing via stdin/stdout).
> 
> Any hints or code examples?
> 
> Thanks,
> 

Isn't this just a standard daemon functionality?
So if you could wrap up your program in a daemon like fashion (e.g. 
http://homepage.hispeed.ch/py430/python/daemon.py) and then point the 
xinetd configuration to the right script, it should just work?

Beware that I didn't try this myself yet ;-) though should do in the 
near future so if you could give a head ups on your progress I would 
appreciate it.

-- 
mph
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml-rpc - adodb - None type - DateTime type

2005-10-28 Thread infidel
> I can replace all None values with the string 'Null', there's no
> problem, but I can't detect the DateTime type object I retrieve from
> the database.
>
> I have something like this:
> def xmlrpc_function():
> conn = adodb.NewADOConnection('postgres')
> conn.Connect(host,user,password,database)
> rs = conn.Exec("select * from table")
> result = []
> i = 0
> while not rs.EOF:
> row = rs.GetRowAssoc(False)
> for key, value in row.items():
> if value==None:
> row[key]='Null'
> result.append(row)
> i = i + 1
> rs.MoveNext()
> rs.Close()
>
> print result
> return result
>
> The problem here is that if row[key] ==  etc...>, then I don't know what to do for detect it and make the
> appropriate change to string.
>
> Console output:
> [{'name': 'Null', 'date':  at 1515f60>}]
>
> If you consult the python manual, you'll see that there's no 'DateTime'
> type object, so I can't do something like:
>
> if value==DateTimeType:
> ...
>
> I only need to know which type of data is a field for make the change
> according to what can I pass through the xml-rpc.

Well, there is the possibility of passing null values through xml-rpc.
I believe there is an optional keyword argument in some of the
xmlrpclib functions to allow it.  Basically it translates None to
 in the xml.

The DateTime type must be defined somewhere.  Is it an adodb type?  If
so, you could do something like this:

if type(value) == adodb.DateTime:
...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-20 Thread Skip Montanaro

codecraig> stefan:  i added, "return 1" to my sendFile method on the 
server...took
codecraig> care of the error, thanks.

Yes, by default XML-RPC doesn't support objects like Python's None.  As the
error message indicated you have to enable allow_none to permit transmission
of None.

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread codecraig
stefan:  i added, "return 1" to my sendFile method on the server...took
care of the error, thanks.

f. petitjean: i cleaned up my code by closing the file, however, when i
tried your exact code above...i got stuck an infinite loop and my PC
speaker beeped over and over :)

thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread F. Petitjean
Le 19 Apr 2005 11:02:47 -0700, codecraig a écrit :
> Experient I have been :)
> 
> Here is what I am getting now
> 
> CLIENT
> ---
> d = xmlrpclib.Binary(open("C:\\somefile.exe").read())
open the file with mode "rb"
fin = open(r'C:\somefile.exe', 'rb')
contents = fin.read()
fin.close()
d = xmlrpclib.Binary(contents)

> server.sendFile(d)
> 
> any ideas?
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread Stefan Behnel
codecraig schrieb:
CLIENT
---
d = xmlrpclib.Binary(open("C:\\somefile.exe").read())
server.sendFile(d)
SERVER
--
def sendFile(tmp):
print "FILE:", tmp
This returns None. Don't know what XML-RPC expects, but you may either try 
to return something else from the function or make XML-RPC return nothing 
(don't know if that works).

xmlrpclib.Fault: 
The obvious error. :)
Stefan
--
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread codecraig
Experient I have been :)

Here is what I am getting now

CLIENT
---
d = xmlrpclib.Binary(open("C:\\somefile.exe").read())
server.sendFile(d)

SERVER
--
def sendFile(tmp):
print "FILE:", tmp

The server receives the file, because it prints it out, but on the
client I get this

xmlrpclib.Fault: 

so it sends it, but the client is getting an error.  The error occurs
on the, server.sendFile(d) line.

any ideas?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread Skip Montanaro

codecraig> how would I decode it?

Assuming you have Python at the other end and you get a Binary object
instead of a string, access its data attribute.  OTOH, xmlrpclib may
automatically decode the wrapper object for you.

In any case, I have two further recommendations:

* Check the xmlrpclib docs.

* Experiment.  Electrons are hardy fellows and hardly ever break at the
  energy levels present in modern computers.

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread codecraig
how would I decode it?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML-RPC -- send file

2005-04-19 Thread Skip Montanaro

codecraig> I thought i read somewhere that by using pickle or something,
codecraig> that u could get a string representation of your object (or a
codecraig> file in my case) and send that.  Any ideas?

Sure:

stuff = xmlrpclib.Binary(open(somefile).read())
server.call_some_remote_function(stuff)

At the other end a similar decoding will have to be done.

Skip


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML/RPC server with SSL in Python

2005-03-22 Thread news
Gerson Kurz wrote:
> Are there any alternatives to using M2Crypto for an XML/RPC server in
> SSL in Python?

tlslite supports SocketServers like SimpleXMLRPCServer:

http://trevp.net/tlslite


Trevor

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML/RPC server with SSL in Python

2005-03-22 Thread Paul Rubin
[EMAIL PROTECTED] (Gerson Kurz) writes:
> Are there any alternatives to using M2Crypto for an XML/RPC server in
> SSL in Python? 

stunnel?  (www.stunnel.org)
-- 
http://mail.python.org/mailman/listinfo/python-list