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
=== modified file 'license_protected_downloads/render_text_files.py'
--- license_protected_downloads/render_text_files.py 2012-10-22 17:00:23 +0000
+++ license_protected_downloads/render_text_files.py 2012-10-23 09:39:09 +0000
@@ -4,38 +4,6 @@
4from collections import OrderedDict4from collections import OrderedDict
5from django.conf import settings5from django.conf import settings
66
7UBUNTU_FILES = ('README',
8 'INSTALL',
9 'HACKING',
10 'FIRMWARE',
11 'RTSM')
12ANDROID_FILES = ('HOWTO_releasenotes.txt',
13 'HOWTO_install.txt',
14 'HOWTO_getsourceandbuild.txt',
15 'HOWTO_flashfirmware.txt',
16 'HOWTO_rtsm.txt')
17
18MANDATORY_ANDROID_FILES = ('HOWTO_install.txt',
19 'HOWTO_getsourceandbuild.txt',
20 'HOWTO_flashfirmware.txt')
21
22FILES_MAP = {'HOWTO_releasenotes.txt': 'Release Notes',
23 'HOWTO_install.txt': 'Binary Image Installation',
24 'HOWTO_getsourceandbuild.txt': 'Building From Source',
25 'HOWTO_flashfirmware.txt': 'Firmware Update',
26 'HOWTO_rtsm.txt': 'RTSM',
27 'README': 'Release Notes',
28 'INSTALL': 'Binary Image Installation',
29 'HACKING': 'Building From Source',
30 'FIRMWARE': 'Firmware Update',
31 'RTSM': 'RTSM'}
32
33TAB_PRIORITY = ['Release Notes',
34 'Binary Image Installation',
35 'Building From Source',
36 'Firmware Update',
37 'RTSM']
38
397
40class MultipleFilesException(Exception):8class MultipleFilesException(Exception):
41 pass9 pass
@@ -48,7 +16,7 @@
4816
49 @classmethod17 @classmethod
50 def sort_tabs_by_priority(cls, a, b):18 def sort_tabs_by_priority(cls, a, b):
51 base_list = TAB_PRIORITY19 base_list = settings.TAB_PRIORITY
52 return base_list.index(a[0]) - base_list.index(b[0])20 return base_list.index(a[0]) - base_list.index(b[0])
5321
54 @classmethod22 @classmethod
@@ -64,16 +32,16 @@
6432
65 if filepaths:33 if filepaths:
66 for filepath in filepaths:34 for filepath in filepaths:
67 title = FILES_MAP[os.path.basename(filepath)]35 title = settings.FILES_MAP[os.path.basename(filepath)]
68 result[title] = cls.render_file(filepath)36 result[title] = cls.render_file(filepath)
6937
70 # Switch to fallback data for mandatory files.38 # Switch to fallback data for mandatory files.
71 if cls.check_for_manifest_or_tarballs(path):39 if cls.check_for_manifest_or_tarballs(path):
72 for filename in MANDATORY_ANDROID_FILES:40 for filename in settings.MANDATORY_ANDROID_FILES:
73 if FILES_MAP[filename] not in result:41 if settings.FILES_MAP[filename] not in result:
74 filepath = os.path.join(settings.TEXTILE_FALLBACK_PATH,42 filepath = os.path.join(settings.TEXTILE_FALLBACK_PATH,
75 filename)43 filename)
76 title = FILES_MAP[filename]44 title = settings.FILES_MAP[filename]
77 result[title] = cls.render_file(filepath)45 result[title] = cls.render_file(filepath)
7846
79 if not filepaths and len(result) == 0:47 if not filepaths and len(result) == 0:
@@ -100,9 +68,9 @@
100 # If there are more of the same type then one, throw custom error as68 # If there are more of the same type then one, throw custom error as
101 # written above.69 # written above.
102 multiple = 070 multiple = 0
103 filepaths = cls.dirEntries(path, True, FILES_MAP.keys())71 filepaths = cls.dirEntries(path, True, settings.FILES_MAP.keys())
104 if len(filepaths) > 0:72 if len(filepaths) > 0:
105 for filepath in FILES_MAP.keys():73 for filepath in settings.FILES_MAP.keys():
106 if len(cls.findall(filepaths,74 if len(cls.findall(filepaths,
107 lambda x: re.search(filepath, x))) > 1:75 lambda x: re.search(filepath, x))) > 1:
108 multiple += 176 multiple += 1
10977
=== modified file 'license_protected_downloads/tests/test_render_text_files.py'
--- license_protected_downloads/tests/test_render_text_files.py 2012-10-22 17:00:23 +0000
+++ license_protected_downloads/tests/test_render_text_files.py 2012-10-23 09:39:09 +0000
@@ -3,11 +3,10 @@
3import tempfile3import tempfile
4import shutil4import shutil
5import re5import re
6from django.conf import settings
6from license_protected_downloads.render_text_files import RenderTextFiles7from license_protected_downloads.render_text_files import RenderTextFiles
7from license_protected_downloads.render_text_files \8from license_protected_downloads.render_text_files \
8 import MultipleFilesException9 import MultipleFilesException
9from license_protected_downloads.render_text_files import ANDROID_FILES
10from license_protected_downloads.render_text_files import UBUNTU_FILES
1110
1211
13THIS_DIRECTORY = os.path.dirname(os.path.abspath(__file__))12THIS_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
@@ -55,19 +54,21 @@
55 RenderTextFiles.find_relevant_files(path)54 RenderTextFiles.find_relevant_files(path)
5655
57 def test_find_relevant_files_android(self):56 def test_find_relevant_files_android(self):
58 path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES)57 path = self.make_temp_dir(empty=False,
58 file_list=settings.ANDROID_FILES)
59 full_android_files = []59 full_android_files = []
60 for file in ANDROID_FILES:60 for file in settings.ANDROID_FILES:
61 full_android_files.append(os.path.join(path, file))61 full_android_files.append(os.path.join(path, file))
62 self.assertEqual(sorted(full_android_files),62 self.assertEqual(sorted(full_android_files),
63 sorted(RenderTextFiles.find_relevant_files(path)))63 sorted(RenderTextFiles.find_relevant_files(path)))
6464
65 def test_find_relevant_files_android_subdir(self):65 def test_find_relevant_files_android_subdir(self):
66 path = self.make_temp_dir()66 path = self.make_temp_dir()
67 full_path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,67 full_path = self.make_temp_dir(empty=False,
68 file_list=settings.ANDROID_FILES,
68 dir=path)69 dir=path)
69 full_android_files = []70 full_android_files = []
70 for file in ANDROID_FILES:71 for file in settings.ANDROID_FILES:
71 full_android_files.append(os.path.join(full_path, file))72 full_android_files.append(os.path.join(full_path, file))
72 self.assertEqual(sorted(full_android_files),73 self.assertEqual(sorted(full_android_files),
73 sorted(RenderTextFiles.find_relevant_files(path)))74 sorted(RenderTextFiles.find_relevant_files(path)))
@@ -76,13 +77,15 @@
7677
77 def test_find_relevant_files_android_several_subdirs(self):78 def test_find_relevant_files_android_several_subdirs(self):
78 path = self.make_temp_dir()79 path = self.make_temp_dir()
79 full_path1 = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,80 full_path1 = self.make_temp_dir(empty=False,
80 dir=path)81 file_list=settings.ANDROID_FILES,
81 full_path2 = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,82 dir=path)
82 dir=path)83 full_path2 = self.make_temp_dir(empty=False,
84 file_list=settings.ANDROID_FILES,
85 dir=path)
83 full_android_files1 = []86 full_android_files1 = []
84 full_android_files2 = []87 full_android_files2 = []
85 for file in ANDROID_FILES:88 for file in settings.ANDROID_FILES:
86 full_android_files1.append(os.path.join(full_path1, file))89 full_android_files1.append(os.path.join(full_path1, file))
87 full_android_files2.append(os.path.join(full_path2, file))90 full_android_files2.append(os.path.join(full_path2, file))
88 with self.assertRaises(MultipleFilesException):91 with self.assertRaises(MultipleFilesException):
@@ -93,7 +96,7 @@
93 sorted(RenderTextFiles.find_relevant_files(full_path2)))96 sorted(RenderTextFiles.find_relevant_files(full_path2)))
9497
95 def test_find_relevant_files_android_and_ubuntu_samedir(self):98 def test_find_relevant_files_android_and_ubuntu_samedir(self):
96 flist = ANDROID_FILES + UBUNTU_FILES99 flist = settings.ANDROID_FILES + settings.LINUX_FILES
97 path = self.make_temp_dir(empty=False, file_list=flist)100 path = self.make_temp_dir(empty=False, file_list=flist)
98 full_files = []101 full_files = []
99 for file in flist:102 for file in flist:
@@ -103,19 +106,21 @@
103106
104 def test_find_relevant_files_android_and_ubuntu_different_subdirs(self):107 def test_find_relevant_files_android_and_ubuntu_different_subdirs(self):
105 path = self.make_temp_dir()108 path = self.make_temp_dir()
106 android_path = self.make_temp_dir(empty=False, file_list=ANDROID_FILES,109 android_path = self.make_temp_dir(empty=False,
110 file_list=settings.ANDROID_FILES,
107 dir=path)111 dir=path)
108 ubuntu_path = self.make_temp_dir(empty=False, file_list=UBUNTU_FILES,112 ubuntu_path = self.make_temp_dir(empty=False,
113 file_list=settings.LINUX_FILES,
109 dir=path)114 dir=path)
110 full_android_files = []115 full_android_files = []
111 full_ubuntu_files = []116 full_linux_files = []
112 for file in ANDROID_FILES:117 for file in settings.ANDROID_FILES:
113 full_android_files.append(os.path.join(android_path, file))118 full_android_files.append(os.path.join(android_path, file))
114 for file in UBUNTU_FILES:119 for file in settings.LINUX_FILES:
115 full_ubuntu_files.append(os.path.join(ubuntu_path, file))120 full_linux_files.append(os.path.join(ubuntu_path, file))
116 self.assertEqual(sorted(full_android_files + full_ubuntu_files),121 self.assertEqual(sorted(full_android_files + full_linux_files),
117 sorted(RenderTextFiles.find_relevant_files(path)))122 sorted(RenderTextFiles.find_relevant_files(path)))
118 self.assertEqual(sorted(full_android_files),123 self.assertEqual(sorted(full_android_files),
119 sorted(RenderTextFiles.find_relevant_files(android_path)))124 sorted(RenderTextFiles.find_relevant_files(android_path)))
120 self.assertEqual(sorted(full_ubuntu_files),125 self.assertEqual(sorted(full_linux_files),
121 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))126 sorted(RenderTextFiles.find_relevant_files(ubuntu_path)))
122127
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2012-10-17 10:52:29 +0000
+++ scripts/publish_to_snapshots.py 2012-10-23 09:39:09 +0000
@@ -69,6 +69,7 @@
69 'OPEN-EULA.txt',69 'OPEN-EULA.txt',
70 '*.EULA.txt.*',70 '*.EULA.txt.*',
71 'README',71 'README',
72 'README.textile',
72 'INSTALL',73 'INSTALL',
73 'HACKING',74 'HACKING',
74 '*HOWTO_*.txt',75 '*HOWTO_*.txt',
7576
=== modified file 'settings.py'
--- settings.py 2012-10-19 11:06:33 +0000
+++ settings.py 2012-10-23 09:39:09 +0000
@@ -161,3 +161,36 @@
161 'django.contrib.messages.context_processors.messages',161 'django.contrib.messages.context_processors.messages',
162 'django.contrib.auth.context_processors.auth',162 'django.contrib.auth.context_processors.auth',
163)163)
164
165# Render TEXTILE files settings.
166LINUX_FILES = ('README',
167 'INSTALL',
168 'HACKING',
169 'FIRMWARE',
170 'RTSM')
171ANDROID_FILES = ('HOWTO_releasenotes.txt',
172 'HOWTO_install.txt',
173 'HOWTO_getsourceandbuild.txt',
174 'HOWTO_flashfirmware.txt',
175 'HOWTO_rtsm.txt')
176
177MANDATORY_ANDROID_FILES = ('HOWTO_install.txt',
178 'HOWTO_getsourceandbuild.txt',
179 'HOWTO_flashfirmware.txt')
180
181FILES_MAP = {'HOWTO_releasenotes.txt': 'Release Notes',
182 'HOWTO_install.txt': 'Binary Image Installation',
183 'HOWTO_getsourceandbuild.txt': 'Building From Source',
184 'HOWTO_flashfirmware.txt': 'Firmware Update',
185 'HOWTO_rtsm.txt': 'RTSM',
186 'README': 'Release Notes',
187 'INSTALL': 'Binary Image Installation',
188 'HACKING': 'Building From Source',
189 'FIRMWARE': 'Firmware Update',
190 'RTSM': 'RTSM'}
191
192TAB_PRIORITY = ['Release Notes',
193 'Binary Image Installation',
194 'Building From Source',
195 'Firmware Update',
196 'RTSM']

Subscribers

People subscribed via source and target branches