~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-18 18:20:31 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070518182031-gbg2cgidv5l20x9p
Takes Robert comments into account.

* bzrlib/transport/ftp.py:
(FtpTransport.__init__): Write a better explanation.

* bzrlib/tests/test_init.py:
(InstrumentedTransport): Just make hooks a class attribute.
(InstrumentedTransport._get_FTP): Run hook directly in the for
loop.
(TransportHooks.run_hook, TransportHooks.uninstall_hook): Not
needed. The hooks should be cleaned up by the test itself.
(TestInit.setUp.cleanup): Resset to default hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Server-side repository related request implmentations."""
18
18
 
19
 
import os
20
19
import sys
21
20
import tempfile
22
21
import tarfile
214
213
    def _tarfile_response(self, tmp_dirname, compression):
215
214
        temp = tempfile.NamedTemporaryFile()
216
215
        try:
217
 
            self._tarball_of_dir(tmp_dirname, compression, temp.file)
 
216
            self._tarball_of_dir(tmp_dirname, compression, temp.name)
218
217
            # all finished; write the tempfile out to the network
219
218
            temp.seek(0)
220
219
            return SuccessfulSmartServerResponse(('ok',), temp.read())
223
222
        finally:
224
223
            temp.close()
225
224
 
226
 
    def _tarball_of_dir(self, dirname, compression, ofile):
227
 
        filename = os.path.basename(ofile.name)
228
 
        tarball = tarfile.open(fileobj=ofile, name=filename,
229
 
            mode='w|' + compression)
 
225
    def _tarball_of_dir(self, dirname, compression, tarfile_name):
 
226
        tarball = tarfile.open(tarfile_name, mode='w:' + compression)
230
227
        try:
231
228
            # The tarball module only accepts ascii names, and (i guess)
232
229
            # packs them with their 8bit names.  We know all the files