Beispiel #1
0
    def get(self):
        """Get handler for the send view.
    """

        ps = get_stats_from_request(self.request)

        if not ps:
            self.no_profiler()
            return

        dest = self.request.get('dest', '')

        if not dest:
            self.write_tagged("No destination specified.", "h3")
            return

        upload_form = MIMEMultipart('form-data')

        upload_filename = 'profile.%s.pstats' % ps.profile_key
        upload_field_name = 'profile_file'

        upload_form.attach(
            mime_upload_data_as_file(
                'profile_file', upload_field_name,
                zlib.compress(ps.pstats_obj.dump_stats_pickle())))
        upload_form.attach(mime_form_value('key_only', '1'))

        http_conn = httplib.HTTPConnection(dest)
        http_conn.connect()
        http_conn.request(
            'POST', '/upload_profile', upload_form.as_string(), {
                'Content-Type':
                'multipart/form-data; boundary=%s' %
                upload_form.get_boundary()
            })

        http_resp = http_conn.getresponse()
        remote_data = http_resp.read()

        if http_resp.status == 200:
            remote_url = "http://%s/view_profile?key=%s" % (dest, remote_data)
            self.write_tagged("Success! <a href='%s'>%s</a>" %
                              (remote_url, remote_url))
        else:
            self.write_tagged(
                "Failure!\n%s: %s\n%s" %
                (http_resp.status, http_resp.reason, remote_data))
Beispiel #2
0
    def get(self):
        ps = get_stats_from_global_or_request(self.request)
        if not ps:
            self.response.out.write(
                "<body><html><h3>No profiler.</h3><html></body>")
            return

        dest = self.request.get('dest', '')
        if not dest:
            self.response.out.write("<body><html>No destination</html></body>")

        upload_form = MIMEMultipart('form-data')

        upload_filename = 'profile.%s.pstats' % ps.profile_key
        upload_field_name = 'profile_file'

        upload_form.attach(
            mime_upload_data_as_file(
                'profile_file', upload_field_name,
                zlib.compress(ps.profile_obj.dump_stats_pickle())))
        upload_form.attach(mime_form_value('key_only', '1'))

        http_conn = httplib.HTTPConnection(dest)
        http_conn.connect()
        http_conn.request(
            'POST', '/upload_profile', upload_form.as_string(), {
                'Content-Type':
                'multipart/form-data; boundary=%s' %
                upload_form.get_boundary()
            })

        http_resp = http_conn.getresponse()
        remote_data = http_resp.read()
        if http_resp.status == 200:
            remote_url = "http://%s/view_profile?key=%s" % (dest, remote_data)
            self.response.out.write(
                "<html><body>Success! <a href='%s'>%s</a></body></html>" %
                (remote_url, remote_url))
        else:
            self.response.out.write(
                "Failure!\n%s: %s\n%s" %
                (http_resp.status, http_resp.reason, remote_data))
Beispiel #3
0
  def get(self):
    """Get handler for the send view.
    """

    ps = get_stats_from_request(self.request)

    if not ps:
      self.no_profiler()
      return

    dest = self.request.get('dest', '')

    if not dest:
      self.write_tagged("No destination specified.", "h3")
      return

    upload_form = MIMEMultipart('form-data')

    upload_filename =  'profile.%s.pstats' % ps.profile_key
    upload_field_name = 'profile_file'

    upload_form.attach(mime_upload_data_as_file('profile_file',
                                                upload_field_name,
                                                zlib.compress(ps.pstats_obj.dump_stats_pickle())))
    upload_form.attach(mime_form_value('key_only', '1'))

    http_conn = httplib.HTTPConnection(dest)
    http_conn.connect()
    http_conn.request('POST', '/upload_profile', upload_form.as_string(),
                      {'Content-Type': 'multipart/form-data; boundary=%s' % upload_form.get_boundary()})

    http_resp = http_conn.getresponse()
    remote_data = http_resp.read()

    if http_resp.status == 200:
      remote_url = "http://%s/view_profile?key=%s" % (dest, remote_data)
      self.write_tagged("Success! <a href='%s'>%s</a>" % (remote_url, remote_url))
    else:
      self.write_tagged("Failure!\n%s: %s\n%s" % (http_resp.status, http_resp.reason, remote_data))