when seeking a file, use os module constants instead of straight numbers

This commit is contained in:
Fabio Erculiani
2009-06-02 16:33:06 +02:00
parent 4fcd5f786b
commit 76d42edf48
5 changed files with 9 additions and 9 deletions
@@ -2446,7 +2446,7 @@ class Package:
# check size first
repo_size = dbconn.retrieveSize(idpackage)
f = open(os.path.join(etpConst['entropyworkdir'],self.infoDict['download']),"r")
f.seek(0,2)
f.seek(0,os.SEEK_END)
disk_size = f.tell()
f.close()
if repo_size == disk_size:
@@ -2503,7 +2503,7 @@ class Package:
down_path = os.path.join(etp_workdir,download)
if os.path.isfile(down_path):
with open(down_path,"r") as f:
f.seek(0,2)
f.seek(0,os.SEEK_END)
disk_size = f.tell()
if repo_size == disk_size:
temp_already_downloaded_count += 1
@@ -229,13 +229,13 @@ class Base(SocketCommands):
text = ''
else:
f = open(file_path,"r")
f.seek(0,2)
f.seek(0,os.SEEK_END)
tell_me = f.tell()
if bytes_from_tail < 1:
bytes_from_tail = tell_me
if bytes_from_tail > tell_me:
bytes_from_tail = tell_me
f.seek(-1*bytes_from_tail,2)
f.seek(-1*bytes_from_tail,os.SEEK_END)
text = f.read()
f.close()
@@ -1110,7 +1110,7 @@ class Base:
def is_last_newline(f):
try:
f.seek(-1,2)
f.seek(-1,os.SEEK_END)
last = f.read(1)
if last == "\n":
return True
+1 -1
View File
@@ -125,7 +125,7 @@ class UrlFetcher:
os.access(self.__path_to_save,os.W_OK) and self.__resume:
self.localfile = open(self.__path_to_save,"awb")
self.localfile.seek(0,2)
self.localfile.seek(0,os.SEEK_END)
self.__startingposition = int(self.localfile.tell())
self.__resumed = True
+3 -3
View File
@@ -266,7 +266,7 @@ class tbz2:
myfile=open(self.file,"a+")
if not myfile:
raise IOError
myfile.seek(-self.xpaksize,2) # 0,2 or -0,2 just mean EOF.
myfile.seek(-self.xpaksize,os.SEEK_END) # 0,2 or -0,2 just mean EOF.
myfile.truncate()
myfile.write(xpdata+encodeint(len(xpdata))+"STOP")
myfile.flush()
@@ -300,7 +300,7 @@ class tbz2:
return 1
self.filestat=mystat
a=open(self.file,"r")
a.seek(-16,2)
a.seek(-16,os.SEEK_END)
trailer=a.read()
self.infosize=0
self.xpaksize=0
@@ -312,7 +312,7 @@ class tbz2:
return 0
self.infosize=decodeint(trailer[8:12])
self.xpaksize=self.infosize+8
a.seek(-(self.xpaksize),2)
a.seek(-(self.xpaksize),os.SEEK_END)
header=a.read(16)
if header[0:8]!="XPAKPACK":
a.close()