/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

MergeĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
    import random
130
130
    base = os.path.basename(new)
131
131
    dirname = os.path.dirname(new)
132
 
    tmp_name = u'tmp.%s.%.9f.%d.%d' % (base, time.time(), os.getpid(), random.randint(0, 0x7FFFFFFF))
 
132
    tmp_name = u'tmp.%s.%.9f.%d.%s' % (base, time.time(), os.getpid(), rand_chars(10))
133
133
    tmp_name = pathjoin(dirname, tmp_name)
134
134
 
135
135
    # Rename the file out of the way, but keep track if it didn't exist
441
441
    """Return size of given open file."""
442
442
    return os.fstat(f.fileno())[ST_SIZE]
443
443
 
 
444
 
444
445
# Define rand_bytes based on platform.
445
446
try:
446
447
    # Python 2.4 and later have os.urandom,
463
464
                n -= 1
464
465
            return s
465
466
 
 
467
 
 
468
ALNUM = '0123456789abcdefghijklmnopqrstuvwxyz'
 
469
def rand_chars(num):
 
470
    """Return a random string of num alphanumeric characters
 
471
    
 
472
    The result only contains lowercase chars because it may be used on 
 
473
    case-insensitive filesystems.
 
474
    """
 
475
    s = ''
 
476
    for raw_byte in rand_bytes(num):
 
477
        s += ALNUM[ord(raw_byte) % 36]
 
478
    return s
 
479
 
 
480
 
466
481
## TODO: We could later have path objects that remember their list
467
482
## decomposition (might be too tricksy though.)
468
483
 
618
633
        return int(os.environ['COLUMNS'])
619
634
    except (IndexError, KeyError, ValueError):
620
635
        return 80
 
636
 
 
637
def supports_executable():
 
638
    return sys.platform != "win32"