[FIX] tests: make sure screencasts dir exists before writing to it
Without this patch, running this command on an environment where the tour will fail, will create massive and useless logs:
odoo --stop-after-init -i auth_totp --test-enable --test-tags /auth_totp
This is because this method is a callback that can come in a different thread, creating a race condition.
There's no problem on checking wether the directory exists before creating the file, and then safeguarding from the problem.
@moduon MT-1075
closes odoo/odoo#151579
X-original-commit: 7aca8ae8728c66700c3afdca350e99ea78a63d88
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
@@ -1343,12 +1343,15 @@ which leads to stray network requests and inconsistencies."""
|
||||
def _handle_screencast_frame(self, sessionId, data, metadata):
|
||||
self._websocket_send('Page.screencastFrameAck', params={'sessionId': sessionId})
|
||||
outfile = os.path.join(self.screencasts_frames_dir, 'frame_%05d.b64' % len(self.screencast_frames))
|
||||
with open(outfile, 'w') as f:
|
||||
f.write(data)
|
||||
self.screencast_frames.append({
|
||||
'file_path': outfile,
|
||||
'timestamp': metadata.get('timestamp')
|
||||
})
|
||||
try:
|
||||
with open(outfile, 'w') as f:
|
||||
f.write(data)
|
||||
self.screencast_frames.append({
|
||||
'file_path': outfile,
|
||||
'timestamp': metadata.get('timestamp')
|
||||
})
|
||||
except FileNotFoundError:
|
||||
self._logger.debug('Useless screencast frame skipped: %s', outfile)
|
||||
|
||||
_TO_LEVEL = {
|
||||
'debug': logging.DEBUG,
|
||||
|
||||
Reference in New Issue
Block a user