host.py 628 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from flask import g
  4. __author__ = 'James Iter'
  5. __date__ = '2017/9/19'
  6. __contact__ = 'james.iter.cn@gmail.com'
  7. __copyright__ = '(c) 2017 by James Iter.'
  8. class Host(object):
  9. def __init__(self):
  10. pass
  11. @staticmethod
  12. def alive_check(v):
  13. """
  14. JimV-C 2 秒更新一次宿主机信息,这里以 5 秒内没收到更新,作为判断宿主机是否在线的标准
  15. """
  16. if 'timestamp' not in v:
  17. return v
  18. v['alive'] = False
  19. if v['timestamp'] + 5 >= g.ts:
  20. v['alive'] = True
  21. return v