tauto: specifying the mode of temp_file

In Python 3, files should be explicitly opened as text mode for dumping
text files.  This CL sets the mode of tempfile.NamedTemporaryFile to 'w'
instead of the default value 'w+b' in order to perform text processing.

BUG=b:223547658
TEST=test_that -b "${BOARD}" "${ACTIVE_DUT}" tast.runtime-probe

Change-Id: I3b2d9150c20d0fa91993283fa2e100201906c975
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3521173
Reviewed-by: Seewai Fu <seewaifu@google.com>
Tested-by: Clark Chung <ckclark@chromium.org>
Auto-Submit: Clark Chung <ckclark@chromium.org>
Reviewed-by: Yong Hong <yhong@chromium.org>
Commit-Queue: Clark Chung <ckclark@chromium.org>
diff --git a/server/site_tests/tast/control.runtime-probe b/server/site_tests/tast/control.runtime-probe
index 341f867..c87c0a7 100644
--- a/server/site_tests/tast/control.runtime-probe
+++ b/server/site_tests/tast/control.runtime-probe
@@ -27,10 +27,11 @@
 
 def run(machine):
     host = hosts.create_host(machine)
-    with tempfile.NamedTemporaryFile(suffix='.yaml') as temp_file:
+    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as temp_file:
         host_info = host.host_info_store.get()
-        yaml.dump({"autotest_host_info_labels": json.dumps(host_info.labels)},
-                  stream=temp_file)
+        yaml.safe_dump({'autotest_host_info_labels':
+                        json.dumps(host_info.labels)}, stream=temp_file)
+        temp_file.flush()
         job.run_test('tast',
                      host=host,
                      test_exprs=['("group:runtime_probe")'],