From ce19aa8034e44dec2d1fd44f1c5626819fce4b77 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 25 Feb 2021 12:21:47 -0500 Subject: [PATCH] Support updating from a file-like object If passed a file-like object, be sure to use that instead of trying to open filename directly. Change-Id: I9ac28dc77aa5297ddf81d49cbd9d6cc2c07e74e6 --- pyghmi/ipmi/oem/lenovo/nextscale.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index 83b37b38..ab317edd 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -704,8 +704,13 @@ class SMMClient(object): def update_firmware(self, filename, data=None, progress=None, bank=None): if progress is None: progress = lambda x: True - if not data and zipfile.is_zipfile(filename): + z = None + if data and hasattr(data, 'read'): + if zipfile.is_zipfile(data): + z = zipfile.ZipFile(data) + elif data is None and zipfile.is_zipfile(filename): z = zipfile.ZipFile(filename) + if z: for tmpname in z.namelist(): if tmpname.endswith('.rom'): filename = tmpname