1410
def send_all(socket, bytes):
1411
"""Send all bytes on a socket.
1413
Regular socket.sendall() can give socket error 10053 on Windows. This
1414
implementation sends no more than 64k at a time, which avoids this problem.
1417
for pos in xrange(0, len(bytes), chunk_size):
1418
socket.sendall(bytes[pos:pos+chunk_size])
1409
1421
def dereference_path(path):
1410
1422
"""Determine the real path to a file.
1423
1435
def supports_mapi():
1424
1436
"""Return True if we can use MAPI to launch a mail client."""
1425
1437
return sys.platform == "win32"
1440
def resource_string(package, resource_name):
1441
"""Load a resource from a package and return it as a string.
1443
Note: Only packages that start with bzrlib are currently supported.
1445
This is designed to be a lightweight implementation of resource
1446
loading in a way which is API compatible with the same API from
1448
http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access.
1449
If and when pkg_resources becomes a standard library, this routine
1452
# Check package name is within bzrlib
1453
if package == "bzrlib":
1454
resource_relpath = resource_name
1455
elif package.startswith("bzrlib."):
1456
package = package[len("bzrlib."):].replace('.', os.sep)
1457
resource_relpath = pathjoin(package, resource_name)
1459
raise errors.BzrError('resource package %s not in bzrlib' % package)
1461
# Map the resource to a file and read its contents
1462
base = dirname(bzrlib.__file__)
1463
if getattr(sys, 'frozen', None): # bzr.exe
1464
base = abspath(pathjoin(base, '..', '..'))
1465
filename = pathjoin(base, resource_relpath)
1466
return open(filename, 'rU').read()