Merge lp:~stevanr/linaro-license-protection/bug-1069814 into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Approved by: Georgy Redkozubov
Approved revision: 140
Merged at revision: 140
Proposed branch: lp:~stevanr/linaro-license-protection/bug-1069814
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 240 lines (+66/-59)
4 files modified
license_protected_downloads/render_text_files.py (+7/-39)
license_protected_downloads/tests/test_render_text_files.py (+25/-20)
scripts/publish_to_snapshots.py (+1/-0)
settings.py (+33/-0)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/bug-1069814
Reviewer Review Type Date Requested Status
Fathi Boudra Needs Fixing
Georgy Redkozubov Approve
Linaro Infrastructure Pending
Review via email: mp+130881@code.launchpad.net

Description of the change

Move textile constants to settings so we can change them for releases.*.

To post a comment you must log in.
Revision history for this message
Georgy Redkozubov (gesha) wrote :

Stevan, thanks for taking bug.
Looks good.

review: Approve
Revision history for this message
Fathi Boudra (fboudra) wrote :

For LP: #1069814, we need to append .textile extension.
Also, please rename UBUNTU_FILES to a generic term like LINUX_FILES. The pattern applies to Ubuntu and OpenEmbedded builds.

review: Needs Fixing
Revision history for this message
Georgy Redkozubov (gesha) wrote :

> For LP: #1069814, we need to append .textile extension.

Fathi, this file is not used for releases, it's generic. For snapshots/releases we override settings in other branch if needed: https://code.launchpad.net/~linaro-infrastructure/linaro-license-protection/configs

Please comment in https://code.launchpad.net/~stevanr/linaro-license-protection/bug-1069814-configs/+merge/130884 what files should have .textile extension.

> Also, please rename UBUNTU_FILES to a generic term like LINUX_FILES. The
> pattern applies to Ubuntu and OpenEmbedded builds.

Fathi, you rule there :)

Stevan, also please update STAGING_ACCEPTED_FILES in scripts/publish_to_snapshots.py as appropriate.

Thanks.

Revision history for this message
Fathi Boudra (fboudra) wrote :

On 23 October 2012 09:06, Georgy Redkozubov wrote:
>> For LP: #1069814, we need to append .textile extension.
>
> Fathi, this file is not used for releases, it's generic. For snapshots/releases we override settings in other branch if needed: https://code.launchpad.net/~linaro-infrastructure/linaro-license-protection/configs
> Please comment in https://code.launchpad.net/~stevanr/linaro-license-protection/bug-1069814-configs/+merge/130884 what files should have .textile extension.

IMO, the markup language extension is generic. According to your
comment, it should be in both branches.

141. By Stevan Radaković

Apply changes from code review fixes.

Revision history for this message
Georgy Redkozubov (gesha) wrote :

Changes look good.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/render_text_files.py'
2--- license_protected_downloads/render_text_files.py 2012-10-22 17:00:23 +0000
3+++ license_protected_downloads/render_text_files.py 2012-10-23 09:39:09 +0000
4@@ -4,38 +4,6 @@
5 from collections import OrderedDict
6 from django.conf import settings
7
8-UBUNTU_FILES = ('README',
9- 'INSTALL',
10- 'HACKING',
11- 'FIRMWARE',
12- 'RTSM')
13-ANDROID_FILES = ('HOWTO_releasenotes.txt',
14- 'HOWTO_install.txt',
15- 'HOWTO_getsourceandbuild.txt',
16- 'HOWTO_flashfirmware.txt',
17- 'HOWTO_rtsm.txt')
18-
19-MANDATORY_ANDROID_FILES = ('HOWTO_install.txt',
20- 'HOWTO_getsourceandbuild.txt',
21- 'HOWTO_flashfirmware.txt')
22-
23-FILES_MAP = {'HOWTO_releasenotes.txt': 'Release Notes',
24- 'HOWTO_install.txt': 'Binary Image Installation',
25- 'HOWTO_getsourceandbuild.txt': 'Building From Source',
26- 'HOWTO_flashfirmware.txt': 'Firmware Update',
27- 'HOWTO_rtsm.txt': 'RTSM',
28- 'README': 'Release Notes',
29- 'INSTALL': 'Binary Image Installation',
30- 'HACKING': 'Building From Source',
31- 'FIRMWARE': 'Firmware Update',
32- 'RTSM': 'RTSM'}
33-
34-TAB_PRIORITY = ['Release Notes',
35- 'Binary Image Installation',
36- 'Building From Source',
37- 'Firmware Update',
38- 'RTSM']
39-
40
41 class MultipleFilesException(Exception):
42 pass
43@@ -48,7 +16,7 @@
44
45 @classmethod
46 def sort_tabs_by_priority(cls, a, b):
47- base_list = TAB_PRIORITY
48+ base_list = settings.TAB_PRIORITY
49 return base_list.index(a[0]) - base_list.index(b[0])
50
51 @classmethod
52@@ -64,16 +32,16 @@
53
54 if filepaths:
55 for filepath in filepaths:
56- title = FILES_MAP[os.path.basename(filepath)]
57+ title = settings.FILES_MAP[os.path.basename(filepath)]
58 result[title] = cls.render_file(filepath)
59
60 # Switch to fallback data for mandatory files.
61 if cls.check_for_manifest_or_tarballs(path):
62- for filename in MANDATORY_ANDROID_FILES:
63- if FILES_MAP[filename] not in result:
64+ for filename in settings.MANDATORY_ANDROID_FILES:
65+ if settings.FILES_MAP[filename] not in result:
66 filepath = os.path.join(settings.TEXTILE_FALLBACK_PATH,
67 filename)
68- title = FILES_MAP[filename]
69+ title = settings.FILES_MAP[filename]
70 result[title] = cls.render_file(filepath)
71
72 if not filepaths and len(result) == 0:
73@@ -100,9 +68,9 @@
74 # If there are more of the same type then one, throw custom error as
75 # written above.
76 multiple = 0
77- filepaths = cls.dirEntries(path, True, FILES_MAP.keys())
78+ filepaths = cls.dirEntries(path, True, settings.FILES_MAP.keys())
79 if len(filepaths) > 0:
80- for filepath in FILES_MAP.keys():
81+ for filepath in settings.FILES_MAP.keys():
82 if len(cls.findall(filepaths,
83 lambda x: re.search(filepath, x))) > 1:
84 multiple += 1
85
86=== modified file 'license_protected_downloads/tests/test_render_text_files.py'
87--- license_protected_downloads/tests/test_render_text_files.py 2012-10-22 17:00:23 +0000
88+++ license_protected_downloads/tests/test_render_text_files.py 2012-10-23 09:39:09 +0000
89@@ -3,11 +3,10 @@
90 import tempfile
91 import shutil
92 import re
93+from django.conf import settings
94 from license_protected_downloads.render_text_files import RenderTextFiles
95 from license_protected_downloads.render_text_files \
96 import MultipleFilesException
97-from license_protected_downloads.render_text_files import ANDROID_FILES
98-from license_protected_downloads.render_text_files import UBUNTU_FILES
99
100
101 THIS_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
102@@ -55,19 +54,21 @@
103 RenderTextFiles.find_relevant_files(path)
104
105 def test_find_relevant_files_android(self):
106- path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES)
107+ path = self.make_temp_dir(empty=False,
108+ file_list=settings.ANDROID_FILES)
109 full_android_files = []
110- for file in ANDROID_FILES:
111+ for file in settings.ANDROID_FILES:
112 full_android_files.append(os.path.join(path, file))
113 self.assertEqual(sorted(full_android_files),
114 sorted(RenderTextFiles.find_relevant_files(path)))
115
116 def test_find_relevant_files_android_subdir(self):
117 path = self.make_temp_dir()
118- full_path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,
119+ full_path = self.make_temp_dir(empty=False,
120+ file_list=settings.ANDROID_FILES,
121 dir=path)
122 full_android_files = []
123- for file in ANDROID_FILES:
124+ for file in settings.ANDROID_FILES:
125 full_android_files.append(os.path.join(full_path, file))
126 self.assertEqual(sorted(full_android_files),
127 sorted(RenderTextFiles.find_relevant_files(path)))
128@@ -76,13 +77,15 @@
129
130 def test_find_relevant_files_android_several_subdirs(self):
131 path = self.make_temp_dir()
132- full_path1 = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,
133- dir=path)
134- full_path2 = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,
135- dir=path)
136+ full_path1 = self.make_temp_dir(empty=False,
137+ file_list=settings.ANDROID_FILES,
138+ dir=path)
139+ full_path2 = self.make_temp_dir(empty=False,
140+ file_list=settings.ANDROID_FILES,
141+ dir=path)
142 full_android_files1 = []
143 full_android_files2 = []
144- for file in ANDROID_FILES:
145+ for file in settings.ANDROID_FILES:
146 full_android_files1.append(os.path.join(full_path1, file))
147 full_android_files2.append(os.path.join(full_path2, file))
148 with self.assertRaises(MultipleFilesException):
149@@ -93,7 +96,7 @@
150 sorted(RenderTextFiles.find_relevant_files(full_path2)))
151
152 def test_find_relevant_files_android_and_ubuntu_samedir(self):
153- flist = ANDROID_FILES + UBUNTU_FILES
154+ flist = settings.ANDROID_FILES + settings.LINUX_FILES
155 path = self.make_temp_dir(empty=False, file_list=flist)
156 full_files = []
157 for file in flist:
158@@ -103,19 +106,21 @@
159
160 def test_find_relevant_files_android_and_ubuntu_different_subdirs(self):
161 path = self.make_temp_dir()
162- android_path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,
163+ android_path = self.make_temp_dir(empty=False,
164+ file_list=settings.ANDROID_FILES,
165 dir=path)
166- ubuntu_path = self.make_temp_dir(empty=False, file_list=UBUNTU_FILES,
167+ ubuntu_path = self.make_temp_dir(empty=False,
168+ file_list=settings.LINUX_FILES,
169 dir=path)
170 full_android_files = []
171- full_ubuntu_files = []
172- for file in ANDROID_FILES:
173+ full_linux_files = []
174+ for file in settings.ANDROID_FILES:
175 full_android_files.append(os.path.join(android_path, file))
176- for file in UBUNTU_FILES:
177- full_ubuntu_files.append(os.path.join(ubuntu_path, file))
178- self.assertEqual(sorted(full_android_files + full_ubuntu_files),
179+ for file in settings.LINUX_FILES:
180+ full_linux_files.append(os.path.join(ubuntu_path, file))
181+ self.assertEqual(sorted(full_android_files + full_linux_files),
182 sorted(RenderTextFiles.find_relevant_files(path)))
183 self.assertEqual(sorted(full_android_files),
184 sorted(RenderTextFiles.find_relevant_files(android_path)))
185- self.assertEqual(sorted(full_ubuntu_files),
186+ self.assertEqual(sorted(full_linux_files),
187 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))
188
189=== modified file 'scripts/publish_to_snapshots.py'
190--- scripts/publish_to_snapshots.py 2012-10-17 10:52:29 +0000
191+++ scripts/publish_to_snapshots.py 2012-10-23 09:39:09 +0000
192@@ -69,6 +69,7 @@
193 'OPEN-EULA.txt',
194 '*.EULA.txt.*',
195 'README',
196+ 'README.textile',
197 'INSTALL',
198 'HACKING',
199 '*HOWTO_*.txt',
200
201=== modified file 'settings.py'
202--- settings.py 2012-10-19 11:06:33 +0000
203+++ settings.py 2012-10-23 09:39:09 +0000
204@@ -161,3 +161,36 @@
205 'django.contrib.messages.context_processors.messages',
206 'django.contrib.auth.context_processors.auth',
207 )
208+
209+# Render TEXTILE files settings.
210+LINUX_FILES = ('README',
211+ 'INSTALL',
212+ 'HACKING',
213+ 'FIRMWARE',
214+ 'RTSM')
215+ANDROID_FILES = ('HOWTO_releasenotes.txt',
216+ 'HOWTO_install.txt',
217+ 'HOWTO_getsourceandbuild.txt',
218+ 'HOWTO_flashfirmware.txt',
219+ 'HOWTO_rtsm.txt')
220+
221+MANDATORY_ANDROID_FILES = ('HOWTO_install.txt',
222+ 'HOWTO_getsourceandbuild.txt',
223+ 'HOWTO_flashfirmware.txt')
224+
225+FILES_MAP = {'HOWTO_releasenotes.txt': 'Release Notes',
226+ 'HOWTO_install.txt': 'Binary Image Installation',
227+ 'HOWTO_getsourceandbuild.txt': 'Building From Source',
228+ 'HOWTO_flashfirmware.txt': 'Firmware Update',
229+ 'HOWTO_rtsm.txt': 'RTSM',
230+ 'README': 'Release Notes',
231+ 'INSTALL': 'Binary Image Installation',
232+ 'HACKING': 'Building From Source',
233+ 'FIRMWARE': 'Firmware Update',
234+ 'RTSM': 'RTSM'}
235+
236+TAB_PRIORITY = ['Release Notes',
237+ 'Binary Image Installation',
238+ 'Building From Source',
239+ 'Firmware Update',
240+ 'RTSM']

Subscribers

People subscribed via source and target branches