SimpleXMLRPCServer - disable output

C

codecraig

Hi,
I thought I posted this, but its been about 10min and hasnt shown up
on the group.
Basically I created a SimpleXMLRPCServer and when one of its methods
gets called and it returns a response to the client, the server prints
some info out to the console, such as,

localhost - - [14/Apr/2005 16:06:28] "POST /RPC2 HTTP/1.0" 200 -

Anyhow, is there a way I can surpress that so its not printed to the
console? I looked at SimpleXMLRPCServer.py ...it doesn't explicitly
print that, I think perhaps std is...but not sure. Any ideas??

thanks.
 
J

Jeremy Jones

codecraig said:
Hi,
I thought I posted this, but its been about 10min and hasnt shown up
on the group.
Basically I created a SimpleXMLRPCServer and when one of its methods
gets called and it returns a response to the client, the server prints
some info out to the console, such as,

localhost - - [14/Apr/2005 16:06:28] "POST /RPC2 HTTP/1.0" 200 -

Anyhow, is there a way I can surpress that so its not printed to the
console? I looked at SimpleXMLRPCServer.py ...it doesn't explicitly
print that, I think perhaps std is...but not sure. Any ideas??

thanks.
Here's the entire SimpleMLRPCServer class from SimpleXMLRPCServer.py:


class SimpleXMLRPCServer(SocketServer.TCPServer,
SimpleXMLRPCDispatcher):
"""Simple XML-RPC server.

Simple XML-RPC server that allows functions and a single instance
to be installed to handle requests. The default implementation
attempts to dispatch XML-RPC calls to the functions or instance
installed in the server. Override the _dispatch method inhereted
from SimpleXMLRPCDispatcher to change this behavior.
"""

def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
logRequests=1):
self.logRequests = logRequests

SimpleXMLRPCDispatcher.__init__(self)
SocketServer.TCPServer.__init__(self, addr, requestHandler)

You should be able to change logRequests to 0 and that should fix it. I just tested it at a prompt and it worked just fine.


Jeremy Jones
 
S

Skip Montanaro

codecraig> I thought I posted this, but its been about 10min and hasnt
codecraig> shown up on the group.

Patience...

codecraig> localhost - - [14/Apr/2005 16:06:28] "POST /RPC2 HTTP/1.0" 200 -

codecraig> Anyhow, is there a way I can surpress that so its not printed
codecraig> to the console? I looked at SimpleXMLRPCServer.py ...it
codecraig> doesn't explicitly print that, I think perhaps std is...but
codecraig> not sure. Any ideas??

Introspection is your friend:
... matches = [m for m in dir(getattr(SimpleXMLRPCServer, a))
... if m.find("log") != -1]
... if matches:
... print "***", a, "***"
... print matches
...
*** SimpleXMLRPCRequestHandler ***
['log_date_time_string', 'log_error', 'log_message', 'log_request']
*** os ***
['getlogin']

Skip
 
C

codecraig

Jeremy said:
codecraig said:
Hi,
I thought I posted this, but its been about 10min and hasnt shown up
on the group.
Basically I created a SimpleXMLRPCServer and when one of its methods
gets called and it returns a response to the client, the server prints
some info out to the console, such as,

localhost - - [14/Apr/2005 16:06:28] "POST /RPC2 HTTP/1.0" 200 -

Anyhow, is there a way I can surpress that so its not printed to the
console? I looked at SimpleXMLRPCServer.py ...it doesn't explicitly
print that, I think perhaps std is...but not sure. Any ideas??

thanks.
Here's the entire SimpleMLRPCServer class from SimpleXMLRPCServer.py:


class SimpleXMLRPCServer(SocketServer.TCPServer,
SimpleXMLRPCDispatcher):
"""Simple XML-RPC server.

Simple XML-RPC server that allows functions and a single instance
to be installed to handle requests. The default implementation
attempts to dispatch XML-RPC calls to the functions or instance
installed in the server. Override the _dispatch method inhereted
from SimpleXMLRPCDispatcher to change this behavior.
"""

def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
logRequests=1):
self.logRequests = logRequests

SimpleXMLRPCDispatcher.__init__(self)
SocketServer.TCPServer.__init__(self, addr, requestHandler)

You should be able to change logRequests to 0 and that should fix it.
I just tested it at a prompt and it worked just fine.
Jeremy Jones

Jeremy,
So can you explain what I can do to set logRequests = 0? Do i just
do..

server = SimpleXMLRPCServer(0) ???

I am sorta new to python thanks.
 
C

codecraig

Jeremy,
Thanks for clearing that up. I am so used to java (i.e.
foo.setLogRequests(0))...that I forgot I could just do, foo.logRequests
= 0.

Learning one day at a time :)

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top