コード例 #1
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
  def get(self):
    recording.dont_record()

    lineno = self.request.get('n')
    try:
      lineno = int(lineno)
    except:
      lineno = 0

    filename = self.request.get('f') or ''
    orig_filename = filename

    match = re.match('<path\[(\d+)\]>(.*)', filename)
    if match:
      index, tail = match.groups()
      index = int(index)
      if index < len(sys.path):
        filename = sys.path[index] + tail

    try:
      fp = open(filename)
    except IOError, err:
      self.response.out.write('<h1>IOError</h1><pre>%s</pre>' %
                              cgi.escape(str(err)))
      self.response.set_status(404)
コード例 #2
0
    def get(self):
        recording.dont_record()

        lineno = self.request.get('n')
        try:
            lineno = int(lineno)
        except:
            lineno = 0

        filename = self.request.get('f') or ''
        orig_filename = filename

        match = re.match('<path\[(\d+)\]>(.*)', filename)
        if match:
            index, tail = match.groups()
            index = int(index)
            if index < len(sys.path):
                filename = sys.path[index] + tail

        try:
            fp = open(filename)
        except IOError, err:
            self.response.out.write('<h1>IOError</h1><pre>%s</pre>' %
                                    cgi.escape(str(err)))
            self.response.set_status(404)
コード例 #3
0
ファイル: ui.py プロジェクト: startup-one/cogofly
    def post(self):
        recording.dont_record()
        if not self._check_access():
            return

        recorder = recording.Recorder(os.environ)
        recording.recorder_proxy.set_for_current_request(recorder)

        script = self.request.get('script', '').replace('\r\n', '\n')
        output, errors = self.execute_script(script)

        recording.recorder_proxy.clear_for_current_request()
        recorder.record_http_status(0)
        recorder.save()
        record = recorder.get_full_proto()

        extra_data = {
            'is_shell': True,
            'script': script,
            'output': output,
            'errors': errors,
            'time_key': int(recorder.start_timestamp * 1000),
            'xsrf_token': admin.get_xsrf_token(),
        }
        render_record(self.response, record, './file', extra_data)
コード例 #4
0
ファイル: ui.py プロジェクト: curlup/gae_hh_fork
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    key = str(self.request.get('key'))
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(recording.make_key(timestamp))
    elif key:
        record = recording.load_full_proto(key)

    if record is None:
      self.response.set_status(404)

      self.response.out.write(render('details.html', {}))
      return


    rpcstats_map = {}
    for rpc_stat in record.individual_stats_list():
      key = rpc_stat.service_call_name()
      count, real, api = rpcstats_map.get(key, (0, 0, 0))
      count += 1
      real += rpc_stat.duration_milliseconds()
      api += rpc_stat.api_mcycles()
      rpcstats_map[key] = (count, real, api)
    rpcstats_by_count = [
        (name, count, real, recording.mcycles_to_msecs(api))
        for name, (count, real, api) in rpcstats_map.iteritems()]
    rpcstats_by_count.sort(key=lambda x: -x[1])


    real_total = 0
    api_total_mcycles = 0
    for i, rpc_stat in enumerate(record.individual_stats_list()):
      real_total += rpc_stat.duration_milliseconds()
      api_total_mcycles += rpc_stat.api_mcycles()

    api_total = recording.mcycles_to_msecs(api_total_mcycles)
    charged_total = recording.mcycles_to_msecs(record.processor_mcycles() +
                                               api_total_mcycles)

    data = {'sys': sys,
            'record': record,
            'rpcstats_by_count': rpcstats_by_count,
            'real_total': real_total,
            'api_total': api_total,
            'charged_total': charged_total,
            'file_url': './file',
            'deadlines': [(0,'#77ff77'), (300,'#ECF000'), (1000,'#DB4900')]
            }
    self.response.out.write(render('details.html', data))
コード例 #5
0
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(timestamp)


    if record is None:
      self.response.set_status(404)

      self.response.out.write(render('details.html', {}))
      return


    rpcstats_map = {}
    for rpc_stat in record.individual_stats_list():
      key = rpc_stat.service_call_name()
      count, real, api = rpcstats_map.get(key, (0, 0, 0))
      count += 1
      real += rpc_stat.duration_milliseconds()
      api += rpc_stat.api_mcycles()
      rpcstats_map[key] = (count, real, api)
    rpcstats_by_count = [
        (name, count, real, recording.mcycles_to_msecs(api))
        for name, (count, real, api) in rpcstats_map.iteritems()]
    rpcstats_by_count.sort(key=lambda x: -x[1])


    real_total = 0
    api_total_mcycles = 0
    for i, rpc_stat in enumerate(record.individual_stats_list()):
      real_total += rpc_stat.duration_milliseconds()
      api_total_mcycles += rpc_stat.api_mcycles()

    api_total = recording.mcycles_to_msecs(api_total_mcycles)
    charged_total = recording.mcycles_to_msecs(record.processor_mcycles() +
                                               api_total_mcycles)

    data = {'sys': sys,
            'record': record,
            'rpcstats_by_count': rpcstats_by_count,
            'real_total': real_total,
            'api_total': api_total,
            'charged_total': charged_total,
            'file_url': './file',
            }
    self.response.out.write(render('details.html', data))
コード例 #6
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
 def get(self):
   recording.dont_record()
   if not self._check_access():
     return
   script = self.request.get('script', recording.config.DEFAULT_SCRIPT)
   extra_data = {'is_shell': True,
                 'script': script,
                 'xsrf_token': admin.get_xsrf_token(),
                 }
   render_record(self.response, None, './file', extra_data)
コード例 #7
0
ファイル: ui.py プロジェクト: adamsowa/google_appengine
 def get(self):
   recording.dont_record()
   if not self._check_access():
     return
   script = self.request.get('script', recording.config.DEFAULT_SCRIPT)
   extra_data = {'is_shell': True,
                 'script': script,
                 'xsrf_token': admin.get_xsrf_token(),
                 }
   render_record(self.response, None, './file', extra_data)
コード例 #8
0
ファイル: ui.py プロジェクト: startup-one/cogofly
    def get(self):
        recording.dont_record()

        if not self.request.path.endswith('/'):
            self.redirect(self.request.path + '/')
            return

        summaries = recording.load_summary_protos()

        data = self._get_summary_data(summaries)

        self.response.out.write(render('main.html', data))
コード例 #9
0
ファイル: ui.py プロジェクト: startup-one/cogofly
    def get(self):
        recording.dont_record()

        time_key = self.request.get('time')
        timestamp = None
        record = None
        if time_key:
            try:
                timestamp = int(time_key) * 0.001
            except Exception:
                pass
        if timestamp:
            record = recording.load_full_proto(timestamp)
        render_record(self.response, record, './file')
コード例 #10
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(timestamp)
    render_record(self.response, record, './file')
コード例 #11
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
  def get(self):
    recording.dont_record()





    if not self.request.path.endswith('/'):
      self.redirect(self.request.path + '/')
      return


    summaries = recording.load_summary_protos()

    data = self._get_summary_data(summaries)


    self.response.out.write(render('main.html', data))
コード例 #12
0
ファイル: ui.py プロジェクト: startup-one/cogofly
 def get(self):
     recording.dont_record()
     here = os.path.dirname(__file__)
     fn = self.request.path
     i = fn.rfind('/')
     fn = fn[i + 1:]
     fn = os.path.join(here, 'static', fn)
     ctype, encoding = mimetypes.guess_type(fn)
     assert ctype and '/' in ctype, repr(ctype)
     expiry = 3600
     expiration = email.Utils.formatdate(time.time() + expiry, usegmt=True)
     fp = open(fn, 'rb')
     try:
         self.response.out.write(fp.read())
     finally:
         fp.close()
     self.response.headers['Content-type'] = ctype
     self.response.headers['Cache-Control'] = 'public, max-age=expiry'
     self.response.headers['Expires'] = expiration
コード例 #13
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
 def get(self):
   recording.dont_record()
   here = os.path.dirname(__file__)
   fn = self.request.path
   i = fn.rfind('/')
   fn = fn[i+1:]
   fn = os.path.join(here, 'static', fn)
   ctype, encoding = mimetypes.guess_type(fn)
   assert ctype and '/' in ctype, repr(ctype)
   expiry = 3600
   expiration = email.Utils.formatdate(time.time() + expiry, usegmt=True)
   fp = open(fn, 'rb')
   try:
     self.response.out.write(fp.read())
   finally:
     fp.close()
   self.response.headers['Content-type'] = ctype
   self.response.headers['Cache-Control'] = 'public, max-age=expiry'
   self.response.headers['Expires'] = expiration
コード例 #14
0
ファイル: ui.py プロジェクト: startup-one/cogofly
    def get(self):
        recording.dont_record()

        lineno = self.request.get('n')
        try:
            lineno = int(lineno)
        except:
            lineno = 0

        filename = self.request.get('f') or ''
        orig_filename = filename

        match = re.match('<path\[(\d+)\]>(.*)', filename)
        if match:
            index, tail = match.groups()
            index = int(index)
            if index < len(sys.path):
                filename = sys.path[index] + tail

        try:
            fp = open(filename)
        except IOError as err:
            self.response.out.write('<h1>IOError</h1><pre>%s</pre>' %
                                    cgi.escape(str(err)))
            self.response.set_status(404)
        else:

            try:
                data = {
                    'fp': fp,
                    'filename': filename,
                    'orig_filename': orig_filename,
                    'lineno': lineno,
                }
                self.response.out.write(render('file.html', data))
            finally:
                fp.close()
コード例 #15
0
ファイル: ui.py プロジェクト: zenlambda/appengine-python3
  def get(self):
    recording.dont_record()

    lineno = self.request.get('n')
    try:
      lineno = int(lineno)
    except:
      lineno = 0

    filename = self.request.get('f') or ''
    orig_filename = filename

    match = re.match('<path\[(\d+)\]>(.*)', filename)
    if match:
      index, tail = match.groups()
      index = int(index)
      if index < len(sys.path):
        filename = sys.path[index] + tail

    try:
      fp = open(filename)
    except IOError as err:
      self.response.out.write('<h1>IOError</h1><pre>%s</pre>' %
                              cgi.escape(str(err)))
      self.response.set_status(404)
    else:

      try:
        data = {'fp': fp,
                'filename': filename,
                'orig_filename': orig_filename,
                'lineno': lineno,
                }
        self.response.out.write(render('file.html', data))
      finally:
        fp.close()
コード例 #16
0
ファイル: ui.py プロジェクト: 404minds/quiz-forest
  def post(self):
    recording.dont_record()
    if not self._check_access():
      return

    recorder = recording.Recorder(os.environ)
    recording.recorder_proxy.set_for_current_request(recorder)

    script = self.request.get('script', '').replace('\r\n', '\n')
    output, errors = self.execute_script(script)

    recording.recorder_proxy.clear_for_current_request()
    recorder.record_http_status(0)
    recorder.save()
    record = recorder.get_full_proto()

    extra_data = {'is_shell': True,
                  'script': script,
                  'output': output,
                  'errors': errors,
                  'time_key': int(recorder.start_timestamp * 1000),
                  'xsrf_token': admin.get_xsrf_token(),
                  }
    render_record(self.response, record, './file', extra_data)
コード例 #17
0
ファイル: ui.py プロジェクト: Agana/MyBlog
  def get(self):
    recording.dont_record()





    if not self.request.path.endswith('/'):
      self.redirect(self.request.path + '/')
      return


    summaries = recording.load_summary_protos()


    allstats = {}
    pathstats = {}
    pivot_path_rpc = {}
    pivot_rpc_path = {}
    for index, summary in enumerate(summaries):




      path_key = recording.config.extract_key(summary)
      if path_key not in pathstats:
        pathstats[path_key] = [1, index+1]
      else:
        values = pathstats[path_key]

        values[0] += 1
        if len(values) >= 11:
          if values[-1]:
            values.append(0)
        else:
          values.append(index+1)
      if path_key not in pivot_path_rpc:
        pivot_path_rpc[path_key] = {}

      for x in summary.rpc_stats_list():
        rpc_key = x.service_call_name()
        value = x.total_amount_of_calls()
        if rpc_key in allstats:
          allstats[rpc_key] += value
        else:
          allstats[rpc_key] = value
        if rpc_key not in pivot_path_rpc[path_key]:
          pivot_path_rpc[path_key][rpc_key] = 0
        pivot_path_rpc[path_key][rpc_key] += value
        if rpc_key not in pivot_rpc_path:
          pivot_rpc_path[rpc_key] = {}
        if path_key not in pivot_rpc_path[rpc_key]:
          pivot_rpc_path[rpc_key][path_key] = 0
        pivot_rpc_path[rpc_key][path_key] += value


    allstats_by_count = []
    for k, v in allstats.iteritems():
      pivot = sorted(pivot_rpc_path[k].iteritems(),
                     key=lambda x: (-x[1], x[0]))
      allstats_by_count.append((k, v, pivot))
    allstats_by_count.sort(key=lambda x: (-x[1], x[0]))


    pathstats_by_count = []
    for path_key, values in pathstats.iteritems():
      pivot = sorted(pivot_path_rpc[path_key].iteritems(),
                     key=lambda x: (-x[1], x[0]))
      rpc_count = sum(x[1] for x in pivot)
      pathstats_by_count.append((path_key, rpc_count,
                                 values[0], values[1:], pivot))
    pathstats_by_count.sort(key=lambda x: (-x[1], -x[2], x[0]))


    data = {'requests': summaries,
            'allstats_by_count': allstats_by_count,
            'pathstats_by_count': pathstats_by_count,
            }
    self.response.out.write(render('main.html', data))
コード例 #18
0
    def get(self):
        recording.dont_record()

        if not self.request.path.endswith('/'):
            self.redirect(self.request.path + '/')
            return

        summaries = recording.load_summary_protos()

        allstats = {}
        pathstats = {}
        pivot_path_rpc = {}
        pivot_rpc_path = {}
        for index, summary in enumerate(summaries):

            path_key = recording.config.extract_key(summary)
            if path_key not in pathstats:
                pathstats[path_key] = [1, index + 1]
            else:
                values = pathstats[path_key]

                values[0] += 1
                if len(values) >= 11:
                    if values[-1]:
                        values.append(0)
                else:
                    values.append(index + 1)
            if path_key not in pivot_path_rpc:
                pivot_path_rpc[path_key] = {}

            for x in summary.rpc_stats_list():
                rpc_key = x.service_call_name()
                value = x.total_amount_of_calls()
                if rpc_key in allstats:
                    allstats[rpc_key] += value
                else:
                    allstats[rpc_key] = value
                if rpc_key not in pivot_path_rpc[path_key]:
                    pivot_path_rpc[path_key][rpc_key] = 0
                pivot_path_rpc[path_key][rpc_key] += value
                if rpc_key not in pivot_rpc_path:
                    pivot_rpc_path[rpc_key] = {}
                if path_key not in pivot_rpc_path[rpc_key]:
                    pivot_rpc_path[rpc_key][path_key] = 0
                pivot_rpc_path[rpc_key][path_key] += value

        allstats_by_count = []
        for k, v in allstats.iteritems():
            pivot = sorted(pivot_rpc_path[k].iteritems(),
                           key=lambda x: (-x[1], x[0]))
            allstats_by_count.append((k, v, pivot))
        allstats_by_count.sort(key=lambda x: (-x[1], x[0]))

        pathstats_by_count = []
        for path_key, values in pathstats.iteritems():
            pivot = sorted(pivot_path_rpc[path_key].iteritems(),
                           key=lambda x: (-x[1], x[0]))
            rpc_count = sum(x[1] for x in pivot)
            pathstats_by_count.append(
                (path_key, rpc_count, values[0], values[1:], pivot))
        pathstats_by_count.sort(key=lambda x: (-x[1], -x[2], x[0]))

        data = {
            'requests': summaries,
            'allstats_by_count': allstats_by_count,
            'pathstats_by_count': pathstats_by_count,
        }
        self.response.out.write(render('main.html', data))