summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cxmanage_api/__init__.py2
-rw-r--r--cxmanage_api/firmware_package.py16
-rw-r--r--cxmanage_api/image.py12
-rw-r--r--cxmanage_api/ip_retriever.py3
-rw-r--r--cxmanage_api/node.py10
5 files changed, 23 insertions, 20 deletions
diff --git a/cxmanage_api/__init__.py b/cxmanage_api/__init__.py
index 2228b38..8c83888 100644
--- a/cxmanage_api/__init__.py
+++ b/cxmanage_api/__init__.py
@@ -36,7 +36,7 @@ import tempfile
WORK_DIR = tempfile.mkdtemp(prefix="cxmanage_api-")
-atexit.register(lambda: shutil.rmtree(WORK_DIR))
+atexit.register(lambda: shutil.rmtree(WORK_DIR, ignore_errors=True))
def temp_file():
diff --git a/cxmanage_api/firmware_package.py b/cxmanage_api/firmware_package.py
index 433b596..0ca5d04 100644
--- a/cxmanage_api/firmware_package.py
+++ b/cxmanage_api/firmware_package.py
@@ -30,6 +30,7 @@
import os
+import sys
import tarfile
import ConfigParser
import pkg_resources
@@ -78,13 +79,14 @@ class FirmwarePackage:
if "package" in config.sections():
cxmanage_ver = config.get("package",
"required_cxmanage_version")
- try:
- pkg_resources.require("cxmanage>=%s" % cxmanage_ver)
- except pkg_resources.VersionConflict:
- # @todo: CxmanageVersionError?
- raise ValueError(
- "%s requires cxmanage version %s or later."
- % (filename, cxmanage_ver))
+ if sys.platform != 'win32':
+ try:
+ pkg_resources.require("cxmanage>=%s" % cxmanage_ver)
+ except pkg_resources.VersionConflict:
+ # @todo: CxmanageVersionError?
+ raise ValueError(
+ "%s requires cxmanage version %s or later."
+ % (filename, cxmanage_ver))
if config.has_option("package", "required_socman_version"):
self.required_socman_version = config.get("package",
diff --git a/cxmanage_api/image.py b/cxmanage_api/image.py
index 87b73a0..7cbd59f 100644
--- a/cxmanage_api/image.py
+++ b/cxmanage_api/image.py
@@ -75,7 +75,7 @@ class Image:
raise ValueError("File %s does not exist" % filename)
if (simg == None):
- contents = open(filename).read()
+ contents = open(filename, "rb").read()
self.simg = has_simg(contents)
else:
self.simg = simg
@@ -104,7 +104,7 @@ class Image:
filename = self.filename
# Create new image if necessary
if (not self.simg):
- contents = open(filename).read()
+ contents = open(filename, "rb").read()
# Figure out daddr
if (self.daddr != None):
daddr = self.daddr
@@ -114,11 +114,11 @@ class Image:
skip_crc32=self.skip_crc32, align=align,
version=self.version)
filename = temp_file()
- with open(filename, "w") as f:
+ with open(filename, "wb") as f:
f.write(simg)
# Make sure the simg was built correctly
- if (not valid_simg(open(filename).read())):
+ if (not valid_simg(open(filename, "rb").read())):
raise InvalidImageError("%s is not a valid SIMG" %
os.path.basename(self.filename))
@@ -137,7 +137,7 @@ class Image:
if (self.simg):
return os.path.getsize(self.filename)
else:
- contents = open(self.filename).read()
+ contents = open(self.filename, "rb").read()
align = (self.type in ["CDB", "BOOT_LOG"])
simg = create_simg(contents, skip_crc32=True, align=align)
return len(simg)
@@ -167,7 +167,7 @@ class Image:
if (self.type in ["CDB", "BOOT_LOG"]):
# Look for "CDBH"
- contents = open(self.filename).read()
+ contents = open(self.filename, "rb").read()
if (self.simg):
contents = get_simg_contents(contents)
if (contents[:4] != "CDBH"):
diff --git a/cxmanage_api/ip_retriever.py b/cxmanage_api/ip_retriever.py
index 411465b..0bf7d5c 100644
--- a/cxmanage_api/ip_retriever.py
+++ b/cxmanage_api/ip_retriever.py
@@ -39,7 +39,8 @@ from time import sleep
from cxmanage_api.cx_exceptions import IPDiscoveryError
-from pexpect import TIMEOUT, EOF
+if sys.platform != 'win32':
+ from pexpect import TIMEOUT, EOF
from pyipmi import make_bmc
from pyipmi.server import Server
from pyipmi.bmc import LanBMC
diff --git a/cxmanage_api/node.py b/cxmanage_api/node.py
index 4d7b61e..5408555 100644
--- a/cxmanage_api/node.py
+++ b/cxmanage_api/node.py
@@ -712,14 +712,14 @@ class Node(object):
# Update running ubootenv
old_ubootenv_image = self._download_image(running_part)
old_ubootenv = self.ubootenv(open(
- old_ubootenv_image.filename).read())
+ old_ubootenv_image.filename, "rb").read())
logger.info(
"Done getting old ubootenv image"
)
try:
- ubootenv = self.ubootenv(open(image.filename).read())
+ ubootenv = self.ubootenv(open(image.filename, "rb").read())
ubootenv.set_boot_order(old_ubootenv.get_boot_order())
ubootenv.set_pxe_interface(old_ubootenv.get_pxe_interface())
@@ -728,7 +728,7 @@ class Node(object):
)
filename = temp_file()
- with open(filename, "w") as f:
+ with open(filename, "wb") as f:
f.write(ubootenv.get_contents())
ubootenv_image = self.image(filename, image.type, False,
image.daddr, image.skip_crc32,
@@ -860,7 +860,7 @@ class Node(object):
priority = max(int(x.priority, 16) for x in [first_part, active_part])
filename = temp_file()
- with open(filename, "w") as f:
+ with open(filename, "wb") as f:
f.write(ubootenv.get_contents())
ubootenv_image = self.image(filename, image.type, False, image.daddr,
@@ -1032,7 +1032,7 @@ class Node(object):
fwinfo = self.get_firmware_info()
partition = self._get_partition(fwinfo, "UBOOTENV", "ACTIVE")
image = self._download_image(partition)
- return self.ubootenv(open(image.filename).read())
+ return self.ubootenv(open(image.filename, "rb").read())
def get_fabric_ipinfo(self):
"""Gets what ip information THIS node knows about the Fabric.