Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. Index: aymaster/scripts/aylook-export-redis.py
  2. ===================================================================
  3. --- aymaster/scripts/aylook-export-redis.py (revision 29319)
  4. +++ aymaster/scripts/aylook-export-redis.py (working copy)
  5. @@ -16,6 +16,26 @@
  6. destcache = "/tmp/cache.rdb"
  7. protocolfile = "/tmp/proto.redis"
  8.  
  9. +def log_decision(path_file, modifier):
  10. + def real_log_decision(func):
  11. + def wrapper(*args, **kwargs):
  12. + must_args = list(args)
  13. + option_kwargs = list(kwargs)
  14. + #print option_kwargs
  15. + try:
  16. + f = open(str(path_file), str(modifier))
  17. + except:
  18. + return func(*args, **kwargs)
  19. + result = func(*args, **kwargs)
  20. + table = "<tr><td>%s</td><td>%s</td></tr>"
  21. + if result is True:
  22. + f.write(table %(must_args[1],"/"))
  23. + else:
  24. + f.write(table %("/",must_args[1]))
  25. + f.close()
  26. + return result
  27. + return wrapper
  28. + return real_log_decision
  29.  
  30. def wait_redis(r):
  31. while True:
  32. @@ -42,14 +62,20 @@
  33. def start_database(self, db_number):
  34. ProtocolCallback.start_database(self, db_number)
  35.  
  36. + @log_decision("decisions.html","a")
  37. def should_backup(self, key, debug=""):
  38. - if (self.mode == "cache")and(self.exportall is False):
  39. - return False
  40. - # if the key seems an object and the key is not from this aylook remove it
  41. + slave_list = ['camera','panel','zone','partition','ioi','cameragroup','patrol','map']
  42. try:
  43. k = key.split(':')
  44. except:
  45. return True
  46. +
  47. + if debug == "hash" and k[0] in slave_list:
  48. + return True
  49. +
  50. + if (self.mode == "cache") and (self.exportall is False):
  51. + return False
  52. + # if the key seems an object and the key is not from this aylook remove it
  53. ret = True
  54. if len(k) < 3:
  55. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement