Merge lp:~fgiff/linaro-android-bot-review/884390 into lp:linaro-android-bot-review

Proposed by Frans Gifford
Status: Merged
Approved by: Frans Gifford
Approved revision: 77
Merged at revision: 77
Proposed branch: lp:~fgiff/linaro-android-bot-review/884390
Merge into: lp:linaro-android-bot-review
Diff against target: 128 lines (+21/-21)
3 files modified
gerritconnection.py (+10/-10)
jenkinsconnection.py (+5/-5)
lavaconnection.py (+6/-6)
To merge this branch: bzr merge lp:~fgiff/linaro-android-bot-review/884390
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Review via email: mp+80847@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Just a note - in exception handling context (in "except:" suite), you can use log.exception("message") to make it log message and associated exception stack trace. Unless you of course want to suppress stack trace logging, then using log.error() is the way to go. I don't think the distinction is critical here, so looks ok, thanks.

review: Approve
Revision history for this message
Frans Gifford (fgiff) wrote :

> Just a note - in exception handling context (in "except:" suite), you can use
> log.exception("message") to make it log message and associated exception stack
> trace. Unless you of course want to suppress stack trace logging, then using
> log.error() is the way to go. I don't think the distinction is critical here,
> so looks ok, thanks.

I didn't about log.exception, which is why I used log.error instead. We can change it later if necessary.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gerritconnection.py'
2--- gerritconnection.py 2011-10-17 21:14:56 +0000
3+++ gerritconnection.py 2011-10-31 21:34:25 +0000
4@@ -31,8 +31,8 @@
5 try:
6 self.client.load_system_host_keys(self.review_known_hosts)
7 except IOError:
8- print "Error: Failed to load known_hosts file so unable to \
9-connect to gerrit."
10+ self.log.error("Error: Failed to load known_hosts file so unable to \
11+connect to gerrit.")
12 raise
13 try:
14 self.client.connect(self.review_host,
15@@ -40,19 +40,19 @@
16 self.ssh_user,
17 key_filename=self.ssh_key_file)
18 except paramiko.BadHostKeyException:
19- print "Error: Failed verification of gerrit's SSH key. \
20-If the gerrit key has changed, please reflect this in known_hosts."
21+ self.log.error("Error: Failed verification of gerrit's SSH key. \
22+If the gerrit key has changed, please reflect this in known_hosts.")
23 raise
24 except paramiko.AuthenticationException:
25- print "Error: Failed authentication to gerrit server. Please \
26+ self.log.error("Error: Failed authentication to gerrit server. Please \
27 check the validity of username %s and SSH key %s." % (self.ssh_user,
28- self.ssh_key_file)
29+ self.ssh_key_file))
30 raise
31 except paramiko.SSHException:
32- print "Error: Failed to complete SSH session with gerrit."
33+ self.log.error("Error: Failed to complete SSH session with gerrit.")
34 raise
35 except socket.error:
36- print "Error: Socket error when connecting to gerrit."
37+ self.log.error("Error: Socket error when connecting to gerrit.")
38 raise
39 return retval
40
41@@ -128,8 +128,8 @@
42 sha1)
43 self.exec_command(cmd)
44 except paramiko.SSHException:
45- print "Error: Failed to complete SSH session with gerrit \
46-for %s %s." % (project, sha1)
47+ self.log.error("Error: Failed to complete SSH session with gerrit \
48+for %s %s." % (project, sha1))
49 raise
50
51
52
53=== modified file 'jenkinsconnection.py'
54--- jenkinsconnection.py 2011-10-14 00:36:41 +0000
55+++ jenkinsconnection.py 2011-10-31 21:34:25 +0000
56@@ -21,7 +21,7 @@
57 try:
58 f = open(jenkins_passwd_file)
59 except IOError:
60- print "Error: could not open %s." % (jenkins_passwd_file)
61+ log.error("Error: could not open %s." % (jenkins_passwd_file))
62 self.jenkins_auth = ""
63 else:
64 self.jenkins_auth = {'Authorization': 'Basic %s' % (
65@@ -132,18 +132,18 @@
66 # Send build command.
67 resp = urllib2.urlopen(req)
68 except urllib2.URLError:
69- print "Error: failed to start build."
70+ log.error("Error: failed to start build.")
71
72 # TODO: Do we care about redirects?
73 if resp.getcode() == 200:
74 build_url = "%sjob/%s/%s/" % (self.jenkins_url, job[0], job[2])
75- print "Build url: %s" % (build_url)
76+ log.error("Build url: %s" % (build_url))
77
78 else:
79 # Give some indication that stuff failed.
80- print "Failed to queue build: %s gave HTTP code %s." % (
81+ log.error( "Failed to queue build: %s gave HTTP code %s." % (
82 req.get_full_url(),
83- resp.getcode())
84+ resp.getcode()))
85 return build_url
86
87 if __name__ == "__main__":
88
89=== modified file 'lavaconnection.py'
90--- lavaconnection.py 2011-10-13 17:51:54 +0000
91+++ lavaconnection.py 2011-10-31 21:34:25 +0000
92@@ -10,7 +10,7 @@
93
94 class LoggingTransport(xmlrpclib.Transport):
95 def send_request(self, connection, handler, request_body):
96- xmlroc_log.debug("%s", (connection, handler, request_body))
97+ xmlrpc_log.debug("%s", (connection, handler, request_body))
98 return xmlrpclib.Transport.send_request(self, connection, handler, request_body)
99
100
101@@ -70,10 +70,10 @@
102 bundles = self.server.dashboard.bundles("%s" % (self.lava_stream))
103 except xmlrpclib.Fault:
104 # Problem with LAVA xmlrpc call.
105- print "Error: Couldn't get test results from LAVA."
106+ self.log.error("Error: Couldn't get test results from LAVA.")
107 except xmlrpclib.ProtocolError:
108 # Problem connecting to LAVA.
109- print "Error: Couldn't connect to LAVA."
110+ self.log.error("Error: Couldn't connect to LAVA.")
111 lava_results = []
112 # Since we're operating on fresh builds, we know the bundle will
113 # have been uploaded in the last 48 hrs, so prune out older ones.
114@@ -96,12 +96,12 @@
115 # Not a user-friendly identifier, but we'd need to download
116 # the bundle to work out which build it corresponds to
117 # and this error occurs when we can't do that.
118- print "Error: Couldn't fetch test results for %s" % (
119- bundle["content_sha1"])
120+ self.log.error("Error: Couldn't fetch test results for %s" % (
121+ bundle["content_sha1"]))
122 continue
123 except xmlrpclib.ProtocolError:
124 # Problem connecting to LAVA.
125- print "Error: Couldn't connect to LAVA."
126+ self.log.error("Error: Couldn't connect to LAVA.")
127 continue
128 return lava_results
129

Subscribers

People subscribed via source and target branches

to all changes: