diff --git a/frontends/src/jp/jp b/frontends/src/jp/jp index ac771634..004232c7 100755 --- a/frontends/src/jp/jp +++ b/frontends/src/jp/jp @@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +from __future__ import with_statement + #consts name = u"jp" about = name+u""" v%s (c) Jérôme Poisson (aka Goffi) 2009, 2010, 2011 @@ -210,9 +212,8 @@ class JP(): fifopath = os.path.join(tmp_dir,"pipe_out") os.mkfifo(fifopath) self.bridge.pipeOut(self._getFullJid(self.dest_jid), fifopath, {}, profile_key=self.profile) - f = open(fifopath, 'w+') - shutil.copyfileobj(sys.stdin, f) - f.close() + with open(fifopath, 'w') as f: + shutil.copyfileobj(sys.stdin, f) shutil.rmtree(tmp_dir) @@ -296,9 +297,8 @@ class JP(): answer_data["dest_path"] = fifopath os.mkfifo(fifopath) self.bridge.confirmationAnswer(id, True, answer_data) - f = open(fifopath, 'r') - shutil.copyfileobj(f, sys.stdout) - f.close() + with open(fifopath, 'r') as f: + shutil.copyfileobj(f, sys.stdout) shutil.rmtree(tmp_dir) self.loop.quit()