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
1=== modified file 'android_build/frontend/api.py'
2--- android_build/frontend/api.py 2011-03-15 01:09:15 +0000
3+++ android_build/frontend/api.py 2011-04-20 17:43:39 +0000
4@@ -2,6 +2,7 @@
5 import re
6 import subprocess
7 import urllib2
8+import logging
9
10 from django.conf import settings
11 from django.http import HttpResponse
12@@ -15,6 +16,8 @@
13 )
14
15
16+log = logging.getLogger(__name__)
17+
18 auth_headers = {
19 'Authorization': 'Basic %s' % (
20 base64.encodestring('%s:%s' % (
21@@ -40,8 +43,9 @@
22 headers = auth_headers.copy()
23 if extra_headers:
24 headers.update(extra_headers)
25- req = urllib2.Request(
26- settings.SERVER_JENKINS_URL + jenkins_path, data, headers)
27+ url = settings.SERVER_JENKINS_URL + jenkins_path
28+ log.debug("Jenkins request: %s %s", url, data)
29+ req = urllib2.Request(url, data, headers)
30 resp = urllib2.urlopen(req)
31 return resp.read()
32
33@@ -78,6 +82,7 @@
34 try:
35 return _authJenkins('job/' + job_name + '/config.xml')
36 except urllib2.HTTPError, e:
37+ log.exception("Error getting config for Jenkins job '%s'", job_name)
38 return HttpResponse(
39 messageFromWinstoneErrorPage(e.read()), status=e.code)
40
41@@ -170,7 +175,7 @@
42 if not valid_build_name.match(buildName):
43 return HttpResponse("Invalid name.", status=400)
44 new_job_name = ownerName + '_' + buildName
45- xml_base = getJobConfig('blank')
46+ xml_base = getJobConfig(settings.TEMPLATE_JOB_NAME)
47 if isinstance(xml_base, HttpResponse):
48 return xml_base
49 new_config = replaceConfigDefault(xml_base, request.POST['config'])
50@@ -183,6 +188,7 @@
51 '~%s/%s' % (ownerName, buildName),
52 status=200)
53 except Exception, e:
54+ log.exception("")
55 return HttpResponse("Unknown error:" + str(e), status=500)
56
57
58
59=== modified file 'android_build/settings.py'
60--- android_build/settings.py 2011-03-25 00:09:03 +0000
61+++ android_build/settings.py 2011-04-20 17:43:39 +0000
62@@ -10,6 +10,11 @@
63
64 from django.conf import global_settings
65 import os
66+import logging
67+
68+#TODO: switch to integrated logging configuration when upgrading
69+#to django 1.3
70+logging.basicConfig(level=logging.INFO)
71
72 DEBUG = True
73 TEMPLATE_DEBUG = DEBUG
74@@ -92,5 +97,7 @@
75 SERVER_JENKINS_URL = 'http://127.0.0.1:9090/jenkins/'
76 FRONTEND_JENKINS_USER = 'admin'
77 FRONTEND_JENKINS_PASSWORD = 'password'
78+# Name of preconfigured job used as a template for all other jobs
79+TEMPLATE_JOB_NAME = 'blank'
80
81 USE_OWN_COMBO=False

Subscribers

People subscribed via source and target branches