refs #1461 extract progress from other place

pull/15/head
Natalia Serrano 2025-02-11 12:04:21 +01:00
parent f8d6706897
commit 1de04f3a7a
1 changed files with 3 additions and 46 deletions

View File

@ -195,54 +195,11 @@ class ogLiveWorker(ServerWorker):
return { 'res':success, 'der':msg }
def _extract_progress (self, job_id, ary=[]):
is_create = is_restore = False
if job_id not in self.progress_jobs: self.progress_jobs[job_id] = { 'restore_with_cache': False }
if 'CrearImagen-' in job_id:
is_create = True
elif 'RestaurarImagen-' in job_id:
is_restore = True
else:
return None
progress = None
for i in ary:
if is_restore:
## RestaurarImagen:
## - si nos traemos la imagen a cache por unicast, se llama en última instancia a rsync:
## - ' 32,77K 0% 0,00kB/s 0:00:00'
## - ' 11,57M 0% 8,77MB/s 0:06:16'
## - ' 1,03G 30% 11,22MB/s 0:03:25'
## - ' 3,39G 100% 11,22MB/s 0:04:48 (xfr#1, to-chk=0/1)'
if m := re.search (r'\d+,\d+[KMGT]\s+(\d+)%.*[kM]B/s', i):
if m := re.search (r'^\[([0-9]+)\]', i): ## look for strings like '[10]', '[60]'
logger.debug (f"matched regex, m.groups ({m.groups()})")
progress = float (m.groups()[0]) / 100
progress /= 2
self.progress_jobs[job_id]['restore_with_cache'] = True
## - si nos traemos la imagen a cache por multicast:
#elif regex:
#TODO
#progress =/ 2
#self.progress_jobs[job_id]['restore_with_cache'] = True
## - si nos traemos la imagen a cache por torrent:
#elif regex:
#TODO
#progress =/ 2
#self.progress_jobs[job_id]['restore_with_cache'] = True
## - tanto si nos la hemos traído a cache como si no, pasamos la imagen a la partición:
## - 'Current block: 720646, Total block: 1750078, Complete: 41,18%'
## - 'Elapsed: 00:00:20, Remaining: 00:00:15, Completed: 57,06%, 9,81GB/min,'
## - 'Current block: 1606658, Total block: 1750078, Complete: 100.00%'
## - 'Elapsed: 00:00:36, Remaining: 00:00:00, Completed: 100.00%, Rate: 9,56GB/min,'
elif m := re.search (r'Current block:.*Complete:\s+(\d+[,.]\d+)%', i):
progress = float (m.groups()[0].replace (',', '.')) / 100
if self.progress_jobs[job_id]['restore_with_cache']:
progress /= 2
progress += 0.5
elif is_create:
pass
if progress and progress > 1: progress = 1
return progress
def mon (self):