Add "--dry-run" argument to download_image.py 78/95278/5
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Thu, 6 Oct 2016 14:14:06 +0000 (16:14 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 9 Jan 2017 18:46:14 +0000 (19:46 +0100)
Images will not be downloaded and project.conf file not created.

Change-Id: Ibb5682b8167f273cc0adb1616afce87ca55efe60
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tsp/scripts/download_image.py

index 74ac03c..52a4510 100755 (executable)
@@ -98,9 +98,10 @@ class ImageVersion(object):
 
 class ImageDownloader:
 
-    def __init__(self, url, target):
+    def __init__(self, url, target, dry):
         self.url = url
         self.target = target
+        self.dry = dry
 
         img_ver = ImageVersion(url)
         self.snap_nr = img_ver.get_snapshot()
@@ -186,6 +187,9 @@ class ImageDownloader:
         logging.debug("Package files (snapshot): %s", self.snap_pkgs)
 
     def run(self):
+        if self.dry:
+            logging.debug("Skipping: run")
+            return
         if not self.is_prerelease:
             self.write_diff_for_snapshot()
         elif self.check_diff(self.fetch_url(self.pkgs), self.fetch_url(self.snap_pkgs)):
@@ -194,6 +198,9 @@ class ImageDownloader:
         self.get(self.imgs, self.md5sums)
 
     def create_projectconf(self, arch, target_name):
+        if self.dry:
+            logging.debug("Skipping: create project.conf file for: %s %s", arch, target_name)
+            return
         logging.debug("Create project.conf file for: %s %s", arch, target_name)
         prjconf = [ "tizen-common_" + self.ver_nr, arch, target_name ]
         with open("project-" + self.target + ".conf", 'w') as f:
@@ -272,6 +279,10 @@ def parse_arguments():
             action="store", dest="target",
             help="Choose target device (odroid, minnow32, minnow64) to download images for")
 
+    parser.add_argument("-d", "--dry-run",
+            action="store_true", dest="dry",
+            help="Dry run - do not actually download images")
+
     parser.add_argument("-l", "--log",
             action="store", dest="loglevel",
             help="Verbosity level")
@@ -288,7 +299,7 @@ def main():
             raise ValueError('Invalid log level: %s' % args.loglevel)
         logging.basicConfig(format='%(asctime)s %(message)s',level=numeric_level)
     logging.debug("Begin")
-    downloader = ImageDownloader(args.url, args.target)
+    downloader = ImageDownloader(args.url, args.target, args.dry)
     downloader.run()
     logging.debug("End")