Merge lp:~pfalcon/linaro-android-frontend/logging into lp:linaro-android-frontend

Proposed by Paul Sokolovsky
Status: Merged
Approved by: James Westby
Approved revision: 226
Merged at revision: 224
Proposed branch: lp:~pfalcon/linaro-android-frontend/logging
Merge into: lp:linaro-android-frontend
Diff against target: 81 lines (+16/-3)
2 files modified
android_build/frontend/api.py (+9/-3)
android_build/settings.py (+7/-0)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-frontend/logging
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+58547@code.launchpad.net

Description of the change

Initial steps to add logging to the frontend.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'android_build/frontend/api.py'
--- android_build/frontend/api.py 2011-03-15 01:09:15 +0000
+++ android_build/frontend/api.py 2011-04-20 17:43:39 +0000
@@ -2,6 +2,7 @@
2import re2import re
3import subprocess3import subprocess
4import urllib24import urllib2
5import logging
56
6from django.conf import settings7from django.conf import settings
7from django.http import HttpResponse8from django.http import HttpResponse
@@ -15,6 +16,8 @@
15 )16 )
1617
1718
19log = logging.getLogger(__name__)
20
18auth_headers = {21auth_headers = {
19 'Authorization': 'Basic %s' % (22 'Authorization': 'Basic %s' % (
20 base64.encodestring('%s:%s' % (23 base64.encodestring('%s:%s' % (
@@ -40,8 +43,9 @@
40 headers = auth_headers.copy()43 headers = auth_headers.copy()
41 if extra_headers:44 if extra_headers:
42 headers.update(extra_headers)45 headers.update(extra_headers)
43 req = urllib2.Request(46 url = settings.SERVER_JENKINS_URL + jenkins_path
44 settings.SERVER_JENKINS_URL + jenkins_path, data, headers)47 log.debug("Jenkins request: %s %s", url, data)
48 req = urllib2.Request(url, data, headers)
45 resp = urllib2.urlopen(req)49 resp = urllib2.urlopen(req)
46 return resp.read()50 return resp.read()
4751
@@ -78,6 +82,7 @@
78 try:82 try:
79 return _authJenkins('job/' + job_name + '/config.xml')83 return _authJenkins('job/' + job_name + '/config.xml')
80 except urllib2.HTTPError, e:84 except urllib2.HTTPError, e:
85 log.exception("Error getting config for Jenkins job '%s'", job_name)
81 return HttpResponse(86 return HttpResponse(
82 messageFromWinstoneErrorPage(e.read()), status=e.code)87 messageFromWinstoneErrorPage(e.read()), status=e.code)
8388
@@ -170,7 +175,7 @@
170 if not valid_build_name.match(buildName):175 if not valid_build_name.match(buildName):
171 return HttpResponse("Invalid name.", status=400)176 return HttpResponse("Invalid name.", status=400)
172 new_job_name = ownerName + '_' + buildName177 new_job_name = ownerName + '_' + buildName
173 xml_base = getJobConfig('blank')178 xml_base = getJobConfig(settings.TEMPLATE_JOB_NAME)
174 if isinstance(xml_base, HttpResponse):179 if isinstance(xml_base, HttpResponse):
175 return xml_base180 return xml_base
176 new_config = replaceConfigDefault(xml_base, request.POST['config'])181 new_config = replaceConfigDefault(xml_base, request.POST['config'])
@@ -183,6 +188,7 @@
183 '~%s/%s' % (ownerName, buildName),188 '~%s/%s' % (ownerName, buildName),
184 status=200)189 status=200)
185 except Exception, e:190 except Exception, e:
191 log.exception("")
186 return HttpResponse("Unknown error:" + str(e), status=500)192 return HttpResponse("Unknown error:" + str(e), status=500)
187193
188194
189195
=== modified file 'android_build/settings.py'
--- android_build/settings.py 2011-03-25 00:09:03 +0000
+++ android_build/settings.py 2011-04-20 17:43:39 +0000
@@ -10,6 +10,11 @@
1010
11from django.conf import global_settings11from django.conf import global_settings
12import os12import os
13import logging
14
15#TODO: switch to integrated logging configuration when upgrading
16#to django 1.3
17logging.basicConfig(level=logging.INFO)
1318
14DEBUG = True19DEBUG = True
15TEMPLATE_DEBUG = DEBUG20TEMPLATE_DEBUG = DEBUG
@@ -92,5 +97,7 @@
92SERVER_JENKINS_URL = 'http://127.0.0.1:9090/jenkins/'97SERVER_JENKINS_URL = 'http://127.0.0.1:9090/jenkins/'
93FRONTEND_JENKINS_USER = 'admin'98FRONTEND_JENKINS_USER = 'admin'
94FRONTEND_JENKINS_PASSWORD = 'password'99FRONTEND_JENKINS_PASSWORD = 'password'
100# Name of preconfigured job used as a template for all other jobs
101TEMPLATE_JOB_NAME = 'blank'
95102
96USE_OWN_COMBO=False103USE_OWN_COMBO=False

Subscribers

People subscribed via source and target branches