def kick(self):
     url = self.get_stt('url')
     prv = self.get_stt('dig')
     res = urlfetch.fetch(url, deadline=60, headers=self.__headers)
     stts = {}
     stts['chk'] = tz.nowjststr()
     if res.status_code != 200:
         logging.error('HTTP Response: %(cd)s' % {'cd':res.status_code})
         return None
     if not res.content:
         logging.error('No content.')
         return None
     if 1 > len(res.content):
         logging.error('Content length: %(len)s' % {'len':len(res.content)})
         return None
     sha1 = hashlib.sha1()
     sha1.update(res.content)
     cur = sha1.hexdigest()
     if cur == prv:
         self.set_stt(stts)
         logging.info('Nothing to get.')
         return 'stop'
     stts['dig'] = cur
     stts['mod'] = tz.nowjststr()
     if self.get_task() == "ar":
         self.__save(res.content, self.get_cat(), stts)
     self.set_stt(stts)
     return 'ok'
Beispiel #2
0
 def kick(self):
     url = self.get_stt('url')
     prv = self.get_stt('dig')
     res = urlfetch.fetch(url, deadline=60, headers=self.__headers)
     stts = {}
     stts['chk'] = tz.nowjststr()
     if res.status_code != 200:
         logging.error('HTTP Response: %(cd)s' % {'cd': res.status_code})
         return None
     if not res.content:
         logging.error('No content.')
         return None
     if 1 > len(res.content):
         logging.error('Content length: %(len)s' %
                       {'len': len(res.content)})
         return None
     sha1 = hashlib.sha1()
     sha1.update(res.content)
     cur = sha1.hexdigest()
     if cur == prv:
         self.set_stt(stts)
         logging.info('Nothing to get.')
         return 'stop'
     stts['dig'] = cur
     stts['mod'] = tz.nowjststr()
     if self.get_task() == "ar":
         self.__save(res.content, self.get_cat(), stts)
     self.set_stt(stts)
     return 'ok'
Beispiel #3
0
 def post(self):
     params = self.request.path.split("/")
     ctrl = None
     ret = "ok"
     if len(params) < 4:
         ret = "Error: Path: %(path)s" % {"path": self.request.path}
     else:
         task = params[2]
         cat = params[3]
         if task == "first":
             task = Params().get("first_task", cat)
         if task not in self.__jobs:
             ret = "Error: Path: %(path)s" % {"path": self.request.path}
     if ret != "ok":
         self.ret_text(ret)
         return
     if len(params) > 4:
         ctrl = params[4]
     job = self.__jobs[task](task, cat)
     if ctrl == "reg" and len(params) > 5:
         taskqueue.add(url="/job/%(task)s/%(cat)s" % {"task": task, "cat": cat})
         self.redirect("/" + "/".join(params[5:]))
         return
     stt = job.kick()
     if not stt:
         ret = "Error: Failed to proc: %(path)s" % {"path": self.request.path}
     elif stt == "stop":
         ret = "stop"
     elif ctrl == "stop":
         ret = "stop"
     else:
         succ = Params().get("task_seq", task)
         if succ is None:
             Status().set("upd_%(cat)s" % {"cat": cat}, tz.nowjststr())
             Status().set("upd", tz.nowjststr())
             ret = "end"
     self.ret_text(ret)
     if self.is_test():
         interval = Params().get("task_interval", "test")
     else:
         interval = Params().get("task_interval", "active")
     if ret == "ok":
         taskqueue.add(url="/job/%(task)s/%(cat)s" % {"task": succ, "cat": cat}, countdown=interval)
     elif ret == "end":
         succ = Params().get("job_seq", cat)
         if succ is None:
             logging.info("Refles release status.")
             Release().reflesh()
         else:
             taskqueue.add(url="/job/first/%(cat)s" % {"cat": succ}, countdown=interval)
Beispiel #4
0
 def post(self):
     stts = {}
     if 'clear' in self.request.arguments():
         Status(self.is_test()).clear()
     else:
         for name in self.request.arguments():
             stts[name] = self.request.get(name, default_value='')
         stts['last_mod'] = tz.nowjststr()
         Status(self.is_test()).merge(stts)
     self.redirect(self.request.url)
Beispiel #5
0
 def __init_param(self):
     """
     空の値に初期値を設定する。
         初期値は設定の param_ini または param_ini_test
     """
     if self.__is_test:
         initparam = Params().get('param_ini_test')
     else:
         initparam = Params().get('param_ini')
     initparam['last_mod'] = tz.nowjststr()
     for key in initparam.keys():
         if key not in self.__stts or self.__stts[key] == '':
             self.__stts[key] = initparam[key]
Beispiel #6
0
 def __init_param(self):
     """
     空の値に初期値を設定する。
         初期値は設定の param_ini または param_ini_test
     """
     if self.__is_test:
         initparam = Params().get('param_ini_test')
     else:
         initparam = Params().get('param_ini')
     initparam['last_mod'] = tz.nowjststr()
     for key in initparam.keys():
         if key not in self.__stts or self.__stts[key] == '':
             self.__stts[key] = initparam[key]