Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import yaml
  2. import redis
  3. import subprocess
  4. import os
  5. import time
  6. import datetime
  7.  
  8. fname = "file_seed_origin.yaml"
  9. fout="new_file_seed.yaml"
  10.  
  11. dataMap = yaml.load(fname)
  12.  
  13. with open(fout, "w") as f:
  14. yaml.dump(dataMap, f)
  15.  
  16. with open(fname) as f:
  17. newdct = yaml.load(f)
  18.  
  19. r=redis.StrictRedis(host='<IP_ADDRESS>',port=6379)
  20. p= r.pubsub()
  21. p.subscribe('<CHANNEL_NAME>')
  22.  
  23. for m in p.listen():
  24. string_message=m['data']
  25. if isinstance(string_message, basestring):
  26. end_message=string_message.split(';')
  27. bbox = []
  28. bbox.append(float(end_message[3]))
  29. bbox.append(float(end_message[4]))
  30. bbox.append(float(end_message[5]))
  31. bbox.append(float(end_message[6]))
  32.  
  33. if end_message[0]=="<ID_LAYER>:
  34. caches = []
  35. caches.append('<CACHE1>');
  36. caches.append('<CACHE2>');
  37. caches.append('<CACHE3>');
  38.  
  39. newdct["seeds"]["myseed"]["caches"]=caches
  40. newdct["coverages"]["cover1"]["bbox"]=bbox
  41. newdct["seeds"]["myseed"]["refresh_before"]["time"]=datetime.datetime.today()
  42.  
  43. with open(fout, "w") as f:
  44. yaml.dump(newdct, f)
  45. subprocess.call(["mapproxy-seed","-f","mapproxy_configuration.yaml","-c","4","new_file_seed.yaml"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement