Merge lp:~linaro-validation/lava-core/doanac-fixes into lp:~zyga/lava-core/demo-3

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 25
Merged at revision: 23
Proposed branch: lp:~linaro-validation/lava-core/doanac-fixes
Merge into: lp:~zyga/lava-core/demo-3
Diff against target: 90 lines (+22/-3)
4 files modified
history_demo.py (+1/-1)
lava/core/controllers/devices/qemu.py (+1/-1)
lava/core/utils.py (+18/-1)
setup.py (+2/-0)
To merge this branch: bzr merge lp:~linaro-validation/lava-core/doanac-fixes
Reviewer Review Type Date Requested Status
Zygmunt Krynicki Approve
Review via email: mp+106932@code.launchpad.net

Description of the change

Reproposing the branch against a better target so the diff makes some sense.

From the original proposal (https://code.launchpad.net/~linaro-validation/lava-core/doanac-fixes/+merge/106725):

zygmunt - not sure what you want to do with these, but here are some minro fixes I had to make to get things working for me.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

66 + def decompress(self, stream, suffix):
67 + commands = { 'gz':'gunzip', 'bz2':'bunzip2' }
68 + command = commands[suffix]
69 + uncompressed_name = stream.name[:-len(suffix)-1]
70 + self.logger.info("Uncompressing %s with %s to %s",
71 + stream.name, command, uncompressed_name)
72 + subprocess.check_call(
73 + [command, '-c', stream.name], stdout=open(uncompressed_name, 'w'))
74 + stream.name = uncompressed_name

As discussed on IRC, I'd prefer a pure python solution for reliability. I'll get this in and then rewrite it as things land to trunk. Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'history_demo.py'
2--- history_demo.py 2012-04-26 02:03:09 +0000
3+++ history_demo.py 2012-05-23 04:07:21 +0000
4@@ -18,7 +18,7 @@
5 # along with lava-core. If not, see <http://www.gnu.org/licenses/>.
6
7 from json_document.serializers import JSON
8-from lava.utils.logging.history import history
9+from lava.core.history import history
10
11
12 def get_food():
13
14=== modified file 'lava/core/controllers/devices/qemu.py'
15--- lava/core/controllers/devices/qemu.py 2012-05-04 02:29:53 +0000
16+++ lava/core/controllers/devices/qemu.py 2012-05-23 04:07:21 +0000
17@@ -214,7 +214,7 @@
18 def _use_prebuilt_image(self, session):
19 # TODO: wrap download issues as UnrecoverableProblem
20 return session.network.download(
21- self.configuration.image, hint='image')
22+ self.configuration.image, compressed=True)
23
24 def _use_partial_image(self, session):
25 # Download both pieces
26
27=== modified file 'lava/core/utils.py'
28--- lava/core/utils.py 2012-05-11 15:27:07 +0000
29+++ lava/core/utils.py 2012-05-23 04:07:21 +0000
30@@ -34,6 +34,7 @@
31 import datetime
32 import os
33 import shutil
34+import subprocess
35 import sys
36 import tempfile
37
38@@ -214,10 +215,12 @@
39 self._scratch = scratch
40 self._proxies = {'http': http_proxy, 'https': https_proxy}
41
42- def download(self, url, hint=''):
43+ def download(self, url, compressed=False, hint=None):
44 """
45 Download something to temporary session storage
46
47+ If compressed, the file will be decompressed while downloading
48+
49 Extra suffix, if provided, helps to identify the file as if will be
50 used in the part of the temporary name.
51
52@@ -231,11 +234,25 @@
53 except requests.exceptions.RequestException as exc:
54 raise UnrecoverableProblem(
55 "Cannot download: {0}: {1}".format(url, exc))
56+ if hint is None:
57+ hint = url.split('.')[-1]
58 with self._scratch.unique(prefix='download.',
59 suffix="." + hint) as stream:
60 down.save(stream)
61+ stream.close() #flush to disk
62+ if compressed:
63+ self.decompress(stream, hint)
64 return stream.name
65
66+ def decompress(self, stream, suffix):
67+ commands = { 'gz':'gunzip', 'bz2':'bunzip2' }
68+ command = commands[suffix]
69+ uncompressed_name = stream.name[:-len(suffix)-1]
70+ self.logger.info("Uncompressing %s with %s to %s",
71+ stream.name, command, uncompressed_name)
72+ subprocess.check_call(
73+ [command, '-c', stream.name], stdout=open(uncompressed_name, 'w'))
74+ stream.name = uncompressed_name
75
76 class ObjectWithConfiguration(object):
77 """
78
79=== modified file 'setup.py'
80--- setup.py 2012-05-11 15:27:07 +0000
81+++ setup.py 2012-05-23 04:07:21 +0000
82@@ -80,6 +80,8 @@
83 'argparse >= 1.1',
84 'json-document >= 0.8',
85 'json-schema-validator',
86+ 'keyring',
87+ 'setproctitle',
88 ],
89 tests_require=[
90 'mocker >= 1.0',

Subscribers

People subscribed via source and target branches