Petr Horáček has posted comments on this change.
Change subject: utils: atomic write ......................................................................
Patch Set 8: Verified+1
(3 comments)
Passed utilsTests.py and network/*_test.py.
https://gerrit.ovirt.org/#/c/61482/7/lib/vdsm/utils.py File lib/vdsm/utils.py:
Line 827: """ Line 828: return os.times()[4] Line 829: Line 830: Line 831: def random_name(prefix='', max_length=15):
Suggestion: Rename this to something generic, like random_name.
Done Line 832: """ Line 833: Create a random name with the supplied prefix and a pseudo-random suffix, Line 834: e.g. dummy_ilXaYiSn7. Network devices' names are bound to IFNAMSIZ of 16-1 Line 835: chars.
https://gerrit.ovirt.org/#/c/61482/7/tests/utilsTests.py File tests/utilsTests.py:
PS7, Line 1070: ite(test_file_path, 'w') as f:
It will be nicer if you can arrange them as in the func definition.
helper was dropped
Line 1068: with namedTemporaryDir() as tmp_dir: Line 1069: test_file_path = os.path.join(tmp_dir, 'foo.txt') Line 1070: with utils.atomic_write(test_file_path, 'w') as f: Line 1071: f.write(TEXT) Line 1072: self.assertFalse(os.path.exists(test_file_path))
Too much logic exists here with regard to original_text existing or not.
Done Line 1073: self._assert_file_contains(test_file_path, TEXT) Line 1074: # temporary file was removed Line 1075: self.assertEqual(len(os.listdir(tmp_dir)), 1) Line 1076: