Skip to content

Instantly share code, notes, and snippets.

@neosb
Created July 29, 2015 09:02
Show Gist options
  • Select an option

  • Save neosb/4ec47961fe685eacf4da to your computer and use it in GitHub Desktop.

Select an option

Save neosb/4ec47961fe685eacf4da to your computer and use it in GitHub Desktop.
Speed up startup of Sikuli script
# This is Sikuli script
# More about SimpleXMLRPCServer: https://docs.python.org/2/library/simplexmlrpcserver.html
#import xmlrpclib # is this necessary?
from SimpleXMLRPCServer import SimpleXMLRPCServer
def click_it():
'''
Some function to do testing automation
'''
click("image.png")
return "Success!"
server = SimpleXMLRPCServer(("localhost", 8000)) # create server listening on port 8000
print "Listening on port 8000..." # For your information
server.register_function(click_it, "click") # custom name for method
server.serve_forever() # eternal loop (until the power goes off)
# This is client for XML-RPC interface exposed from Sikuli script file
# If you wish, you can do this in any other language with xml-rpc support
# Link to Wikipedia: https://en.wikipedia.org/wiki/XML-RPC
# Note it's Python 3.4
#!/usr/bin/env python3
import xmlrpc.client # xmlrpclib in Python 2.x
# s = xmlrpclib.ServerProxy('http://localhost:8000') in Python 2.x
s = xmlrpc.client.ServerProxy("http://localhost:8000/") # connecting from the same machine
print(s.click())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment