From: david-sarah Date: Wed, 16 May 2012 21:39:48 +0000 (+0000) Subject: Since we now require Python 2.5, we can use os.SEEK_END. X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/somewhere?a=commitdiff_plain;h=4ddcde309454179a25e2a67e40882b7068721051;p=tahoe-lafs%2Ftahoe-lafs.git Since we now require Python 2.5, we can use os.SEEK_END. --- diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index 013aca97..27c4b5ca 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -1363,7 +1363,7 @@ class FileHandle(BaseUploadable): def get_size(self): if self._size is not None: return defer.succeed(self._size) - self._filehandle.seek(0,2) + self._filehandle.seek(0, os.SEEK_END) size = self._filehandle.tell() self._size = size self._filehandle.seek(0) diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py index c611a6f9..3b7c6e05 100644 --- a/src/allmydata/mutable/publish.py +++ b/src/allmydata/mutable/publish.py @@ -1224,7 +1224,7 @@ class MutableFileHandle: old_position = self._filehandle.tell() # Seek to the end of the file by seeking 0 bytes from the # file's end - self._filehandle.seek(0, 2) # 2 == os.SEEK_END in 2.5+ + self._filehandle.seek(0, os.SEEK_END) self._size = self._filehandle.tell() # Restore the previous position, in case this was called # after a read. diff --git a/src/allmydata/scripts/common_http.py b/src/allmydata/scripts/common_http.py index 9ceb7a79..66a6291c 100644 --- a/src/allmydata/scripts/common_http.py +++ b/src/allmydata/scripts/common_http.py @@ -1,4 +1,5 @@ +import os from cStringIO import StringIO import urlparse, httplib import allmydata # for __full_version__ @@ -53,7 +54,7 @@ def do_http(method, url, body=""): c.putheader("Connection", "close") old = body.tell() - body.seek(0, 2) + body.seek(0, os.SEEK_END) length = body.tell() body.seek(old) c.putheader("Content-Length", str(length)) diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index f6a6f2ff..0db1a89b 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -437,7 +437,7 @@ class FileUtil(unittest.TestCase): f.write("stuff.") f.close() f = fileutil.open_or_create(fn) - f.seek(0, 2) + f.seek(0, os.SEEK_END) f.write("more.") f.close() f = open(fn, "r")