Merge lp:~maxb/udd/pythonpath-1 into lp:udd

Proposed by Max Bowsher
Status: Merged
Approved by: James Westby
Approved revision: 593
Merged at revision: 593
Proposed branch: lp:~maxb/udd/pythonpath-1
Merge into: lp:udd
Diff against target: 323 lines (+51/-96)
21 files modified
bin/_path.py (+7/-0)
bin/add-import-jobs (+1/-3)
bin/analyze-log (+2/-7)
bin/branch-branches-from-lp (+2/-5)
bin/categorise-failures (+2/-5)
bin/count-outstanding-jobs (+2/-5)
bin/delete-branches-from-lp (+2/-5)
bin/email-failures (+2/-5)
bin/graph-failures (+2/-5)
bin/import-package (+2/-6)
bin/list-packages (+2/-6)
bin/logrotate (+2/-7)
bin/mass-import (+2/-5)
bin/requeue-package (+2/-5)
bin/set-official (+2/-5)
bin/show-failure (+2/-5)
etc-init.d-mass-import (+3/-4)
fixit.sh (+3/-4)
importer.crontab (+3/-4)
udd/scripts/analyze_log.py (+4/-4)
udd/scripts/logrotate.py (+2/-1)
To merge this branch: bzr merge lp:~maxb/udd/pythonpath-1
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+104696@code.launchpad.net

Description of the change

The primary motivation of this branch is to make all of the bin/* scripts automatically set up the Python path in order to be able to access the udd.* Python modules from the same branch, without any external wrapper assistance.

Because of a previous attempt (https://code.launchpad.net/~maxb/udd/environment-setup/+merge/101307) becoming mired, it very specifically only attempts to address the single path element of the udd.* modules themselves, and does not address the requirement on jubany to run with an overridden bzrlib and distro-info.

Even so, this change alone is enough to make the various bin/* scripts usefully invokable on a Precise machine without PYTHONPATH preparation.

Along with the main thrust of this branch as above, a number of minor cleanups are included, each in a separate revision - I recommend reviewing this branch revision by revision, *not* reviewing the aggregate diff.

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=== added file 'bin/_path.py'
2--- bin/_path.py 1970-01-01 00:00:00 +0000
3+++ bin/_path.py 2012-05-04 07:57:18 +0000
4@@ -0,0 +1,7 @@
5+import os
6+import sys
7+
8+udd_scripts_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9+
10+# scripts branch root contains the udd library
11+sys.path.insert(0, udd_scripts_root)
12
13=== modified file 'bin/add-import-jobs'
14--- bin/add-import-jobs 2011-10-21 10:17:16 +0000
15+++ bin/add-import-jobs 2012-05-04 07:57:18 +0000
16@@ -1,6 +1,4 @@
17 #!/usr/bin/python
18-
19+import _path
20 from udd.scripts.add_import_jobs import main
21-
22-
23 main()
24
25=== modified file 'bin/analyze-log'
26--- bin/analyze-log 2011-10-21 10:17:16 +0000
27+++ bin/analyze-log 2012-05-04 07:57:18 +0000
28@@ -1,11 +1,6 @@
29 #!/usr/bin/python
30 """Analyzes the package importer log files collecting various historical data.
31 """
32-
33-import sys
34-
35+import _path
36 from udd.scripts.analyze_log import main
37-
38-
39-if __name__ == '__main__':
40- main(sys.argv)
41+main()
42
43=== modified file 'bin/branch-branches-from-lp'
44--- bin/branch-branches-from-lp 2011-10-21 10:17:16 +0000
45+++ bin/branch-branches-from-lp 2012-05-04 07:57:18 +0000
46@@ -1,9 +1,6 @@
47 #!/usr/bin/python
48 # Script to create local branches from all existing official package branches
49 # of a package, for debugging purposes.
50-
51+import _path
52 from udd.scripts.branch_branches_from_lp import main
53-
54-
55-if __name__ == '__main__':
56- main()
57+main()
58
59=== modified file 'bin/categorise-failures'
60--- bin/categorise-failures 2011-10-21 10:17:16 +0000
61+++ bin/categorise-failures 2012-05-04 07:57:18 +0000
62@@ -1,7 +1,4 @@
63 #!/usr/bin/python
64-
65+import _path
66 from udd.scripts.categorise_failures import main
67-
68-
69-if __name__ == '__main__':
70- main()
71+main()
72
73=== modified file 'bin/count-outstanding-jobs'
74--- bin/count-outstanding-jobs 2011-10-21 10:17:16 +0000
75+++ bin/count-outstanding-jobs 2012-05-04 07:57:18 +0000
76@@ -1,7 +1,4 @@
77 #!/usr/bin/python
78-
79+import _path
80 from udd.scripts.count_outstanding_jobs import main
81-
82-
83-if __name__ == '__main__':
84- main()
85+main()
86
87=== modified file 'bin/delete-branches-from-lp'
88--- bin/delete-branches-from-lp 2011-10-21 10:17:16 +0000
89+++ bin/delete-branches-from-lp 2012-05-04 07:57:18 +0000
90@@ -1,7 +1,4 @@
91 #!/usr/bin/python
92-
93+import _path
94 from udd.scripts.delete_branches_from_lp import main
95-
96-
97-if __name__ == '__main__':
98- main()
99+main()
100
101=== modified file 'bin/email-failures'
102--- bin/email-failures 2011-10-21 10:17:16 +0000
103+++ bin/email-failures 2012-05-04 07:57:18 +0000
104@@ -1,7 +1,4 @@
105 #!/usr/bin/python
106-
107+import _path
108 from udd.scripts.email_failures import main
109-
110-
111-if __name__ == '__main__':
112- main()
113+main()
114
115=== modified file 'bin/graph-failures'
116--- bin/graph-failures 2011-10-21 10:17:16 +0000
117+++ bin/graph-failures 2012-05-04 07:57:18 +0000
118@@ -1,7 +1,4 @@
119 #!/usr/bin/python
120-
121+import _path
122 from udd.scripts.graph_failures import main
123-
124-
125-if __name__ == '__main__':
126- main()
127+main()
128
129=== modified file 'bin/import-package'
130--- bin/import-package 2011-12-08 18:01:01 +0000
131+++ bin/import-package 2012-05-04 07:57:18 +0000
132@@ -1,8 +1,4 @@
133 #!/usr/bin/python
134-
135+import _path
136 from udd.scripts.import_package import main
137-
138-
139-if __name__ == '__main__':
140- main()
141-
142+main()
143
144=== modified file 'bin/list-packages'
145--- bin/list-packages 2011-10-21 10:17:16 +0000
146+++ bin/list-packages 2012-05-04 07:57:18 +0000
147@@ -1,9 +1,5 @@
148 #!/usr/bin/python
149-
150 """Get a list of packages from Launchpad and store them in the local database."""
151-
152+import _path
153 from udd.scripts.list_packages import main
154-
155-
156-if __name__ == '__main__':
157- main()
158+main()
159
160=== modified file 'bin/logrotate'
161--- bin/logrotate 2011-10-21 10:17:16 +0000
162+++ bin/logrotate 2012-05-04 07:57:18 +0000
163@@ -1,11 +1,6 @@
164 #!/usr/bin/python
165 """Invoke logrotate for the package importer taking configuration into account.
166 """
167-
168-import sys
169-
170+import _path
171 from udd.scripts.logrotate import main
172-
173-
174-if __name__ == '__main__':
175- sys.exit(main())
176+main()
177
178=== modified file 'bin/mass-import'
179--- bin/mass-import 2011-10-21 10:17:16 +0000
180+++ bin/mass-import 2012-05-04 07:57:18 +0000
181@@ -1,7 +1,4 @@
182 #!/usr/bin/python
183-
184+import _path
185 from udd.scripts.mass_import import main
186-
187-
188-if __name__ == '__main__':
189- main()
190+main()
191
192=== modified file 'bin/requeue-package'
193--- bin/requeue-package 2011-10-21 10:17:16 +0000
194+++ bin/requeue-package 2012-05-04 07:57:18 +0000
195@@ -1,7 +1,4 @@
196 #!/usr/bin/python
197-
198+import _path
199 from udd.scripts.requeue_package import main
200-
201-
202-if __name__ == '__main__':
203- main()
204+main()
205
206=== modified file 'bin/set-official'
207--- bin/set-official 2011-10-21 10:17:16 +0000
208+++ bin/set-official 2012-05-04 07:57:18 +0000
209@@ -1,7 +1,4 @@
210 #!/usr/bin/python
211-
212+import _path
213 from udd.scripts.set_official import main
214-
215-
216-if __name__ == '__main__':
217- main()
218+main()
219
220=== modified file 'bin/show-failure'
221--- bin/show-failure 2011-10-21 10:17:16 +0000
222+++ bin/show-failure 2012-05-04 07:57:18 +0000
223@@ -1,7 +1,4 @@
224 #!/usr/bin/python
225-
226+import _path
227 from udd.scripts.show_failure import main
228-
229-
230-if __name__ == '__main__':
231- main()
232+main()
233
234=== modified file 'etc-init.d-mass-import'
235--- etc-init.d-mass-import 2011-11-08 13:06:03 +0000
236+++ etc-init.d-mass-import 2012-05-04 07:57:18 +0000
237@@ -3,10 +3,9 @@
238 export BASEDIR=/srv/package-import.canonical.com/new
239 # We need ${BASEDIR}/scripts for our local dpkg-mergechangelogs
240 export PATH=${BASEDIR}/scripts:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
241-# 1) 'scripts' contains the udd library.
242-# 2) If a local bzr is installed, use it
243-# 3) bzr-builddeb requires distro-info
244-export PYTHONPATH=${BASEDIR}/scripts:${BASEDIR}/bzr:${BASEDIR}/distro-info/python
245+# * If a local bzr is installed, use it
246+# * bzr-builddeb requires distro-info
247+export PYTHONPATH=${BASEDIR}/bzr:${BASEDIR}/distro-info/python
248 NAME=mass-import
249 DAEMON=${BASEDIR}/scripts/bin/mass-import
250 PIDFILE=${BASEDIR}/mass-import.pid
251
252=== modified file 'fixit.sh'
253--- fixit.sh 2011-11-08 13:06:03 +0000
254+++ fixit.sh 2012-05-04 07:57:18 +0000
255@@ -13,10 +13,9 @@
256
257 export BASEDIR=/srv/package-import.canonical.com/new
258 export PATH=${BASEDIR}/scripts/bin:${PATH}
259-# 1) 'scripts' contains the udd library.
260-# 2) If a local bzr is installed, use it
261-# 3) bzr-builddeb requires distro-info
262-export PYTHONPATH=${BASEDIR}/scripts:${BASEDIR}/bzr:${BASEDIR}/distro-info/python
263+# * If a local bzr is installed, use it
264+# * bzr-builddeb requires distro-info
265+export PYTHONPATH=${BASEDIR}/bzr:${BASEDIR}/distro-info/python
266 export BZR_PLUGIN_PATH=${BASEDIR}/scripts/plugins
267 export LANG="en_GB.UTF-8"
268 export BZR_EMAIL="Package Import Robot <package-import@ubuntu.com>"
269
270=== modified file 'importer.crontab'
271--- importer.crontab 2011-11-08 13:06:03 +0000
272+++ importer.crontab 2012-05-04 07:57:18 +0000
273@@ -1,8 +1,7 @@
274 SCRIPTS_DIR=/srv/package-import.canonical.com/new/scripts/bin
275-# 1) 'scripts' contains the udd library.
276-# 2) If a local bzr is installed, use it
277-# 3) bzr-builddeb requires distro-info
278-PYTHONPATH=/srv/package-import.canonical.com/new/scripts:/srv/package-import.canonical.com/new/bzr:/srv/package-import.canonical.com/new/distro-info/python
279+# * If a local bzr is installed, use it
280+# * bzr-builddeb requires distro-info
281+PYTHONPATH=/srv/package-import.canonical.com/new/bzr:/srv/package-import.canonical.com/new/distro-info/python
282 # m h dom mon dow command
283 17 * * * * /usr/bin/python ${SCRIPTS_DIR}/logrotate
284 */5 * * * * /usr/bin/python ${SCRIPTS_DIR}/categorise-failures
285
286=== modified file 'udd/scripts/analyze_log.py'
287--- udd/scripts/analyze_log.py 2011-10-10 11:01:48 +0000
288+++ udd/scripts/analyze_log.py 2012-05-04 07:57:18 +0000
289@@ -508,12 +508,12 @@
290 self.report_all()
291
292
293-def main(args):
294- if len(args) != 2:
295- print 'Usage: %s <log file path>'
296+def main():
297+ if len(sys.argv) != 2:
298+ print 'Usage: %s <log file path>' % (sys.argv[0],)
299 exit(1)
300
301- log_path = args[1]
302+ log_path = sys.argv[1]
303 if log_path == '-':
304 f = sys.stdin
305 else:
306
307=== modified file 'udd/scripts/logrotate.py'
308--- udd/scripts/logrotate.py 2011-12-10 09:12:13 +0000
309+++ udd/scripts/logrotate.py 2012-05-04 07:57:18 +0000
310@@ -3,6 +3,7 @@
311
312 import os
313 import subprocess
314+import sys
315
316 from udd import (
317 icommon,
318@@ -42,4 +43,4 @@
319 lrot_state_path = os.path.join(log_dir, 'logrotate.state')
320 retcode = subprocess.call(['/usr/sbin/logrotate', '-s', lrot_state_path,
321 lrot_conf_path])
322- return retcode
323+ sys.exit(retcode)

Subscribers

People subscribed via source and target branches