Changeset 100592 in webkit


Ignore:
Timestamp:
Nov 17, 2011 3:01:53 AM (12 years ago)
Author:
abarth@webkit.org
Message:

Move test_results_uploader.py out of layout_package
https://bugs.webkit.org/show_bug.cgi?id=72590

Reviewed by Eric Seidel.

Most of the lines of code in this file are wrong, but I've restrained
myself and only changed a few of them to generalized this class to the
common package.

This is part of a series of patches to remove layout_package.

  • Scripts/webkitpy/common/net/file_uploader.py: Copied from Tools/Scripts/webkitpy/layout_tests/layout_package/test_results_uploader.py.
  • Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
  • Scripts/webkitpy/layout_tests/layout_package/test_results_uploader.py: Removed.
Location:
trunk/Tools
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r100591 r100592  
     12011-11-17  Adam Barth  <abarth@webkit.org>
     2
     3        Move test_results_uploader.py out of layout_package
     4        https://bugs.webkit.org/show_bug.cgi?id=72590
     5
     6        Reviewed by Eric Seidel.
     7
     8        Most of the lines of code in this file are wrong, but I've restrained
     9        myself and only changed a few of them to generalized this class to the
     10        common package.
     11
     12        This is part of a series of patches to remove layout_package.
     13
     14        * Scripts/webkitpy/common/net/file_uploader.py: Copied from Tools/Scripts/webkitpy/layout_tests/layout_package/test_results_uploader.py.
     15        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
     16        * Scripts/webkitpy/layout_tests/layout_package/test_results_uploader.py: Removed.
     17
    1182011-11-17  Adam Barth  <abarth@webkit.org>
    219
  • trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py

    r100591 r100592  
    3737from webkitpy.common.net.networktransaction import NetworkTransaction
    3838
     39
    3940def get_mime_type(filename):
    4041    return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
    4142
    4243
     44# FIXME: Rather than taking tuples, this function should take more structured data.
    4345def _encode_multipart_form_data(fields, files):
    4446    """Encode form fields for multipart/form-data.
     
    8284
    8385
    84 class TestResultsUploader:
    85     def __init__(self, host):
    86         self._host = host
     86class FileUploader(object):
     87    def __init__(self, url):
     88        self._url = url
    8789
    8890    def _upload_files(self, attrs, file_objs):
    89         url = "http://%s/testfile/upload" % self._host
     91        # FIXME: We should use the same variable names for the formal and actual parameters.
    9092        content_type, data = _encode_multipart_form_data(attrs, file_objs)
    91         headers = {"Content-Type": content_type}
    92         request = urllib2.Request(url, data, headers)
     93        headers = {
     94            "Content-Type": content_type,
     95        }
     96        # FIXME: We should talk to the network via a Host object.
     97        request = urllib2.Request(self._url, data, headers)
    9398        urllib2.urlopen(request)
    9499
     
    96101        file_objs = []
    97102        for filename, path in files:
     103            # FIXME: We should talk to the filesytem via a Host object.
    98104            with codecs.open(path, "rb") as file:
    99105                file_objs.append(('file', filename, file.read()))
     
    101107        orig_timeout = socket.getdefaulttimeout()
    102108        try:
     109            # FIXME: We shouldn't mutate global static state.
    103110            socket.setdefaulttimeout(timeout_seconds)
    104111            NetworkTransaction(timeout_seconds=timeout_seconds).run(
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py

    r91214 r100592  
    3535import xml.dom.minidom
    3636
    37 from webkitpy.layout_tests.layout_package import test_results_uploader
     37from webkitpy.common.net.file_uploader import FileUploader
    3838
    3939try:
     
    318318            for file in json_files]
    319319
    320         uploader = test_results_uploader.TestResultsUploader(
    321             self._test_results_server)
     320        url = "http://%s/testfile/upload" % self._test_results_server
     321        uploader = FileUploader(url)
    322322        try:
    323323            # Set uploading timeout in case appengine server is having problem.
     
    419419
    420420        try:
     421            # FIXME: We should talk to the network via a Host object.
    421422            results_file = urllib2.urlopen(results_file_url)
    422423            info = results_file.info()
Note: See TracChangeset for help on using the changeset viewer.