Report: Revise report filename format on factory server.

Current report filename format is very confusing:
1. sync_factory_server uploads report with filename like
   "FA-SMT-SN123-20171205T051541Z.rpt.xz". Both "FA" and "SMT" occur at
   the same time.
2. gooftool uploads report with filename like
   "FA-20171121T010101Z_SN123.tar.xz-SN123-20171121T020202Z.rpt.xz".

This change changes the report filename format of sync_factory_server to
"SMT-SN123-20171205T051541Z.rpt.xz" and changes the report filename
format of gooftool to "GRT-gooftool-SN123-20171205T051541Z.rpt.xz".

BUG=chromium:791874
TEST=manually

Change-Id: I65ab200e38c5998c75cc41cc9a824270ad1c4ffd
Reviewed-on: https://chromium-review.googlesource.com/807341
Commit-Ready: Youcheng Syu <youcheng@chromium.org>
Tested-by: Youcheng Syu <youcheng@chromium.org>
Reviewed-by: Pi-Hsun Shih <pihsun@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index 49ea023..a4b12ac 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # Copyright 2014 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
@@ -588,8 +588,7 @@
   """
   report_archive = CreateReportArchive(*args, **kwargs)
   try:
-    with open(report_archive) as f:
-      return xmlrpclib.Binary(f.read())
+    return xmlrpclib.Binary(file_utils.ReadFile(report_archive))
   finally:
     os.unlink(report_archive)
 
@@ -668,7 +667,9 @@
     return
   method, param = options.upload_method.split(':', 1)
   if method == 'shopfloor':
-    report_upload.ShopFloorUpload(target_path, param)
+    report_upload.ShopFloorUpload(
+        target_path, param,
+        'GRT' if options.command_name == 'finalize' else None)
   elif method == 'ftp':
     report_upload.FtpUpload(target_path, 'ftp:' + param)
   elif method == 'ftps':
@@ -765,7 +766,7 @@
   db = GetGooftool(options).db
   encoded_string = options.hwid or hwid_utils.GetHWIDString()
   if options.probe_results:
-    probed_results = yaml.load(open(options.probe_results).read())
+    probed_results = yaml.load(file_utils.ReadFile(options.probe_results))
   else:
     probed_results = yaml.load(Probe(probe_vpd=True).Encode())
   vpd = hwid_utils.GetVPD(probed_results)