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
1=== modified file 'README'
2--- README 2012-08-17 15:05:44 +0000
3+++ README 2012-08-21 08:26:19 +0000
4@@ -154,3 +154,14 @@
5 If no BUILD-INFO.txt is found it falls back to per-file/per-directory EULA
6 protection.
7
8+Custom scripts
9+--------------
10+
11+Validation
12+..........
13+
14+The validation script only purpose is to discover and print the list of
15+directories which contain a build but do not have any kind of licensing
16+protection. Usage:
17+
18+./validation.py root_builds_dir
19
20=== added file 'scripts/validation.py'
21--- scripts/validation.py 1970-01-01 00:00:00 +0000
22+++ scripts/validation.py 2012-08-21 08:26:19 +0000
23@@ -0,0 +1,54 @@
24+#!/usr/bin/env python
25+# Print the list of build directories with no license protection.
26+
27+import sys
28+import os
29+
30+
31+class Validation():
32+
33+ LICENSE_FILE_LIST = [
34+ "EULA.txt",
35+ "OPEN-EULA.txt",
36+ "BUILD-INFO.txt",
37+ ]
38+
39+ def __init__(self):
40+ pass
41+
42+ @classmethod
43+ def find_non_protected_dirs(cls, rootdir):
44+
45+ non_handled_dirs = []
46+
47+ for root, subFolders, files in os.walk(rootdir):
48+
49+ for dir in subFolders:
50+ dir_path = os.path.join(root, dir)
51+ has_build = False
52+ for fname in os.listdir(dir_path):
53+ if os.path.isfile(os.path.join(dir_path, fname)):
54+ if "gz" in os.path.splitext(fname)[1] or \
55+ "bz2" in os.path.splitext(fname)[1]:
56+ has_build = True
57+ break
58+ if has_build:
59+ if not cls.has_license_handling(dir_path):
60+ non_handled_dirs.append(dir_path)
61+
62+ return non_handled_dirs
63+
64+ @classmethod
65+ def has_license_handling(cls, dir_path):
66+ for fname in os.listdir(dir_path):
67+ if os.path.isfile(os.path.join(dir_path, fname)):
68+ for mode in cls.LICENSE_FILE_LIST:
69+ if mode in fname:
70+ return True
71+ return False
72+
73+if __name__ == '__main__':
74+
75+ result_dirs = Validation.find_non_protected_dirs(sys.argv[1])
76+ for dir in result_dirs:
77+ print dir

Subscribers

People subscribed via source and target branches