Пример #1
0
    def get(self):
        path = self.request.path

        if path in ['favicon.ico', 'robots.txt']:
            response.set_status(404)
            return

        if self._RedirectSpecialCases(path):
            return

        if path.startswith('/cron'):
            # Crons often time out, and when they do *and* then eventually try to
            # flush logs they die. Turn off autoflush and manually do so at the end.
            logservice.AUTOFLUSH_ENABLED = False
            try:
                self._HandleCron(path)
            finally:
                logservice.flush()
            return

        # Redirect paths like "directory" to "directory/". This is so relative
        # file paths will know to treat this as a directory.
        if os.path.splitext(path)[1] == '' and path[-1] != '/':
            self.redirect(path + '/')
            return

        path = path.strip('/')
        if self._RedirectFromCodeDotGoogleDotCom(path):
            return

        self._HandleGet(path)
Пример #2
0
  def get(self):
    path = self.request.path

    if path in ['favicon.ico', 'robots.txt']:
      response.set_status(404)
      return

    if self._RedirectSpecialCases(path):
      return

    if path.startswith('/cron'):
      # Crons often time out, and when they do *and* then eventually try to
      # flush logs they die. Turn off autoflush and manually do so at the end.
      logservice.AUTOFLUSH_ENABLED = False
      try:
        self._HandleCron(path)
      finally:
        logservice.flush()
      return

    # Redirect paths like "directory" to "directory/". This is so relative
    # file paths will know to treat this as a directory.
    if os.path.splitext(path)[1] == '' and path[-1] != '/':
      self.redirect(path + '/')
      return

    path = path.strip('/')
    if self._RedirectFromCodeDotGoogleDotCom(path):
      return

    self._HandleGet(path)
Пример #3
0
 def Get(self):
   # Crons often time out, and when they do *and* then eventually try to
   # flush logs they die. Turn off autoflush and manually do so at the end.
   logservice.AUTOFLUSH_ENABLED = False
   try:
     return self._GetImpl()
   finally:
     logservice.flush()
 def Get(self):
     # Crons often time out, and when they do *and* then eventually try to
     # flush logs they die. Turn off autoflush and manually do so at the end.
     logservice.AUTOFLUSH_ENABLED = False
     try:
         return self._GetImpl()
     finally:
         logservice.flush()
Пример #5
0
 def Get(self):
   # Manually flush logs at the end of the run. However, sometimes
   # even that isn't enough, which is why in this file we use the
   # custom logger and make it flush the log every time its used.
   logservice.AUTOFLUSH_ENABLED = False
   try:
     return self._GetImpl()
   except BaseException:
     _log.error('Caught top-level exception! %s', traceback.format_exc())
   finally:
     logservice.flush()
 def Get(self):
   # Manually flush logs at the end of the run. However, sometimes
   # even that isn't enough, which is why in this file we use the
   # custom logger and make it flush the log every time its used.
   logservice.AUTOFLUSH_ENABLED = False
   try:
     return self._GetImpl()
   except BaseException:
     _log.error('Caught top-level exception! %s', traceback.format_exc())
   finally:
     logservice.flush()
Пример #7
0
 def Get(self):
   # Refreshes may time out, and if they do we need to make sure to flush the
   # logs before the process gets killed (Python gives us a couple of
   # seconds).
   #
   # So, manually flush logs at the end of the cron run. However, sometimes
   # even that isn't enough, which is why in this file we use _log and
   # make it flush the log every time its used.
   logservice.AUTOFLUSH_ENABLED = False
   try:
     return self._GetImpl()
   except BaseException:
     _log.error('Caught top-level exception! %s', traceback.format_exc())
   finally:
     logservice.flush()
Пример #8
0
 def Get(self):
     # Crons often time out, and if they do we need to make sure to flush the
     # logs before the process gets killed (Python gives us a couple of
     # seconds).
     #
     # So, manually flush logs at the end of the cron run. However, sometimes
     # even that isn't enough, which is why in this file we use _cronlog and
     # make it flush the log every time its used.
     logservice.AUTOFLUSH_ENABLED = False
     try:
         return self._GetImpl()
     except BaseException:
         _cronlog.error('Caught top-level exception! %s',
                        traceback.format_exc())
     finally:
         logservice.flush()
Пример #9
0
 def _log(self, logfn, msg, args):
   try:
     logfn('cron: %s' % msg, *args)
   finally:
     logservice.flush()
Пример #10
0
 def _log(self, logfn, msg, args):
     try:
         logfn('cron: %s' % msg, *args)
     finally:
         logservice.flush()
Пример #11
0
 def _log(self, logfn, msg, args):
   try:
     logfn('%s: %s' % (self._prefix, msg), *args)
   finally:
     logservice.flush()