factory: Replace `basestring` with `str`
`basestring` is removed in python3. We need to use `str` to do the
type checking.
BUG=chromium:999876
TEST=None
Change-Id: I08b049a77257b2f41ad53ac98ca62dcc0acd5b6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1991204
Tested-by: Yilin Yang (kerker) <kerker@chromium.org>
Commit-Queue: Yilin Yang (kerker) <kerker@chromium.org>
Reviewed-by: Yong Hong <yhong@chromium.org>
diff --git a/py/utils/pygpt.py b/py/utils/pygpt.py
index 7f1f81b..f6e75bf 100755
--- a/py/utils/pygpt.py
+++ b/py/utils/pygpt.py
@@ -330,7 +330,7 @@
fmt = self.GetStructFormat()
if source is None:
source = '\x00' * struct.calcsize(fmt)
- if not isinstance(source, basestring):
+ if not isinstance(source, str):
return self.Unpack(source.read(struct.calcsize(fmt)))
for f, value in zip(self.FIELDS, struct.unpack(fmt, source)):
setattr(self, f.name, f.Unpack(value))
@@ -573,7 +573,7 @@
Args:
image: a string as file path or a file-like object to read from.
"""
- if isinstance(image, basestring):
+ if isinstance(image, str):
with open(image, 'rb') as f:
return cls.LoadFromFile(f)
@@ -849,7 +849,7 @@
Returns:
The written PMBR structure.
"""
- if isinstance(image, basestring):
+ if isinstance(image, str):
with open(image, 'rb+') as f:
return cls.WriteProtectiveMBR(f, create, bootcode, boot_guid)
@@ -900,7 +900,7 @@
Args:
image: a string as file path or a file-like object to write into.
"""
- if isinstance(image, basestring):
+ if isinstance(image, str):
with open(image, 'rb+') as f:
return self.WriteToFile(f)
@@ -1621,7 +1621,7 @@
code = commands.Execute(args)
if isinstance(code, int):
sys.exit(code)
- elif isinstance(code, basestring):
+ elif isinstance(code, str):
print('OK: %s' % code)
except Exception as e:
if args.verbose or args.debug: