jp: use with statement to open fifo
This commit is contained in:
parent
2531f966f6
commit
8484dbe56e
1 changed files with 6 additions and 6 deletions
|
|
@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue