~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-09-03 20:58:40 UTC
  • mfrom: (3626.1.6 unicode_hostname)
  • Revision ID: pqm@pqm.ubuntu.com-20080903205840-mteswj8dfvld7vo3
(Mark Hammond) Fix bug #256550 by using a Unicode api on Windows for
        the host name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1470
1470
    return user_encoding
1471
1471
 
1472
1472
 
 
1473
def get_host_name():
 
1474
    """Return the current unicode host name.
 
1475
 
 
1476
    This is meant to be used in place of socket.gethostname() because that
 
1477
    behaves inconsistently on different platforms.
 
1478
    """
 
1479
    if sys.platform == "win32":
 
1480
        import win32utils
 
1481
        return win32utils.get_host_name()
 
1482
    else:
 
1483
        import socket
 
1484
        return socket.gethostname().decode(get_user_encoding())
 
1485
 
 
1486
 
1473
1487
def recv_all(socket, bytes):
1474
1488
    """Receive an exact number of bytes.
1475
1489