Merge lp:~stevanr/linaro-license-protection/add-validation-script into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 108
Merged at revision: 107
Proposed branch: lp:~stevanr/linaro-license-protection/add-validation-script
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 77 lines (+65/-0)
2 files modified
README (+11/-0)
scripts/validation.py (+54/-0)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/add-validation-script
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Review via email: mp+120513@code.launchpad.net

Description of the change

Add validation script to discover non protected dirs.

To post a comment you must log in.
108. By Stevan Radaković

Fix script permissions.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2012-08-17 15:05:44 +0000
+++ README 2012-08-21 08:26:19 +0000
@@ -154,3 +154,14 @@
154If no BUILD-INFO.txt is found it falls back to per-file/per-directory EULA154If no BUILD-INFO.txt is found it falls back to per-file/per-directory EULA
155protection.155protection.
156156
157Custom scripts
158--------------
159
160Validation
161..........
162
163The validation script only purpose is to discover and print the list of
164directories which contain a build but do not have any kind of licensing
165protection. Usage:
166
167./validation.py root_builds_dir
157168
=== added file 'scripts/validation.py'
--- scripts/validation.py 1970-01-01 00:00:00 +0000
+++ scripts/validation.py 2012-08-21 08:26:19 +0000
@@ -0,0 +1,54 @@
1#!/usr/bin/env python
2# Print the list of build directories with no license protection.
3
4import sys
5import os
6
7
8class Validation():
9
10 LICENSE_FILE_LIST = [
11 "EULA.txt",
12 "OPEN-EULA.txt",
13 "BUILD-INFO.txt",
14 ]
15
16 def __init__(self):
17 pass
18
19 @classmethod
20 def find_non_protected_dirs(cls, rootdir):
21
22 non_handled_dirs = []
23
24 for root, subFolders, files in os.walk(rootdir):
25
26 for dir in subFolders:
27 dir_path = os.path.join(root, dir)
28 has_build = False
29 for fname in os.listdir(dir_path):
30 if os.path.isfile(os.path.join(dir_path, fname)):
31 if "gz" in os.path.splitext(fname)[1] or \
32 "bz2" in os.path.splitext(fname)[1]:
33 has_build = True
34 break
35 if has_build:
36 if not cls.has_license_handling(dir_path):
37 non_handled_dirs.append(dir_path)
38
39 return non_handled_dirs
40
41 @classmethod
42 def has_license_handling(cls, dir_path):
43 for fname in os.listdir(dir_path):
44 if os.path.isfile(os.path.join(dir_path, fname)):
45 for mode in cls.LICENSE_FILE_LIST:
46 if mode in fname:
47 return True
48 return False
49
50if __name__ == '__main__':
51
52 result_dirs = Validation.find_non_protected_dirs(sys.argv[1])
53 for dir in result_dirs:
54 print dir

Subscribers

People subscribed via source and target branches