added counters for the upload and download queues

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@203 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2007-03-28 09:47:58 +00:00
parent d31b54cca7
commit e4102bca7f
3 changed files with 19 additions and 8 deletions
-1
View File
@@ -9,7 +9,6 @@ TODO list (for developers only):
- sync tool removal
- database update and management between me and reagent
- create a .md5 for every in upload package
- add a counter to the upload command
- reagent tasks:
- reagent should support a forced revision bumping
+12 -3
View File
@@ -260,8 +260,12 @@ def packages(options):
if (detailedUploadQueue != []):
ftp = activatorFTP(uri)
ftp.setCWD(etpConst['binaryurirelativepath'])
uploadCounter = str(len(detailedUploadQueue))
currentCounter = 0
for item in detailedUploadQueue:
print_info(red(" * Uploading file ")+bold(item[0]) + red(" [")+blue(bytesIntoHuman(item[1]))+red("] to ")+ bold(extractFTPHostFromUri(uri)) +red(" ..."),back = True)
currentCounter += 1
counterInfo = bold(" (")+blue(str(currentCounter))+"/"+red(uploadCounter)+bold(")")
print_info(counterInfo+red(" Uploading file ")+bold(item[0]) + red(" [")+blue(bytesIntoHuman(item[1]))+red("] to ")+ bold(extractFTPHostFromUri(uri)) +red(" ..."),back = True)
ftp.uploadFile(etpConst['packagessuploaddir']+"/"+item[0])
# now move the file into etpConst['packagesbindir']
os.system("mv "+etpConst['packagessuploaddir']+"/"+item[0]+" "+etpConst['packagesbindir']+"/")
@@ -272,16 +276,21 @@ def packages(options):
if (detailedDownloadQueue != []):
ftp = activatorFTP(uri)
ftp.setCWD(etpConst['binaryurirelativepath'])
downloadCounter = str(len(detailedDownloadQueue))
currentCounter = 0
for item in detailedDownloadQueue:
currentCounter += 1
counterInfo = bold(" (")+blue(str(currentCounter))+"/"+red(downloadCounter)+bold(")")
if os.path.isfile(etpConst['packagessuploaddir']+"/"+item[0]):
localSize = int(os.stat(etpConst['packagessuploaddir']+"/"+item[0])[6])
remoteSize = int(item[1])
if localSize == remoteSize:
print_info(red(" * Moving file ")+bold(item[0])+red(" to ")+bold(etpConst['packagesbindir'])+red(" ..."),back = True)
print_info(counterInfo+red(" Moving file ")+bold(item[0])+red(" to ")+bold(etpConst['packagesbindir'])+red(" ..."),back = True)
os.system("mv "+etpConst['packagessuploaddir']+"/"+item[0]+" "+etpConst['packagesbindir']+"/")
continue
print_info(red(" * Downloading file ")+bold(item[0]) + red(" [")+blue(bytesIntoHuman(item[1]))+red("] from ")+ bold(extractFTPHostFromUri(uri)) +red(" ..."),back = True)
print_info(counterInfo+red(" Downloading file ")+bold(item[0]) + red(" [")+blue(bytesIntoHuman(item[1]))+red("] from ")+ bold(extractFTPHostFromUri(uri)) +red(" ..."),back = True)
ftp.downloadFile(item[0],etpConst['packagesbindir']+"/")
print_info(red(" * Download completed for ")+bold(extractFTPHostFromUri(uri)))
ftp.closeFTPConnection()
+7 -4
View File
@@ -857,17 +857,20 @@ class activatorFTP:
def uploadFile(self,file,ascii = False):
for i in range(10): # ten tries
f = open(file)
file = file.split("/")[len(file.split("/"))-1]
filename = file.split("/")[len(file.split("/"))-1]
try:
if (ascii):
rc = self.ftpconn.storlines("STOR "+file,f)
rc = self.ftpconn.storlines("STOR "+filename+".tmp",f)
else:
rc = self.ftpconn.storbinary("STOR "+file,f)
rc = self.ftpconn.storbinary("STOR "+filename+".tmp",f)
# now we can rename the file with its original name
self.renameFile(filename+".tmp",filename)
return rc
except socket.error: # connection reset by peer
print_info(red("Upload issue, retrying..."))
self.reconnectHost() # reconnect
self.deleteFile(file)
self.deleteFile(filename)
self.deleteFile(filename+".tmp")
f.close()
continue