Fix `IOError: [Errno 2] No such file or directory` when sync diff
authorLingchaox Xin <lingchaox.xin@intel.com>
Mon, 10 Feb 2014 09:23:23 +0000 (17:23 +0800)
committerLin A Yang <lin.a.yang@intel.com>
Fri, 14 Feb 2014 08:39:03 +0000 (10:39 +0200)
Change-Id: I1c128842679e7c6f220103dc929055fb8210a8bc

job_sync_snapdiff.py

index 7747997..5f5cf1b 100755 (executable)
@@ -104,7 +104,10 @@ def sync_world(template_name, repo_path, **kwargs):
     template = env.get_template(template_name)
     content = template.render(kwargs)
     sync_out = os.path.join(os.getenv('WORKSPACE'), 'outdir')
-    with open(os.path.join(sync_out, 'builddata', 'reports', 'index.html'), 'w') as fp:
+    reports = os.path.join(sync_out, 'builddata', 'reports')
+    if not os.path.exists(reports):
+        return
+    with open(os.path.join(reports, 'index.html'), 'w') as fp:
         fp.write(content)
     sync(sync_out, os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), repo_path))