Merge lp:~deeptik/linaro-license-protection/publish-to-snapshots into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Deepti B. Kalakeri
Status: Merged
Merged at revision: 48
Proposed branch: lp:~deeptik/linaro-license-protection/publish-to-snapshots
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 150 lines (+34/-39)
2 files modified
scripts/publish_to_snapshots.py (+24/-27)
testing/test_publish_to_snapshots.py (+10/-12)
To merge this branch: bzr merge lp:~deeptik/linaro-license-protection/publish-to-snapshots
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Review via email: mp+97841@code.launchpad.net

Description of the change

Removing the -r kernel_tree option.
Using the build number in the kernel build path.
Using the jobname to use build the target and the uploads dir path.

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

This is an improvement, but I think all of 'if args.job_type == "android":' and 'elif args.job_type == "kernel-hwpack":' should be concentrated solely in jobname_to_target_subdir().

Good to go to solve immediate needs.

review: Approve
48. By Deepti B. Kalakeri

Removing the -r kernel_tree option. Using the build number in the kernel build path

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/publish_to_snapshots.py'
2--- scripts/publish_to_snapshots.py 2012-03-14 08:00:24 +0000
3+++ scripts/publish_to_snapshots.py 2012-03-16 11:16:29 +0000
4@@ -10,8 +10,6 @@
5 parser = argparse.ArgumentParser()
6 parser.add_argument("-t", "--job-type", dest="job_type",
7 help="Specify the job type (Ex: android/kernel-hwpack)")
8-parser.add_argument("-r", "--ktree", dest="kernel_tree",
9- help="Specify the kernel tree built by the job")
10 parser.add_argument("-j", "--job-name", dest="job_name",
11 help="Specify the job name which resulted the archive to be stored.\
12 Ex: ${JOB_NAME} should be specified for andriod and for \
13@@ -33,16 +31,9 @@
14 def validate_args(self, args):
15 # Validate that all the required information
16 # is passed on the command line
17- if (args.job_type == None or args.job_name == None):
18- parser.error("\nYou must specify job-type and job-name")
19- return FAIL
20-
21- if (args.job_type == "android" and args.build_num == None):
22- parser.error("You must specify build number")
23- return FAIL
24-
25- if (args.job_type == "kernel-hwpack" and args.kernel_tree == None):
26- parser.error("You must specify kernel tree name built by the job")
27+ if (args.job_type == None or args.job_name == None or \
28+ args.build_num == None):
29+ parser.error("\nYou must specify job-type, job-name and build-num")
30 return FAIL
31
32 if (args.job_type not in acceptable_job_types):
33@@ -53,27 +44,33 @@
34 ret_val = None
35 if args.job_type == "android":
36 ret_val = jobname.split("_")
37+ elif args.job_type == "kernel-hwpack":
38+ ret_val = jobname.split('_')[0].replace(".", "_")
39 return ret_val
40
41 def validate_paths(self, args, uploads_path, target_path):
42 build_dir_path = target_dir_path = None
43- if args.job_type == "android":
44- build_path = '/'.join([args.job_type, args.job_name,
45- str(args.build_num)])
46- build_dir_path = os.path.join(uploads_path, build_path)
47- ret_val = self.jobname_to_target_subdir(args, args.job_name)
48- if ret_val != None:
49- user_name = ret_val[0]
50- job_name = '_'.join(ret_val[1:])
51- target_dir = '/'.join([args.job_type, user_name, job_name,
52+ ret_val = self.jobname_to_target_subdir(args, args.job_name)
53+ if ret_val != None:
54+ if args.job_type == "android":
55+ build_path = '/'.join([args.job_type, args.job_name,
56 str(args.build_num)])
57- target_dir_path = os.path.join(target_path, target_dir)
58- else:
59- return None, None
60+ build_dir_path = os.path.join(uploads_path, build_path)
61+ user_name = ret_val[0]
62+ job_name = '_'.join(ret_val[1:])
63+ target_dir = '/'.join([args.job_type, user_name, job_name,
64+ str(args.build_num)])
65+ target_dir_path = os.path.join(target_path, target_dir)
66+ elif args.job_type == "kernel-hwpack":
67+ kernel_tree = ret_val
68+ build_path = '/'.join([args.job_type, args.job_name,
69+ str(args.build_num)])
70+ build_dir_path = os.path.join(uploads_path, build_path)
71+ target_dir = '/'.join([args.job_type, kernel_tree,
72+ args.job_name])
73+ target_dir_path = os.path.join(target_path, target_dir)
74 else:
75- build_path = '/'.join([args.job_type, args.kernel_tree, args.job_name])
76- build_dir_path = os.path.join(uploads_path, build_path)
77- target_dir_path = os.path.join(target_path, build_path)
78+ return None, None
79
80 if not (os.path.isdir(uploads_path) or os.path.isdir(build_dir_path)):
81 build_paths = "'%s' or '%s'" % (uploads_path, build_dir_path)
82
83=== modified file 'testing/test_publish_to_snapshots.py'
84--- testing/test_publish_to_snapshots.py 2012-03-14 08:00:24 +0000
85+++ testing/test_publish_to_snapshots.py 2012-03-16 11:16:29 +0000
86@@ -18,7 +18,6 @@
87 def setUp(self):
88 self.parser = argparse.ArgumentParser()
89 self.parser.add_argument("-t", "--job-type", dest="job_type")
90- self.parser.add_argument("-r", "--ktree", dest="kernel_tree")
91 self.parser.add_argument("-j", "--job-name", dest="job_name")
92 self.parser.add_argument("-n", "--build-num", dest="build_num", type=int)
93 if not os.path.isdir(self.uploads_path):
94@@ -38,10 +37,11 @@
95
96 def test_validate_args_valid_job_values(self):
97 self.publisher = SnapshotsPublisher()
98- param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
99+ param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name',
100+ '-n', '1'])
101 self.publisher.validate_args(param)
102- param = self.parser.parse_args(['-t', 'kernel-hwpack', '-r', 'dummy_tree',
103- '-j', 'dummy_job_name'])
104+ param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name',
105+ '-n', '1'])
106 self.publisher.validate_args(param)
107
108 def test_validate_args_invalid_job_type(self):
109@@ -94,15 +94,14 @@
110 stderr = sys.stderr = StringIO()
111 self.publisher = SnapshotsPublisher()
112 try:
113- param = self.parser.parse_args(['-t', None , '-r', None,
114- '-j', None , '-n' , 0])
115+ param = self.parser.parse_args(['-t', None , '-j', None , '-n' , 0])
116 self.publisher.validate_args(param)
117 except SystemExit, err:
118 self.assertEqual(err.code, 2, "None values are not acceptable")
119 finally:
120 sys.stderr = orig_stderr
121 stderr.seek(0)
122- self.assertIn("You must specify job-type and job-name",
123+ self.assertIn("You must specify job-type, job-name and build-num",
124 stderr.read())
125
126 def test_validate_paths_invalid_uploads_path(self):
127@@ -131,8 +130,7 @@
128 self.publisher.validate_args(param)
129 self.target_path = "./dummy_target_path"
130 try:
131- self.publisher.validate_paths(param, self.uploads_path,
132- self.target_path)
133+ self.publisher.validate_paths(param, self.uploads_path, self.target_path)
134 finally:
135 sys.stdout = orig_stdout
136 stdout.seek(0)
137@@ -143,10 +141,10 @@
138 stdout = sys.stdout = StringIO()
139 self.publisher = SnapshotsPublisher()
140 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name',
141- '-r', 'dummy_kernel_tree'])
142+ '-n', '1'])
143 self.publisher.validate_args(param)
144- build_path = os.path.join(self.uploads_path, param.job_type, param.kernel_tree,
145- param.job_name)
146+ build_path = os.path.join(self.uploads_path, param.job_type, param.job_name,
147+ str(param.build_num))
148 os.makedirs(build_path)
149 tempfiles = tempfile.mkstemp(dir=build_path)
150 try:

Subscribers

People subscribed via source and target branches