Created
June 3, 2011 06:46
-
-
Save springmeyer/1005972 to your computer and use it in GitHub Desktop.
python client for talkin' sockets with mod_tile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# client for mod_tile | |
import struct | |
import socket | |
def print_resp(data): | |
print 'Received', repr(data) | |
version, request, x, y, z, xmlname = struct.unpack("5i41sxxx", data) | |
xmlname = xmlname.rstrip('\000') | |
print '\t'.join("version request x y z xmlname".split(' ')) | |
print version,'\t',request,'\t',x,'\t',y,'\t', z,'\t', xmlname | |
def request(address,xmlname,x,y,z): | |
version = 2 | |
command = 1 | |
# form up data | |
data = (version, command, x, y, z, xmlname) | |
# pack it | |
msg = struct.pack("5i41sxxx", *data) | |
# connect to renderd and send request | |
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
s.connect(sock_addr) | |
s.send(msg) | |
# print response | |
data = s.recv(1024) | |
#print_resp(data) | |
# close connection | |
s.close() | |
if __name__ == "__main__": | |
import sys | |
z,x,y = [int(i) for i in sys.argv[1:]] | |
print z,x,y | |
# renderd.conf defaults | |
xmlname = 'default' | |
sock_addr = '/tmp/osm-renderd' | |
request(sock_addr,xmlname,x,y,z) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment