Since we now require Python 2.5, we can use os.SEEK_END.

This commit is contained in:
david-sarah 2012-05-16 21:39:48 +00:00
parent a1a1b5bf8a
commit 4ddcde3094
4 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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))

View File

@ -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")