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
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2012-03-14 08:00:24 +0000
+++ scripts/publish_to_snapshots.py 2012-03-16 11:16:29 +0000
@@ -10,8 +10,6 @@
10parser = argparse.ArgumentParser()10parser = argparse.ArgumentParser()
11parser.add_argument("-t", "--job-type", dest="job_type",11parser.add_argument("-t", "--job-type", dest="job_type",
12 help="Specify the job type (Ex: android/kernel-hwpack)")12 help="Specify the job type (Ex: android/kernel-hwpack)")
13parser.add_argument("-r", "--ktree", dest="kernel_tree",
14 help="Specify the kernel tree built by the job")
15parser.add_argument("-j", "--job-name", dest="job_name",13parser.add_argument("-j", "--job-name", dest="job_name",
16 help="Specify the job name which resulted the archive to be stored.\14 help="Specify the job name which resulted the archive to be stored.\
17 Ex: ${JOB_NAME} should be specified for andriod and for \15 Ex: ${JOB_NAME} should be specified for andriod and for \
@@ -33,16 +31,9 @@
33 def validate_args(self, args):31 def validate_args(self, args):
34 # Validate that all the required information 32 # Validate that all the required information
35 # is passed on the command line33 # is passed on the command line
36 if (args.job_type == None or args.job_name == None): 34 if (args.job_type == None or args.job_name == None or \
37 parser.error("\nYou must specify job-type and job-name")35 args.build_num == None):
38 return FAIL36 parser.error("\nYou must specify job-type, job-name and build-num")
39
40 if (args.job_type == "android" and args.build_num == None):
41 parser.error("You must specify build number")
42 return FAIL
43
44 if (args.job_type == "kernel-hwpack" and args.kernel_tree == None):
45 parser.error("You must specify kernel tree name built by the job")
46 return FAIL37 return FAIL
4738
48 if (args.job_type not in acceptable_job_types):39 if (args.job_type not in acceptable_job_types):
@@ -53,27 +44,33 @@
53 ret_val = None44 ret_val = None
54 if args.job_type == "android":45 if args.job_type == "android":
55 ret_val = jobname.split("_") 46 ret_val = jobname.split("_")
47 elif args.job_type == "kernel-hwpack":
48 ret_val = jobname.split('_')[0].replace(".", "_")
56 return ret_val 49 return ret_val
5750
58 def validate_paths(self, args, uploads_path, target_path):51 def validate_paths(self, args, uploads_path, target_path):
59 build_dir_path = target_dir_path = None52 build_dir_path = target_dir_path = None
60 if args.job_type == "android":53 ret_val = self.jobname_to_target_subdir(args, args.job_name)
61 build_path = '/'.join([args.job_type, args.job_name,54 if ret_val != None:
62 str(args.build_num)])55 if args.job_type == "android":
63 build_dir_path = os.path.join(uploads_path, build_path) 56 build_path = '/'.join([args.job_type, args.job_name,
64 ret_val = self.jobname_to_target_subdir(args, args.job_name)
65 if ret_val != None:
66 user_name = ret_val[0]
67 job_name = '_'.join(ret_val[1:])
68 target_dir = '/'.join([args.job_type, user_name, job_name,
69 str(args.build_num)])57 str(args.build_num)])
70 target_dir_path = os.path.join(target_path, target_dir)58 build_dir_path = os.path.join(uploads_path, build_path)
71 else:59 user_name = ret_val[0]
72 return None, None60 job_name = '_'.join(ret_val[1:])
61 target_dir = '/'.join([args.job_type, user_name, job_name,
62 str(args.build_num)])
63 target_dir_path = os.path.join(target_path, target_dir)
64 elif args.job_type == "kernel-hwpack":
65 kernel_tree = ret_val
66 build_path = '/'.join([args.job_type, args.job_name,
67 str(args.build_num)])
68 build_dir_path = os.path.join(uploads_path, build_path)
69 target_dir = '/'.join([args.job_type, kernel_tree,
70 args.job_name])
71 target_dir_path = os.path.join(target_path, target_dir)
73 else:72 else:
74 build_path = '/'.join([args.job_type, args.kernel_tree, args.job_name])73 return None, None
75 build_dir_path = os.path.join(uploads_path, build_path)
76 target_dir_path = os.path.join(target_path, build_path)
7774
78 if not (os.path.isdir(uploads_path) or os.path.isdir(build_dir_path)):75 if not (os.path.isdir(uploads_path) or os.path.isdir(build_dir_path)):
79 build_paths = "'%s' or '%s'" % (uploads_path, build_dir_path)76 build_paths = "'%s' or '%s'" % (uploads_path, build_dir_path)
8077
=== modified file 'testing/test_publish_to_snapshots.py'
--- testing/test_publish_to_snapshots.py 2012-03-14 08:00:24 +0000
+++ testing/test_publish_to_snapshots.py 2012-03-16 11:16:29 +0000
@@ -18,7 +18,6 @@
18 def setUp(self):18 def setUp(self):
19 self.parser = argparse.ArgumentParser()19 self.parser = argparse.ArgumentParser()
20 self.parser.add_argument("-t", "--job-type", dest="job_type")20 self.parser.add_argument("-t", "--job-type", dest="job_type")
21 self.parser.add_argument("-r", "--ktree", dest="kernel_tree")
22 self.parser.add_argument("-j", "--job-name", dest="job_name")21 self.parser.add_argument("-j", "--job-name", dest="job_name")
23 self.parser.add_argument("-n", "--build-num", dest="build_num", type=int)22 self.parser.add_argument("-n", "--build-num", dest="build_num", type=int)
24 if not os.path.isdir(self.uploads_path):23 if not os.path.isdir(self.uploads_path):
@@ -38,10 +37,11 @@
3837
39 def test_validate_args_valid_job_values(self):38 def test_validate_args_valid_job_values(self):
40 self.publisher = SnapshotsPublisher()39 self.publisher = SnapshotsPublisher()
41 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])40 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name',
41 '-n', '1'])
42 self.publisher.validate_args(param)42 self.publisher.validate_args(param)
43 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-r', 'dummy_tree', 43 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name',
44 '-j', 'dummy_job_name'])44 '-n', '1'])
45 self.publisher.validate_args(param)45 self.publisher.validate_args(param)
4646
47 def test_validate_args_invalid_job_type(self):47 def test_validate_args_invalid_job_type(self):
@@ -94,15 +94,14 @@
94 stderr = sys.stderr = StringIO()94 stderr = sys.stderr = StringIO()
95 self.publisher = SnapshotsPublisher()95 self.publisher = SnapshotsPublisher()
96 try:96 try:
97 param = self.parser.parse_args(['-t', None , '-r', None, 97 param = self.parser.parse_args(['-t', None , '-j', None , '-n' , 0])
98 '-j', None , '-n' , 0])
99 self.publisher.validate_args(param)98 self.publisher.validate_args(param)
100 except SystemExit, err:99 except SystemExit, err:
101 self.assertEqual(err.code, 2, "None values are not acceptable")100 self.assertEqual(err.code, 2, "None values are not acceptable")
102 finally:101 finally:
103 sys.stderr = orig_stderr102 sys.stderr = orig_stderr
104 stderr.seek(0)103 stderr.seek(0)
105 self.assertIn("You must specify job-type and job-name", 104 self.assertIn("You must specify job-type, job-name and build-num",
106 stderr.read())105 stderr.read())
107106
108 def test_validate_paths_invalid_uploads_path(self):107 def test_validate_paths_invalid_uploads_path(self):
@@ -131,8 +130,7 @@
131 self.publisher.validate_args(param)130 self.publisher.validate_args(param)
132 self.target_path = "./dummy_target_path"131 self.target_path = "./dummy_target_path"
133 try:132 try:
134 self.publisher.validate_paths(param, self.uploads_path, 133 self.publisher.validate_paths(param, self.uploads_path, self.target_path)
135 self.target_path)
136 finally:134 finally:
137 sys.stdout = orig_stdout135 sys.stdout = orig_stdout
138 stdout.seek(0)136 stdout.seek(0)
@@ -143,10 +141,10 @@
143 stdout = sys.stdout = StringIO()141 stdout = sys.stdout = StringIO()
144 self.publisher = SnapshotsPublisher()142 self.publisher = SnapshotsPublisher()
145 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name', 143 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name',
146 '-r', 'dummy_kernel_tree'])144 '-n', '1'])
147 self.publisher.validate_args(param)145 self.publisher.validate_args(param)
148 build_path = os.path.join(self.uploads_path, param.job_type, param.kernel_tree, 146 build_path = os.path.join(self.uploads_path, param.job_type, param.job_name,
149 param.job_name)147 str(param.build_num))
150 os.makedirs(build_path)148 os.makedirs(build_path)
151 tempfiles = tempfile.mkstemp(dir=build_path)149 tempfiles = tempfile.mkstemp(dir=build_path)
152 try:150 try:

Subscribers

People subscribed via source and target branches