From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 52E2B1384B4 for ; Sat, 21 Nov 2015 01:34:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AFE0221C031; Sat, 21 Nov 2015 01:33:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 35BFA21C030 for ; Sat, 21 Nov 2015 01:33:56 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 54119340AC7 for ; Sat, 21 Nov 2015 01:33:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 896141471 for ; Sat, 21 Nov 2015 01:33:45 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1447044388.5cce2772eda7d0885c9d7cfea184a3f5606dddef.dolsen@gentoo> Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/targets/, catalyst/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/config.py catalyst/support.py catalyst/targets/livecd_stage2.py X-VCS-Directories: catalyst/base/ catalyst/targets/ catalyst/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 5cce2772eda7d0885c9d7cfea184a3f5606dddef X-VCS-Branch: pending Date: Sat, 21 Nov 2015 01:33:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 24af58b0-0a4f-4a86-832c-579d06ce03f3 X-Archives-Hash: 160de9069fe1598f59c3407470e97782 commit: 5cce2772eda7d0885c9d7cfea184a3f5606dddef Author: Brian Dolbec gentoo org> AuthorDate: Mon Nov 9 04:46:28 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Mon Nov 9 04:46:28 2015 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5cce2772 catalyst: Convert nearly all use of open() to use the with statement. There was one use in stagebase that was too large a code block to convert at this time. catalyst/base/stagebase.py | 5 ++--- catalyst/config.py | 5 ++--- catalyst/support.py | 5 ++--- catalyst/targets/livecd_stage2.py | 19 ++++++++++--------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ffd84de..edbcaa6 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -848,9 +848,8 @@ class StageBase(TargetBase, ClearBase, GenBase): log.error('%s', unpack_errmsg % unpack_info) if "snapcache" in self.settings["options"]: - myf = open(snapshot_cache_hash_path, 'w') - myf.write(self.settings["snapshot_path_hash"]) - myf.close() + with open(snapshot_cache_hash_path, 'w') as myf: + myf.write(self.settings["snapshot_path_hash"]) else: log.info('Setting snapshot autoresume point') self.resume.enable("unpack_portage", diff --git a/catalyst/config.py b/catalyst/config.py index 5f72e15..ee73abd 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -27,12 +27,11 @@ class ParserBase(object): def parse_file(self, filename): try: - myf = open(filename, "r") + with open(filename, "r") as myf: + self.lines = myf.readlines() except: raise CatalystError("Could not open file " + filename, print_traceback=True) - self.lines = myf.readlines() - myf.close() self.filename = filename self.parse() diff --git a/catalyst/support.py b/catalyst/support.py index 4bf1b22..e132568 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -155,9 +155,8 @@ def read_makeconf(mymakeconffile): import portage_util return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except ImportError: - myf=open(mymakeconffile,"r") - mylines=myf.readlines() - myf.close() + with open(mymakeconffile, "r") as myf: + mylines=myf.readlines() return parse_makeconf(mylines) except Exception: raise CatalystError("Could not parse make.conf file " + diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index fa76421..943466e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -68,8 +68,17 @@ class livecd_stage2(StageBase): def run_local(self): # what modules do we want to blacklist? if "livecd/modblacklist" in self.settings: + path = normpath(self.settings["chroot_path"], + "/etc/modprobe.d/blacklist.conf") try: - myf=open(self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf","a") + with open(path, "a") as myf: + myf.write("\n#Added by Catalyst:") + # workaround until config.py is using configparser + if isinstance(self.settings["livecd/modblacklist"], str): + self.settings["livecd/modblacklist"] = self.settings[ + "livecd/modblacklist"].split() + for x in self.settings["livecd/modblacklist"]: + myf.write("\nblacklist "+x) except: self.unbind() raise CatalystError("Couldn't open " + @@ -77,14 +86,6 @@ class livecd_stage2(StageBase): "/etc/modprobe.d/blacklist.conf.", print_traceback=True) - myf.write("\n#Added by Catalyst:") - # workaround until config.py is using configparser - if isinstance(self.settings["livecd/modblacklist"], str): - self.settings["livecd/modblacklist"] = self.settings["livecd/modblacklist"].split() - for x in self.settings["livecd/modblacklist"]: - myf.write("\nblacklist "+x) - myf.close() - def set_action_sequence(self): self.settings["action_sequence"]=["unpack","unpack_snapshot",\ "config_profile_link","setup_confdir","portage_overlay",\ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C4DE21384B4 for ; Mon, 9 Nov 2015 04:47:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9BD08E07FE; Mon, 9 Nov 2015 04:47:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3042FE07FE for ; Mon, 9 Nov 2015 04:47:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DCE8533FE13 for ; Mon, 9 Nov 2015 04:47:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 546282335 for ; Mon, 9 Nov 2015 04:47:39 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1447044388.5cce2772eda7d0885c9d7cfea184a3f5606dddef.dolsen@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/config.py catalyst/support.py catalyst/targets/livecd_stage2.py X-VCS-Directories: catalyst/base/ catalyst/ catalyst/targets/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 5cce2772eda7d0885c9d7cfea184a3f5606dddef X-VCS-Branch: master Date: Mon, 9 Nov 2015 04:47:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 963ac33d-5afc-41b0-b07c-8e96d3f8422a X-Archives-Hash: 94709d81124cf45abde64bb6d44290c5 Message-ID: <20151109044739.1z-KHypzJE3Lu7SQ68yPYWnN4IdGbBvWBQEtVN8_CVI@z> commit: 5cce2772eda7d0885c9d7cfea184a3f5606dddef Author: Brian Dolbec gentoo org> AuthorDate: Mon Nov 9 04:46:28 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Mon Nov 9 04:46:28 2015 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5cce2772 catalyst: Convert nearly all use of open() to use the with statement. There was one use in stagebase that was too large a code block to convert at this time. catalyst/base/stagebase.py | 5 ++--- catalyst/config.py | 5 ++--- catalyst/support.py | 5 ++--- catalyst/targets/livecd_stage2.py | 19 ++++++++++--------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ffd84de..edbcaa6 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -848,9 +848,8 @@ class StageBase(TargetBase, ClearBase, GenBase): log.error('%s', unpack_errmsg % unpack_info) if "snapcache" in self.settings["options"]: - myf = open(snapshot_cache_hash_path, 'w') - myf.write(self.settings["snapshot_path_hash"]) - myf.close() + with open(snapshot_cache_hash_path, 'w') as myf: + myf.write(self.settings["snapshot_path_hash"]) else: log.info('Setting snapshot autoresume point') self.resume.enable("unpack_portage", diff --git a/catalyst/config.py b/catalyst/config.py index 5f72e15..ee73abd 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -27,12 +27,11 @@ class ParserBase(object): def parse_file(self, filename): try: - myf = open(filename, "r") + with open(filename, "r") as myf: + self.lines = myf.readlines() except: raise CatalystError("Could not open file " + filename, print_traceback=True) - self.lines = myf.readlines() - myf.close() self.filename = filename self.parse() diff --git a/catalyst/support.py b/catalyst/support.py index 4bf1b22..e132568 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -155,9 +155,8 @@ def read_makeconf(mymakeconffile): import portage_util return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except ImportError: - myf=open(mymakeconffile,"r") - mylines=myf.readlines() - myf.close() + with open(mymakeconffile, "r") as myf: + mylines=myf.readlines() return parse_makeconf(mylines) except Exception: raise CatalystError("Could not parse make.conf file " + diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index fa76421..943466e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -68,8 +68,17 @@ class livecd_stage2(StageBase): def run_local(self): # what modules do we want to blacklist? if "livecd/modblacklist" in self.settings: + path = normpath(self.settings["chroot_path"], + "/etc/modprobe.d/blacklist.conf") try: - myf=open(self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf","a") + with open(path, "a") as myf: + myf.write("\n#Added by Catalyst:") + # workaround until config.py is using configparser + if isinstance(self.settings["livecd/modblacklist"], str): + self.settings["livecd/modblacklist"] = self.settings[ + "livecd/modblacklist"].split() + for x in self.settings["livecd/modblacklist"]: + myf.write("\nblacklist "+x) except: self.unbind() raise CatalystError("Couldn't open " + @@ -77,14 +86,6 @@ class livecd_stage2(StageBase): "/etc/modprobe.d/blacklist.conf.", print_traceback=True) - myf.write("\n#Added by Catalyst:") - # workaround until config.py is using configparser - if isinstance(self.settings["livecd/modblacklist"], str): - self.settings["livecd/modblacklist"] = self.settings["livecd/modblacklist"].split() - for x in self.settings["livecd/modblacklist"]: - myf.write("\nblacklist "+x) - myf.close() - def set_action_sequence(self): self.settings["action_sequence"]=["unpack","unpack_snapshot",\ "config_profile_link","setup_confdir","portage_overlay",\