SimpleXMLRPCServer - disable output

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • codecraig

    #1

    SimpleXMLRPCServer - disable output

    Hi,
    I thought I posted this, but its been about 10min and hasnt shown up
    on the group.
    Basically I created a SimpleXMLRPCSer ver 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 SimpleXMLRPCSer ver.py ...it doesn't explicitly
    print that, I think perhaps std is...but not sure. Any ideas??

    thanks.

  • Skip Montanaro

    #2
    Re: SimpleXMLRPCSer ver - disable output


    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 SimpleXMLRPCSer ver.py ...it
    codecraig> doesn't explicitly print that, I think perhaps std is...but
    codecraig> not sure. Any ideas??

    Introspection is your friend:
    [color=blue][color=green][color=darkred]
    >>> import SimpleXMLRPCSer ver
    >>> for a in dir(SimpleXMLRP CServer):[/color][/color][/color]
    ... matches = [m for m in dir(getattr(Sim pleXMLRPCServer , a))
    ... if m.find("log") != -1]
    ... if matches:
    ... print "***", a, "***"
    ... print matches
    ...
    *** SimpleXMLRPCReq uestHandler ***
    ['log_date_time_ string', 'log_error', 'log_message', 'log_request']
    *** os ***
    ['getlogin']

    Skip

    Comment

    • Jeremy Jones

      #3
      Re: SimpleXMLRPCSer ver - disable output

      codecraig wrote:
      [color=blue]
      >Hi,
      > I thought I posted this, but its been about 10min and hasnt shown up
      >on the group.
      > Basically I created a SimpleXMLRPCSer ver 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 SimpleXMLRPCSer ver.py ...it doesn't explicitly
      >print that, I think perhaps std is...but not sure. Any ideas??
      >
      >thanks.
      >
      >
      >[/color]
      Here's the entire SimpleMLRPCServ er class from SimpleXMLRPCSer ver.py:


      class SimpleXMLRPCSer ver(SocketServe r.TCPServer,
      SimpleXMLRPCDis patcher):
      """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 SimpleXMLRPCDis patcher to change this behavior.
      """

      def __init__(self, addr, requestHandler= SimpleXMLRPCReq uestHandler,
      logRequests=1):
      self.logRequest s = logRequests

      SimpleXMLRPCDis patcher.__init_ _(self)
      SocketServer.TC PServer.__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

      Comment

      • codecraig

        #4
        Re: SimpleXMLRPCSer ver - disable output


        Jeremy Jones wrote:[color=blue]
        > codecraig wrote:
        >[color=green]
        > >Hi,
        > > I thought I posted this, but its been about 10min and hasnt shown[/color][/color]
        up[color=blue][color=green]
        > >on the group.
        > > Basically I created a SimpleXMLRPCSer ver and when one of its[/color][/color]
        methods[color=blue][color=green]
        > >gets called and it returns a response to the client, the server[/color][/color]
        prints[color=blue][color=green]
        > >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 SimpleXMLRPCSer ver.py ...it doesn't explicitly
        > >print that, I think perhaps std is...but not sure. Any ideas??
        > >
        > >thanks.
        > >
        > >
        > >[/color]
        > Here's the entire SimpleMLRPCServ er class from SimpleXMLRPCSer ver.py:
        >
        >
        > class SimpleXMLRPCSer ver(SocketServe r.TCPServer,
        > SimpleXMLRPCDis patcher):
        > """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 SimpleXMLRPCDis patcher to change this behavior.
        > """
        >
        > def __init__(self, addr,[/color]
        requestHandler= SimpleXMLRPCReq uestHandler,[color=blue]
        > logRequests=1):
        > self.logRequest s = logRequests
        >
        > SimpleXMLRPCDis patcher.__init_ _(self)
        > SocketServer.TC PServer.__init_ _(self, addr, requestHandler)
        >
        > You should be able to change logRequests to 0 and that should fix it.[/color]
        I just tested it at a prompt and it worked just fine.[color=blue]
        >
        >
        > Jeremy Jones[/color]

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

        server = SimpleXMLRPCSer ver(0) ???

        I am sorta new to python thanks.

        Comment

        • codecraig

          #5
          Re: SimpleXMLRPCSer ver - disable output

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

          Learning one day at a time :)

          Thanks.

          Comment

          Working...