1

I have a server along these lines:

from SimpleXMLRPCServer import SimpleXMLRPCServer
def ack(msg):
    return input("Allow? ").lower() in ['y', 'yes']
server = SimpleXMLRPCServer(("localhost", 8080))
server.register_function(ack, "ack")
server.serve_forever()

And a client along these lines:

import xmlrpclib
proxy = xmlrpclib.ServerProxy("http://localhost:8080")

with open(myfile) as mfd:
    for line in mfd.readlines():
        if proxy.ack(line):
            print line

This results in a fault being sent to the client. The fault code & string are:

1
<type 'exceptions.NameError'>:name 'y' is not defined

My assumption is the consumption of input over on the server side is killing the POST XML-RPC goodness.

I'd prefer not to have to code up some method with two clients and a server—I kind of like the simple 1:1 setup I have going.

Really, I'm open to any alternate (python) solution.

Community
  • 1
  • 1
thechao
  • 367
  • 2
  • 13
  • Aside: Thanks for including a complete, concise [MCVE](http://stackoverflow.com/help/mcve). – Robᵩ Nov 04 '15 at 23:15

1 Answers1

1

You are using input() where you ought to use raw_input(). Try this:

return raw_input("Allow? ").lower() in ['y', 'yes']
Robᵩ
  • 163,533
  • 20
  • 239
  • 308
  • You are correct, but it isn't clear to me from the python documents *why* you're correct---would you care to elaborate? Thanks! Is it due to the 'eval' part of `input()`? – thechao Nov 05 '15 at 01:04