~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-22 00:37:17 UTC
  • Revision ID: mbp@sourcefrog.net-20050322003717-7b1d4a370c237846
lift out tracefile creation code

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    ## XXX: Could alternatively read /proc/sys/kernel/random/uuid on
87
87
    ## Linux, but we need something portable for other systems;
88
88
    ## preferably an implementation in Python.
89
 
    try:
90
 
        return chomp(file('/proc/sys/kernel/random/uuid').readline())
91
 
    except IOError:
92
 
        return chomp(os.popen('uuidgen').readline())
93
 
 
 
89
    bailout('uuids not allowed!')
 
90
    return chomp(os.popen('uuidgen').readline())
94
91
 
95
92
def chomp(s):
96
93
    if s and (s[-1] == '\n'):
172
169
def compare_files(a, b):
173
170
    """Returns true if equal in contents"""
174
171
    # TODO: don't read the whole thing in one go.
175
 
    BUFSIZE = 4096
176
 
    while True:
177
 
        ai = a.read(BUFSIZE)
178
 
        bi = b.read(BUFSIZE)
179
 
        if ai != bi:
180
 
            return False
181
 
        if ai == '':
182
 
            return True
 
172
    result = a.read() == b.read()
 
173
    return result
183
174
 
184
175
 
185
176
 
186
177
def local_time_offset(t=None):
187
178
    """Return offset of local zone from GMT, either at present or at time t."""
188
 
    # python2.3 localtime() can't take None
189
 
    if t is None:
190
 
        t = time.time()
191
 
        
192
179
    if time.localtime(t).tm_isdst and time.daylight:
193
180
        return -time.altzone
194
181
    else: