Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > This code works so far: > > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) > > But it does not writes anything to the terminal to inform the user. > > When I use: > > for member in taro.getmembers(): > print('extracting "%s"' % member.name) > taro.extract(member) > > I get the error: > > File "/usr/lib/python2.7/tarfile.py", line 556, in seek > raise StreamError("seeking backwards is not allowed") > > Of course, a stream is not seekable. > > Any ideas?
As a hack, I modified the standard library module tarfile.py: root@diaspora:/usr/lib/python2.7# vv -d --- ./.versions/tarfile.py~1~ 2015-06-22 21:59:27.000000000 +0200 +++ tarfile.py 2016-02-11 18:01:50.185555952 +0100 @@ -2045,6 +2045,7 @@ directories.append(tarinfo) tarinfo = copy.copy(tarinfo) tarinfo.mode = 0700 + print('untar "%s"' % tarinfo.name) self.extract(tarinfo, path) # Reverse sort directories. This gives me exact the output I want :-) BUT I want to distribute my program and all others will not see the tar extracting information. Now my question: How can I substitute the standard module function tarfile.extractall() with my own function? -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ -- https://mail.python.org/mailman/listinfo/python-list