jinyulin / test-analytics

Automatically exported from code.google.com/p/test-analytics
0 stars 0 forks source link

HTTP Error 500: Internal Server Error. During uploading data #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Run the following python code:

email = "correct email"
password = "correct password"

data = {'bug': [{'projectId': 'v100',
                  'title': 'test bug title',
                  'bugId': "333",
                  'path': '/1/3/3',
                  'severity': '1',
                  'priority': '2',
                  'groups': 'one',
                  'status': 'open',
                  'statusDate': '01/01/2013'
                 }],
         'test': [{'projectId': 'v100',
                 'testId': '1234',
                 'title': 'switching sources',
                 'tags': 'no',
                 'result': 'failed',
                 'resultDate': '01/01/2013'
                 }],
         'checkin': [{'projectId': 'v100',
                    'checkinId': '566',
                    'summary': "test summary",
                    'directories': '/home/users',
                    'state': 'committed',
                    'stateDate': '01/01/2013'
                    }]
        }

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(), 
urllib2.HTTPSHandler)
urllib2.install_opener(opener)

# Define URLs
loing_page_url = 'https://accounts.google.com/ServiceLogin'
gv_home_page_url = "https://test-analytics.appspot.com/api/data"

# Load sign in page
login_page_contents = opener.open(loing_page_url).read()

# Find GALX value
galx_match_obj = re.search(r'name="GALX"\s*value="([^"]+)"', 
login_page_contents, re.IGNORECASE)

galx_value = galx_match_obj.group(1) if galx_match_obj.group(1) is not None 
else ''

# Set up login credentials
login_params = urllib.urlencode({'Email': email,
                                 'Passwd': password,
                                 'GALX': galx_value
                                })

# Login
opener.open(loing_page_url, login_params)

# Open GV home page
# gv_home_page_contents = opener.open(gv_home_page_url).read()

# print gv_home_page_contents

req = urllib2.Request(url, json.dumps(data), headers)
print opener.open(req).read()

Actual result:
the following error appears:
Traceback (most recent call last):
  File "/home/...../src/test2.py", line 333, in <module>
    print opener.open(req).read()
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 625, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 625, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 625, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 625, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 625, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 444, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error

Original issue reported on code.google.com by Soo...@gmail.com on 2 Sep 2013 at 12:54