| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- def after_simulation(ctrltree, datfile, opener, mpart_opener, options):
- import time
- from zipfile import ZipFile, ZIP_DEFLATED
- from utils.xml import TreeToFile
-
- runid = ctrltree.getroot().attrib['runid']
- url = options.url + '/transferFullResult?worker=%s&runid=%s' % (WORKER_ID, runid)
-
- # try to open - sometimes the raw file seems not to be fully flushed to disk
- vi = VolumeImage()
- for i in range(5):
- try:
- vi.read(datfile)
- except Exception:
- time.sleep(0.5)
- if i == 4:
- raise IOError('cannot read datfile')
- else:
- break
-
-
- rawfile = datfile.parent.joinpath(datfile.namebase + '.raw')
- zfile = datfile.parent.joinpath(datfile.namebase + '.raw.zip')
- ctrlfile = datfile.parent.joinpath(datfile.namebase + '.xml')
- TreeToFile(ctrltree, ctrlfile)
-
- log.info('zipping %s and %s' % (rawfile, datfile))
-
- with ZipFile(zfile, mode='w', compression=ZIP_DEFLATED) as zf:
- zf.write(rawfile)
- zf.write(datfile)
- zf.write(ctrlfile)
-
- log.info('sending %.1f kb zipped rawdata...' % (zfile.size / 1024.0))
-
- t = time.time()
- try:
- mpart_opener.open(url, data={'zippedfile': open(zfile, "rb")})
- except Exception:
- log.exception('cannot send data to %s' % url)
- else:
- log.info('transmitted with %.2f kb/sec' % (zfile.size / 1024.0 / (time.time() - t)))
-
-
-
-
|