~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-17 09:07:12 UTC
  • mfrom: (5984 +trunk)
  • mto: (5971.2.3 bzr-gpgme)
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110617090712-gbp520g89lwfhihn
mergeĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2381
2381
    except UnicodeDecodeError:
2382
2382
        raise errors.BzrError("Can't decode username as %s." % \
2383
2383
                user_encoding)
 
2384
    except ImportError, e:
 
2385
        if sys.platform != 'win32':
 
2386
            raise
 
2387
        if str(e) != 'No module named pwd':
 
2388
            raise
 
2389
        # https://bugs.launchpad.net/bzr/+bug/660174
 
2390
        # getpass.getuser() is unable to return username on Windows
 
2391
        # if there is no USERNAME environment variable set.
 
2392
        # That could be true if bzr is running as a service,
 
2393
        # e.g. running `bzr serve` as a service on Windows.
 
2394
        # We should not fail with traceback in this case.
 
2395
        username = u'UNKNOWN'
2384
2396
    return username
2385
2397
 
2386
2398