Merge lp:~sil2100/ubuntu-archive-tools/kernel-sru-cleanup into lp:ubuntu-archive-tools

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 1087
Proposed branch: lp:~sil2100/ubuntu-archive-tools/kernel-sru-cleanup
Merge into: lp:ubuntu-archive-tools
Diff against target: 44 lines (+15/-4)
1 file modified
kernel-sru-review (+15/-4)
To merge this branch: bzr merge lp:~sil2100/ubuntu-archive-tools/kernel-sru-cleanup
Reviewer Review Type Date Requested Status
Ubuntu Package Archive Administrators Pending
Review via email: mp+320254@code.launchpad.net

Commit message

Download the kernel sources to temporary directories in kernel-sru-review, cleanup when done. Allow for bypassing the cleanup mechanism.

Description of the change

Download the kernel sources to temporary directories in kernel-sru-review, cleanup when done. Allow for bypassing the cleanup mechanism.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'kernel-sru-review'
2--- kernel-sru-review 2017-01-19 13:45:58 +0000
3+++ kernel-sru-review 2017-03-17 19:39:13 +0000
4@@ -32,9 +32,12 @@
5 import os
6 import pytz
7 import re
8+import shutil
9 import subprocess
10 import sys
11 import time
12+from contextlib import ExitStack
13+from tempfile import mkdtemp
14 from optparse import OptionParser
15
16 from launchpadlib.launchpad import Launchpad
17@@ -185,6 +188,8 @@
18
19 parser.add_option(
20 "-l", "--launchpad", dest="launchpad_instance", default="production")
21+ parser.add_option(
22+ "-k", "--keep-files", dest="keep_files", action="store_true")
23
24 opts, bugs = parser.parse_args()
25
26@@ -200,8 +205,14 @@
27 distribution=ubuntu, name='ppa')
28
29 context = {'archive': archive, 'ppa': ppa, 'ubuntu': ubuntu}
30+ main_dir = os.getcwd()
31 for bugnum in bugs:
32- process_sru_bug(
33- launchpad, bugnum, review_task_callback, review_source_callback,
34- context)
35- # XXX: clean up temp files
36+ with ExitStack() as resources:
37+ cwd = mkdtemp(prefix='kernel-sru-{}-'.format(bugnum), dir=main_dir)
38+ if not opts.keep_files:
39+ resources.callback(shutil.rmtree, cwd)
40+ os.chdir(cwd)
41+ process_sru_bug(
42+ launchpad, bugnum, review_task_callback,
43+ review_source_callback, context)
44+ os.chdir(main_dir)

Subscribers

People subscribed via source and target branches