From 0cb382bdce9f6ee17fdc1d01a040c67a7d47f4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qin=20Zhang=20=EF=BC=88=E5=BC=A0=E7=90=B4=EF=BC=89?= Date: Fri, 3 Nov 2023 14:55:57 +0800 Subject: [PATCH] Misc changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Qin Zhang (张琴) --- XSConsoleData.py | 4 ++-- XSConsoleUtils.py | 2 +- simpleconfig.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/XSConsoleData.py b/XSConsoleData.py index 5d4684f..22925f7 100644 --- a/XSConsoleData.py +++ b/XSConsoleData.py @@ -65,7 +65,7 @@ def DataCache(self): def GetData(self, inNames, inDefault = None): data = self.data for name in inNames: - if name is '__repr__': + if name == '__repr__': # Error - missing () raise Exception('Data call Data.' + '.'.join(inNames[:-1]) + ' must end with ()') elif name in data: @@ -1058,7 +1058,7 @@ def IsXAPIRunning(self): pidfile = "/var/run/xapi.pid" if pidfile: # Look for any "xapi" running - pid = file(pidfile).read().strip() + pid = open(pidfile, "r").read().strip() exelink = "/proc/%s/exe" % (pid) if os.path.exists(exelink): if os.path.basename(os.readlink(exelink)) == "xapi": diff --git a/XSConsoleUtils.py b/XSConsoleUtils.py index a8e5a4d..3d412a5 100644 --- a/XSConsoleUtils.py +++ b/XSConsoleUtils.py @@ -198,7 +198,7 @@ def ValidateIP(cls, text): for i in ints: if i > 255: return False largest = max(largest, i) - if largest is 0: return False + if largest == 0: return False return True @classmethod diff --git a/simpleconfig.py b/simpleconfig.py index b122e05..a7a68ce 100644 --- a/simpleconfig.py +++ b/simpleconfig.py @@ -24,7 +24,7 @@ def uppercase_ASCII_string(str): newstr = "" for i in range(0, len(str)): - if str[i] in string.lowercase: + if str[i].islower(): newstr += chr(ord(str[i]) - 32) else: newstr += str[i]