[autotest] Fix issue where gs_offloader crashed

gs_offloader can at times try to seek from a file object that is
null, avoid that scenario.

TEST=ran on local moblab

Change-Id: Ib4daa3d1a3f645522c9e57e046db2b79ffc39103
Reviewed-on: https://chromium-review.googlesource.com/606972
Reviewed-by: Keith Haddow <haddowk@chromium.org>
Reviewed-by: Michael Tang <ntang@chromium.org>
Commit-Queue: Keith Haddow <haddowk@chromium.org>
Tested-by: Keith Haddow <haddowk@chromium.org>
Trybot-Ready: Keith Haddow <haddowk@chromium.org>
diff --git a/site_utils/gs_offloader.py b/site_utils/gs_offloader.py
index fd2ecbd..1cc547e 100755
--- a/site_utils/gs_offloader.py
+++ b/site_utils/gs_offloader.py
@@ -666,12 +666,15 @@
                 # Rewind the log files for stdout and stderr and log
                 # their contents.
-                stdout_file.seek(0)
-                stderr_file.seek(0)
-                stderr_content = stderr_file.read()
+                if stdout_file:
+                    stdout_file.seek(0)
+                if stderr_file:
+                    stderr_file.seek(0)
+                    stderr_content = stderr_file.read()
                 logging.warning('Error occurred when offloading %s:', dir_entry)
-                logging.warning('Stdout:\n%s \nStderr:\n%s', stdout_file.read(),
-                                stderr_content)
+                if stdout_file and stderr_file:
+                    logging.warning('Stdout:\n%s \nStderr:\n%s',
+                                    stdout_file.read(), stderr_content)
                 # Some result files may have wrong file permission. Try
                 # to correct such error so later try can success.