mirror of
https://git.yoctoproject.org/poky
synced 2026-05-07 16:59:22 +00:00
lib/oe/patch: use with open() for all file operations
with open(...)... is preferred for reading/writing files as it is neater and takes care of closing the file for you. (From OE-Core rev: 99ac382d84667eb496dc510d3277b8c55b237738) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3d0418a331
commit
2298b4a03e
+19
-21
@@ -115,7 +115,8 @@ class PatchTree(PatchSet):
|
||||
def _removePatchFile(self, all = False):
|
||||
if not os.path.exists(self.seriespath):
|
||||
return
|
||||
patches = open(self.seriespath, 'r+').readlines()
|
||||
with open(self.seriespath, 'r+') as f:
|
||||
patches = f.readlines()
|
||||
if all:
|
||||
for p in reversed(patches):
|
||||
self._removePatch(os.path.join(self.patchdir, p.strip()))
|
||||
@@ -405,16 +406,15 @@ class QuiltTree(PatchSet):
|
||||
if not os.path.exists(self.dir):
|
||||
raise NotFoundError(self.dir)
|
||||
if os.path.exists(seriespath):
|
||||
series = file(seriespath, 'r')
|
||||
for line in series.readlines():
|
||||
patch = {}
|
||||
parts = line.strip().split()
|
||||
patch["quiltfile"] = self._quiltpatchpath(parts[0])
|
||||
patch["quiltfilemd5"] = bb.utils.md5_file(patch["quiltfile"])
|
||||
if len(parts) > 1:
|
||||
patch["strippath"] = parts[1][2:]
|
||||
self.patches.append(patch)
|
||||
series.close()
|
||||
with open(seriespath, 'r') as f:
|
||||
for line in f.readlines():
|
||||
patch = {}
|
||||
parts = line.strip().split()
|
||||
patch["quiltfile"] = self._quiltpatchpath(parts[0])
|
||||
patch["quiltfilemd5"] = bb.utils.md5_file(patch["quiltfile"])
|
||||
if len(parts) > 1:
|
||||
patch["strippath"] = parts[1][2:]
|
||||
self.patches.append(patch)
|
||||
|
||||
# determine which patches are applied -> self._current
|
||||
try:
|
||||
@@ -436,9 +436,8 @@ class QuiltTree(PatchSet):
|
||||
self.InitFromDir()
|
||||
PatchSet.Import(self, patch, force)
|
||||
oe.path.symlink(patch["file"], self._quiltpatchpath(patch["file"]), force=True)
|
||||
f = open(os.path.join(self.dir, "patches","series"), "a");
|
||||
f.write(os.path.basename(patch["file"]) + " -p" + patch["strippath"]+"\n")
|
||||
f.close()
|
||||
with open(os.path.join(self.dir, "patches", "series"), "a") as f:
|
||||
f.write(os.path.basename(patch["file"]) + " -p" + patch["strippath"] + "\n")
|
||||
patch["quiltfile"] = self._quiltpatchpath(patch["file"])
|
||||
patch["quiltfilemd5"] = bb.utils.md5_file(patch["quiltfile"])
|
||||
|
||||
@@ -559,13 +558,12 @@ class UserResolver(Resolver):
|
||||
bb.utils.mkdirhier(t)
|
||||
import random
|
||||
rcfile = "%s/bashrc.%s.%s" % (t, str(os.getpid()), random.random())
|
||||
f = open(rcfile, "w")
|
||||
f.write("echo '*** Manual patch resolution mode ***'\n")
|
||||
f.write("echo 'Dropping to a shell, so patch rejects can be fixed manually.'\n")
|
||||
f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n")
|
||||
f.write("echo ''\n")
|
||||
f.write(" ".join(patchcmd) + "\n")
|
||||
f.close()
|
||||
with open(rcfile, "w") as f:
|
||||
f.write("echo '*** Manual patch resolution mode ***'\n")
|
||||
f.write("echo 'Dropping to a shell, so patch rejects can be fixed manually.'\n")
|
||||
f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n")
|
||||
f.write("echo ''\n")
|
||||
f.write(" ".join(patchcmd) + "\n")
|
||||
os.chmod(rcfile, 0775)
|
||||
|
||||
self.terminal("bash --rcfile " + rcfile, 'Patch Rejects: Please fix patch rejects manually', self.patchset.d)
|
||||
|
||||
Reference in New Issue
Block a user