gooftool: Support SMB in report_upload.
Implement report uploading with SMB protocol with "smbclient". To pass
necessary arguments, the parameter should be like:
smb://<userid>:<passwd>@<host>/<share_name>/<path>
where userid and passwd are optional. If userid is omitted, it will
upload report with guest user.
Also fix pylint error for xrange.
BUG=b:144389712
TEST=upload to my own samba server
Change-Id: If69fb0b9ec06e2867569caedd667adf6a6218ea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1928504
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
Commit-Queue: Kevin Lin <kevinptt@chromium.org>
Tested-by: Kevin Lin <kevinptt@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index 4362125..6af25a2 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -253,7 +253,7 @@
'e.g. "gooftool verify --skip_list verify_tpm clear_gbb_flags".')
_rlz_embargo_end_date_offset_cmd_arg = CmdArg(
- '--embargo_offset', type=int, default=7, choices=xrange(7, 15),
+ '--embargo_offset', type=int, default=7, choices=list(range(7, 15)),
help='Change the offset of embargo end date, cannot less than 7 days or '
'more than 14 days.')
@@ -664,7 +664,7 @@
_upload_method_cmd_arg = CmdArg(
'--upload_method', metavar='METHOD:PARAM',
help=('How to perform the upload. METHOD should be one of '
- '{ftp, shopfloor, ftps, cpfe}.'))
+ '{ftp, shopfloor, ftps, cpfe, smb}.'))
_upload_max_retry_times_arg = CmdArg(
'--upload_max_retry_times', type=int, default=0,
help='Number of tries to upload. 0 to retry infinitely.')
@@ -726,6 +726,12 @@
max_retry_times=options.upload_max_retry_times,
retry_interval=retry_interval,
allow_fail=options.upload_allow_fail)
+ elif method == 'smb':
+ # param should be in form: <dest_path>.
+ report_upload.SmbUpload(target_path, 'smb:' + param,
+ max_retry_times=options.upload_max_retry_times,
+ retry_interval=retry_interval,
+ allow_fail=options.upload_allow_fail)
else:
raise Error('unknown report upload method %r' % method)