1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
imported from bzrlib.smart.
23
from __future__ import absolute_import
23
25
__all__ = ['RemoteTransport', 'RemoteTCPTransport', 'RemoteSSHTransport']
25
27
from cStringIO import StringIO
248
247
transport._file_streams[self.abspath(relpath)] = result
251
def put_bytes(self, relpath, upload_contents, mode=None):
252
# FIXME: upload_file is probably not safe for non-ascii characters -
253
# should probably just pass all parameters as length-delimited
255
if type(upload_contents) is unicode:
256
# Although not strictly correct, we raise UnicodeEncodeError to be
257
# compatible with other transports.
258
raise UnicodeEncodeError(
259
'undefined', upload_contents, 0, 1,
260
'put_bytes must be given bytes, not unicode.')
261
resp = self._call_with_body_bytes('put',
250
def put_bytes(self, relpath, raw_bytes, mode=None):
251
if not isinstance(raw_bytes, str):
253
'raw_bytes must be a plain string, not %s' % type(raw_bytes))
254
resp = self._call_with_body_bytes(
262
256
(self._remote_path(relpath), self._serialise_optional_mode(mode)),
264
258
self._ensure_ok(resp)
265
return len(upload_contents)
259
return len(raw_bytes)
267
def put_bytes_non_atomic(self, relpath, bytes, mode=None,
261
def put_bytes_non_atomic(self, relpath, raw_bytes, mode=None,
268
262
create_parent_dir=False,
270
264
"""See Transport.put_bytes_non_atomic."""
277
271
'put_non_atomic',
278
272
(self._remote_path(relpath), self._serialise_optional_mode(mode),
279
273
create_parent_str, self._serialise_optional_mode(dir_mode)),
281
275
self._ensure_ok(resp)
283
277
def put_file(self, relpath, upload_file, mode=None):
541
535
# url only for an intial construction (when the url came from the
543
537
http_url = base[len('bzr+'):]
544
self._http_transport = transport.get_transport(http_url)
538
self._http_transport = transport.get_transport_from_url(http_url)
546
540
self._http_transport = http_transport
547
541
super(RemoteHTTPTransport, self).__init__(