Merge lp://qastaging/~liuyq0307/lava-android-test/extract-attachments into lp://qastaging/lava-android-test
Proposed by
Yongqin Liu
Status: | Merged |
---|---|
Merged at revision: | 191 |
Proposed branch: | lp://qastaging/~liuyq0307/lava-android-test/extract-attachments |
Merge into: | lp://qastaging/lava-android-test |
Diff against target: |
111 lines (+68/-3) 2 files modified
lava_android_test/commands.py (+67/-3) setup.py (+1/-0) |
To merge this branch: | bzr merge lp://qastaging/~liuyq0307/lava-android-test/extract-attachments |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andy Doan (community) | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2012-08-06.
Description of the change
add extract-attachments sub command to extract the log or image files from the json format result file
updated according to the review comment
To post a comment you must log in.
On 08/06/2012 02:02 AM, Yongqin Liu wrote: test/commands. py' test/commands. py 2012-06-28 11:29:49 +0000 test/commands. py 2012-08-06 07:01:28 +0000 exists( self.args. result_ file): r("The specified result file(%s) " result_ file)
> === modified file 'lava_android_
> --- lava_android_
> +++ lava_android_
<snip>
> + def invoke(self):
> +
> + if not os.path.
> + raise LavaCommandErro
> + "is not existed." % self.args.
Bad grammar: This should be "The specified file(%s) does not exist"
> + msg = "extract attachment file from result bundle file(%s)" % ( result_ file)
> + self.args.
> + self.say_begin(msg)
> + badchars = "[^a-zA-Z0-9\._-]"
badchars? looks like these are "good" chars?
> + with open(self. args.result_ file) as stream: loads(jobdata) [1] data.get( 'test_runs' ) prefix= 'attachments- ', dir=os.path.curdir) 'test_id' ).replace( " ", "_")
> + jobdata = stream.read()
> + result_data = DocumentIO.
> + test_runs = result_
> + attachment_dir = mkdtemp(
> + for test in test_runs:
> + test_id = test.get(
> + test_id = re.sub(badchars, "_", test_id)
> + target_dir = mkdtemp(prefix='%s' % test_id, dir=attachment_dir)
maybe this should be a command line option for the user to specify the
output directory?
> + print "The test id is: %s" % test_id 'attachments' , []) get('pathname' ) basename( pathname) standard_ b64decode( get("content" )) path.join( target_ dir, file_name), 'a') as fd:
> + attachments = test.get(
> + for attach in attachments:
> + pathname = attach.
> + file_name = os.path.
> + content_decoded = base64.
> + attach.
> + with open(os.
you are opening the file in append mode, shouldn't it just be 'w' instead?