From 03a68da0291678acf7abc87742d264d20011a4da Mon Sep 17 00:00:00 2001 From: kelvin Date: Tue, 19 Dec 2023 15:50:36 +0800 Subject: fix syntaxwarning error --- lib/sunhpc/commands/create/distro/__init__.py | 2 +- lib/sunhpc/commands/pxelinux/build/__init__.py | 4 ++-- lib/sunhpc/core/build.py | 2 +- lib/sunhpc/core/files.py | 6 +++--- lib/sunhpc/core/security.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/sunhpc/commands/create/distro/__init__.py b/lib/sunhpc/commands/create/distro/__init__.py index 0c3569e..8581793 100644 --- a/lib/sunhpc/commands/create/distro/__init__.py +++ b/lib/sunhpc/commands/create/distro/__init__.py @@ -133,7 +133,7 @@ class Command(sunhpc.commands.create.command): mirrors = distro.getMirrors() fullmirror = mirrors[0].getRollsPath() # modify all dirs mode 755 - os.system('find %s -type d ' % (fullmirror) + '-exec chmod -R 0755 {} \;') + os.system(r'find %s -type d ' % (fullmirror) + '-exec chmod -R 0755 {} \;') if self.arch != arch and os.path.exists(dist): shutil.move(os.path.join(tempdist, arch), os.path.join(dist, arch)) diff --git a/lib/sunhpc/commands/pxelinux/build/__init__.py b/lib/sunhpc/commands/pxelinux/build/__init__.py index 3a0e357..39ab37e 100644 --- a/lib/sunhpc/commands/pxelinux/build/__init__.py +++ b/lib/sunhpc/commands/pxelinux/build/__init__.py @@ -27,7 +27,7 @@ class RollHandler(object): subprocess.run('umount %s' % self.mntdir, shell=True) def read_iso(self): - cmd = 'find %s -type f -name roll-\*.xml' % self.mntdir + cmd = r'find %s -type f -name roll-\*.xml' % self.mntdir ret = self.cmd.shcmd(cmd, code=True) try: roll = sunhpc.core.files.RollInfoFile(ret['o'].strip()) @@ -104,7 +104,7 @@ class RollHandler(object): os.chdir(os.path.join(self.mntdir, roll_name)) # 修改所有目录权限,确保所有人能够访问,例如Apache等. - self.cmd.shcmd("find %s -type d -exec chmod a+rx {} \;" % roll_dir, code=True) + self.cmd.shcmd(r"find %s -type d -exec chmod a+rx {} \;" % roll_dir, code=True) # 插入roll信息到数据库,如果存在则放弃插入. rows = self.cmd.db.search('select * from rolls where' \ diff --git a/lib/sunhpc/core/build.py b/lib/sunhpc/core/build.py index 13514cc..9a4ffce 100644 --- a/lib/sunhpc/core/build.py +++ b/lib/sunhpc/core/build.py @@ -400,7 +400,7 @@ class DistributionBuilder(Builder): # os.chdir(self.dist.getReleasePath()) if self.calcmd5: - cmd = '/usr/bin/md5sum `find -L . -type f | sed "s/^\.\///" | ' + cmd = r'/usr/bin/md5sum `find -L . -type f | sed "s/^\.\///" | ' cmd += 'egrep -v "^build|^SRPMS|^force" | egrep -v "rpm$"` ' cmd += '> %s/packages.md5' % (productfilesdir) else: diff --git a/lib/sunhpc/core/files.py b/lib/sunhpc/core/files.py index 886a059..747bbee 100644 --- a/lib/sunhpc/core/files.py +++ b/lib/sunhpc/core/files.py @@ -162,9 +162,9 @@ class Tree: os.path.islink(filepath): self.build(os.path.join(dir, f)) else: - if re.match('.*\.rpm$', f) != None: + if re.match(r'.*\.rpm$', f) != None: v.append(RPMFile(filepath)) - elif re.match('roll-.*\.iso$', f) != None: + elif re.match(r'roll-.*\.iso$', f) != None: v.append(RollFile(filepath)) else: v.append(File(filepath)) @@ -204,7 +204,7 @@ class RPMBaseFile(File): def versionList(self, s): list = [] - for e in re.split('\.+|_+', s): + for e in re.split(r'\.+|_+', s): l = [] num = '' alpha = '' diff --git a/lib/sunhpc/core/security.py b/lib/sunhpc/core/security.py index 033d4cf..64211d8 100644 --- a/lib/sunhpc/core/security.py +++ b/lib/sunhpc/core/security.py @@ -34,10 +34,10 @@ class Security(object): self.masters = [] # A regex for our header search. - pattern = "\n*(?P.*?)\$110id\$" + pattern = r"\n*(?P.*?)\$110id\$" self.header_pattern = re.compile(pattern) - pattern = "(?P.+) +(?P\d+.*) +(?P\d+.*)" + pattern = r"(?P.+) +(?P\d+.*) +(?P\d+.*)" # Make the pattern matching engine case-insensitive. self.dir_pattern = re.compile(pattern, re.I) -- cgit v1.2.3