]> code.ossystems Code Review - openembedded-core.git/commitdiff
resulttool: Allow store to work on single files
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 2 Apr 2019 22:51:02 +0000 (23:51 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 4 Apr 2019 21:57:00 +0000 (22:57 +0100)
Store operations using a single file as a source weren't working as the os.walk
command didn't like being given a single file. Fix the store operation to
work for single files.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/resulttool/store.py

index 5e33716c3dcf2b227e7aceaddcbdaa4fa2fa4fbc..3a81933242b4351cbfd38cc04a86dd41abb36e23 100644 (file)
@@ -29,15 +29,18 @@ def store(args, logger):
     try:
         results = {}
         logger.info('Reading files from %s' % args.source)
-        for root, dirs,  files in os.walk(args.source):
-            for name in files:
-                f = os.path.join(root, name)
-                if name == "testresults.json":
-                    resultutils.append_resultsdata(results, f)
-                elif args.all:
-                    dst = f.replace(args.source, tempdir + "/")
-                    os.makedirs(os.path.dirname(dst), exist_ok=True)
-                    shutil.copyfile(f, dst)
+        if os.path.isfile(args.source):
+            resultutils.append_resultsdata(results, args.source)
+        else:
+            for root, dirs,  files in os.walk(args.source):
+                for name in files:
+                    f = os.path.join(root, name)
+                    if name == "testresults.json":
+                        resultutils.append_resultsdata(results, f)
+                    elif args.all:
+                        dst = f.replace(args.source, tempdir + "/")
+                        os.makedirs(os.path.dirname(dst), exist_ok=True)
+                        shutil.copyfile(f, dst)
 
         revisions = {}