Merge lp:~gesha/linaro-license-protection/flatten-android-artifacts into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Merged at revision: 153
Proposed branch: lp:~gesha/linaro-license-protection/flatten-android-artifacts
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 97 lines (+58/-0)
2 files modified
scripts/publish_to_snapshots.py (+28/-0)
tests/test_publish_to_snapshots.py (+30/-0)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/flatten-android-artifacts
Reviewer Review Type Date Requested Status
Deepti B. Kalakeri (community) Approve
Review via email: mp+138188@code.launchpad.net

Description of the change

This branch adds support of reshuffling android artifacts. It does 'flattening' of 'target/product/<name>/*' directory, all entries from the '<name>' directory are moved to the top level directory (job id).

To post a comment you must log in.
Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

Looks good. +1.

review: Approve

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-11-29 09:36:04 +0000
+++ scripts/publish_to_snapshots.py 2012-12-05 14:36:25 +0000
@@ -12,6 +12,7 @@
12target_path = '/srv/snapshots.linaro.org/www/'12target_path = '/srv/snapshots.linaro.org/www/'
13staging_uploads_path = '/srv/staging.snapshots.linaro.org/uploads/'13staging_uploads_path = '/srv/staging.snapshots.linaro.org/uploads/'
14staging_target_path = '/srv/staging.snapshots.linaro.org/www/'14staging_target_path = '/srv/staging.snapshots.linaro.org/www/'
15product_dir_path = 'target/product'
15PASS = 016PASS = 0
16FAIL = 117FAIL = 1
17acceptable_job_types = [18acceptable_job_types = [
@@ -263,6 +264,30 @@
263 os.chdir(orig_dir)264 os.chdir(orig_dir)
264 return FAIL265 return FAIL
265266
267 def reshuffle_android_artifacts(self, src_dir):
268 dst_dir = src_dir
269 full_product_path = os.path.join(src_dir, product_dir_path)
270 if os.path.isdir(full_product_path):
271 filelist = os.listdir(full_product_path)
272 try:
273 for file in filelist:
274 src = os.path.join(full_product_path, file)
275 if os.path.isdir(src):
276 for artifact in os.listdir(src):
277 dest = os.path.join(dst_dir, artifact)
278 if os.path.exists(dest):
279 if os.path.isdir(dest):
280 continue
281 else:
282 os.remove(dest)
283 shutil.move(os.path.join(src, artifact), dest)
284 except shutil.Error:
285 print "Error while reshuffling the content"
286 try:
287 shutil.rmtree(os.path.dirname(full_product_path))
288 except shutil.Error:
289 print "Error removing empty product dir"
290
266 def move_dir_content(self, src_dir, dest_dir, sanitize=False):291 def move_dir_content(self, src_dir, dest_dir, sanitize=False):
267 filelist = os.listdir(src_dir)292 filelist = os.listdir(src_dir)
268 try:293 try:
@@ -300,6 +325,9 @@
300 if not os.path.isdir(target_dir_path):325 if not os.path.isdir(target_dir_path):
301 raise OSError326 raise OSError
302327
328 if (args.job_type == "android"):
329 self.reshuffle_android_artifacts(build_dir_path)
330
303 self.move_dir_content(build_dir_path, target_dir_path,331 self.move_dir_content(build_dir_path, target_dir_path,
304 sanitize=args.staging)332 sanitize=args.staging)
305333
306334
=== modified file 'tests/test_publish_to_snapshots.py'
--- tests/test_publish_to_snapshots.py 2012-10-10 18:59:02 +0000
+++ tests/test_publish_to_snapshots.py 2012-12-05 14:36:25 +0000
@@ -10,6 +10,7 @@
10 PublisherArgumentException,10 PublisherArgumentException,
11 SnapshotsPublisher,11 SnapshotsPublisher,
12 setup_parser,12 setup_parser,
13 product_dir_path,
13 )14 )
1415
1516
@@ -696,3 +697,32 @@
696 self.assertEqual(os.path.basename(artifact),697 self.assertEqual(os.path.basename(artifact),
697 open(moved_artifact).read())698 open(moved_artifact).read())
698 self.assertIn("Moved the files from", stdout.read())699 self.assertIn("Moved the files from", stdout.read())
700
701 def test_flatten_android_artifacts(self):
702 source_dir = tempfile.mkdtemp()
703 full_product_path = os.path.join(source_dir, product_dir_path)
704 full_board_path = os.path.join(full_product_path, 'board')
705 full_howto_path = os.path.join(full_board_path, 'howto')
706 os.makedirs(full_howto_path)
707
708 content = "file_content"
709 file_name = os.path.join(full_board_path, "artifact.txt")
710 file = open(file_name, "w")
711 file.write(content)
712 file.close()
713
714 howto_content = "howto_file_content"
715 howto_file_name = os.path.join(full_howto_path, "HOWTO_install.txt")
716 file = open(howto_file_name, "w")
717 file.write(howto_content)
718 file.close()
719
720 publisher = SnapshotsPublisher()
721 publisher.reshuffle_android_artifacts(source_dir)
722 resulting_file = os.path.join(source_dir,
723 os.path.basename(file_name))
724 resulting_howto_file = os.path.join(source_dir, 'howto',
725 os.path.basename(howto_file_name))
726 self.assertEqual(content, open(resulting_file).read())
727 self.assertEqual(howto_content, open(resulting_howto_file).read())
728 shutil.rmtree(source_dir)

Subscribers

People subscribed via source and target branches