A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

56 рядки
2.1 KiB

  1. <%!
  2. from datetime import datetime
  3. import os
  4. import re
  5. from shlex import split
  6. from subprocess import check_output, CalledProcessError, STDOUT
  7. os.environ["SGE_ROOT"] = "/sge62"
  8. def format_date(d):
  9. start = datetime.strptime(d, "%a %b %d %H:%M:%S %Y")
  10. since = start.strftime("%b %d, %Y at %H:%M:%S UTC")
  11. diff = (datetime.utcnow() - start)
  12. if diff.days:
  13. uptime = "{0} days".format(diff.days)
  14. if diff.seconds >= 3600:
  15. uptime += ", {0} hours".format(diff.seconds / 3600)
  16. else:
  17. if diff.seconds > 3600:
  18. uptime = "{0} hours".format(diff.seconds / 3600)
  19. elif diff.seconds > 60:
  20. uptime = "{0} minutes".format(diff.seconds / 60)
  21. else:
  22. uptime = "{0} seconds".format(diff.seconds)
  23. return (since, uptime)
  24. def collect_status_info():
  25. try:
  26. result = check_output(["qstat", "-j", "earwigbot"], stderr=STDOUT)
  27. except CalledProcessError as e:
  28. return ["offline"]
  29. if result.startswith("Following jobs do not exist:"):
  30. return ["offline"]
  31. lines = result.splitlines()[1:]
  32. re_key = "^(.*?):\s"
  33. re_val = ":\s*(.*?)$"
  34. data = dict((re.search(re_key, line).group(1), re.search(re_val, line).group(1)) for line in lines)
  35. since, uptime = format_date(data["submission_time"])
  36. host = data["sge_o_host"]
  37. return ["online", since, uptime, host]
  38. %>\
  39. <%def name="get_status()" filter="trim">
  40. <% status, since, uptime, host = collect_status_info() %>
  41. <span class="${status}">${status}</span>
  42. % if status == "online":
  43. since ${since} (${uptime} uptime) on <tt>${host}</tt>
  44. % endif
  45. </%def>\
  46. <%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/>
  47. <h1>EarwigBot Status</h1>
  48. <p>EarwigBot is ${get_status()}.</p>
  49. <p>Additional information: <a href="http://status.toolserver.org/">status.toolserver.org</a></p>
  50. <%include file="/support/footer.mako" args="environ=environ"/>