Merge lp:~pedronis/tanuki-agent/rpi2-sample-provkit-use-py2 into lp:tanuki-agent

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 116
Merged at revision: 116
Proposed branch: lp:~pedronis/tanuki-agent/rpi2-sample-provkit-use-py2
Merge into: lp:tanuki-agent
Diff against target: 110 lines (+22/-13)
3 files modified
rpi2-sample-provkit/runtest (+7/-4)
rpi2-sample-provkit/setup (+7/-4)
rpi2-sample-provkit/test_tarball_content/test (+8/-5)
To merge this branch: bzr merge lp:~pedronis/tanuki-agent/rpi2-sample-provkit-use-py2
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Review via email: mp+275193@code.launchpad.net

Commit message

convert the whole sample provkit to use py2 for consistency (also of deps)

Description of the change

convert the whole sample provkit to use py2 for consistency (also of deps)

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

Awesome

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rpi2-sample-provkit/runtest'
2--- rpi2-sample-provkit/runtest 2015-10-15 19:57:02 +0000
3+++ rpi2-sample-provkit/runtest 2015-10-21 14:45:32 +0000
4@@ -1,10 +1,13 @@
5-#!/usr/bin/env python3
6+#!/usr/bin/python2
7+
8+from __future__ import print_function
9
10 import argparse
11+import codecs
12 import json
13 import os
14 import subprocess
15-import urllib.parse
16+import urlparse
17
18 TESTS_DIR = "tests"
19
20@@ -12,13 +15,13 @@
21 def main(args):
22 """Main entry point."""
23 # get the test opportunity content
24- with open(args.test_opp, 'rt', encoding='utf8') as fh:
25+ with codecs.open(args.test_opp, 'rt', encoding='utf8') as fh:
26 test_opp = json.load(fh)
27
28 tarball_url = test_opp['test_payload']['tarball_url']
29 test_cmd = test_opp['test_payload']['test_cmd']
30
31- name = os.path.basename(urllib.parse.urlparse(tarball_url).path)
32+ name = os.path.basename(urlparse.urlparse(tarball_url).path)
33 if not os.path.exists(TESTS_DIR):
34 os.mkdir(TESTS_DIR)
35 print("Downloading {}...".format(tarball_url))
36
37=== modified file 'rpi2-sample-provkit/setup'
38--- rpi2-sample-provkit/setup 2015-10-15 19:57:02 +0000
39+++ rpi2-sample-provkit/setup 2015-10-21 14:45:32 +0000
40@@ -1,11 +1,14 @@
41-#!/usr/bin/env python3
42+#!/usr/bin/python2
43+
44+from __future__ import print_function
45
46 import argparse
47+import codecs
48 import json
49 import os
50 import subprocess
51 import sys
52-import urllib
53+import urlparse
54
55 import requests
56
57@@ -18,7 +21,7 @@
58 ip = os.getenv('RPI2_IP', 'webdm.local')
59 port = int(os.getenv('RPI2_SSH_PORT', 22))
60 # get the test opportunity content
61- with open(args.test_opp, 'rt', encoding='utf8') as fh:
62+ with codecs.open(args.test_opp, 'rt', encoding='utf8') as fh:
63 test_opp = json.load(fh)
64
65 # find snap(s) to upgrade
66@@ -44,7 +47,7 @@
67 .format(snap_name, snap_revno, info['sequence']), file=sys.stderr)
68 sys.exit(1)
69 url = info['anon_download_url']
70- snap_fname = os.path.basename(urllib.parse.urlparse(url).path)
71+ snap_fname = os.path.basename(urlparse.urlparse(url).path)
72 subprocess.check_call(['curl', '-O', url])
73 subprocess.check_call(['snappy-remote', '--url',
74 'ssh://ubuntu@{}:{}'.format(ip, port),
75
76=== modified file 'rpi2-sample-provkit/test_tarball_content/test'
77--- rpi2-sample-provkit/test_tarball_content/test 2015-10-15 19:57:02 +0000
78+++ rpi2-sample-provkit/test_tarball_content/test 2015-10-21 14:45:32 +0000
79@@ -1,5 +1,8 @@
80-#!/usr/bin/env python3
81-
82+#!/usr/bin/python2
83+
84+from __future__ import print_function
85+
86+import codecs
87 import json
88 import os
89 import subprocess
90@@ -22,7 +25,7 @@
91 rpi2_address = os.environ['RPI2_IP']
92 rpi2_ssh_port = os.environ['RPI2_SSH_PORT']
93 test_opp_path = os.environ['TEST_OPPORTUNITY']
94- with open(test_opp_path, 'rt', encoding='utf8') as fh:
95+ with codecs.open(test_opp_path, 'rt', encoding='utf8') as fh:
96 test_opp = json.load(fh)
97
98 # find snap(s) to check version
99@@ -38,9 +41,9 @@
100 real_revno = check_function(rpi2_address, rpi2_ssh_port)
101 expected = str(snaps[snap_name])
102 assert real_revno == expected, "real={!r} != expected={!r}".format(real_revno, expected)
103- with open("../spi_test_result.json", "wt", encoding="utf8") as fh:
104+ with codecs.open("../spi_test_result.json", "wt", encoding="utf8") as fh:
105 json.dump({'result': 'OK'}, fh)
106-
107+
108
109 if __name__ == '__main__':
110 main()

Subscribers

People subscribed via source and target branches

to all changes: