)]}'
{"nova/tests/test_utils.py":[{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"9b80abfc395b86fbcf412bedc467fa6c12c05509","unresolved":false,"context_lines":[{"line_number":792,"context_line":"    def test_read_all(self):"},{"line_number":793,"context_line":"        self.f.seek(0, os.SEEK_SET)"},{"line_number":794,"context_line":"        out, truncated \u003d utils.last_bytes(self.f, 1000)"},{"line_number":795,"context_line":"        self.assertEqual(out, \u00271234567890\u0027)"},{"line_number":796,"context_line":"        self.assertFalse(truncated)"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAMH%2F%2FzvY%3D","line":795,"updated":"2012-11-21 22:36:39.000000000","message":"So this tests that you get the whole content when the file is shorter. I think it would be prudent to check that you don\u0027t get an os error on regular files if you seek back more than the length of the file. the fseek man page is not clear on whether that is an expected behaviour or not.","commit_id":"b04b178974999dd7954678636af5c9a60905b624"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"73b1265685bf94697223c1dcc250dcdbb2f6e733","unresolved":false,"context_lines":[{"line_number":792,"context_line":"    def test_read_all(self):"},{"line_number":793,"context_line":"        self.f.seek(0, os.SEEK_SET)"},{"line_number":794,"context_line":"        out, truncated \u003d utils.last_bytes(self.f, 1000)"},{"line_number":795,"context_line":"        self.assertEqual(out, \u00271234567890\u0027)"},{"line_number":796,"context_line":"        self.assertFalse(truncated)"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAMH%2F%2Fzto%3D","line":795,"in_reply_to":"AAAAMH%2F%2FzvY%3D","updated":"2012-11-21 22:52:11.000000000","message":"Done","commit_id":"b04b178974999dd7954678636af5c9a60905b624"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"a5c0569a470036431b9aac1449c38d9b54f82de6","unresolved":false,"context_lines":[{"line_number":811,"context_line":"            self.assertFalse(remaining \u003e 0)"},{"line_number":812,"context_line":""},{"line_number":813,"context_line":"        finally:"},{"line_number":814,"context_line":"            if os.path.exists(name):"},{"line_number":815,"context_line":"                os.remove(name)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAMH%2F%2Fzls%3D","line":814,"updated":"2012-11-22 00:28:50.000000000","message":"This would be simpler as\ndef test_seek_too_far_real_file(self):\n    file_obj \u003d tempfile.TemporaryFile()\n    content \u003d \u002701234567890\u0027\n    file_obj.write(content)\n    file_obj.seek(0)\n    self.assertEqual((content, 0), utils.last_bytes(file_obj, 1000))\n\nNot to mention being more correct - your test uses self.f, which is still a StringIO :)","commit_id":"d35e8012738629be2cd6f267c7fa8e9be222e442"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"06b62d0cd00ce8fdad98d4b7fe4f42b9395456d8","unresolved":false,"context_lines":[{"line_number":811,"context_line":"            self.assertFalse(remaining \u003e 0)"},{"line_number":812,"context_line":""},{"line_number":813,"context_line":"        finally:"},{"line_number":814,"context_line":"            if os.path.exists(name):"},{"line_number":815,"context_line":"                os.remove(name)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAMH%2F%2FzjI%3D","line":814,"in_reply_to":"AAAAMH%2F%2Fzjw%3D","updated":"2012-11-22 01:49:00.000000000","message":"See pydoc tempfile.TemporaryFile, it will clean up when the file closes, which will be when the last ref goes, as you have no cycles that should be very fast. Or you can add\nself.addCleanup(file_obj.close)\n\nto do that in a short and reliable style.\n\nAs for two assertions, you get more information from a failure if you see both, so its better for diagnosing failures.","commit_id":"d35e8012738629be2cd6f267c7fa8e9be222e442"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"5d66231d91e0c677091d6901767e888edf0db95e","unresolved":false,"context_lines":[{"line_number":811,"context_line":"            self.assertFalse(remaining \u003e 0)"},{"line_number":812,"context_line":""},{"line_number":813,"context_line":"        finally:"},{"line_number":814,"context_line":"            if os.path.exists(name):"},{"line_number":815,"context_line":"                os.remove(name)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAMH%2F%2Fzjw%3D","line":814,"in_reply_to":"AAAAMH%2F%2Fzls%3D","updated":"2012-11-22 01:32:09.000000000","message":"I need the filename so I can cleanup at the end of the test, so I don\u0027t think TemporaryFile() works for me. Good catch on the self.f thing. I think I prefer the assertions to be two separate assertions -- I think it reads more clearly.","commit_id":"d35e8012738629be2cd6f267c7fa8e9be222e442"}],"nova/tests/test_virt_drivers.py":[{"author":{"_account_id":1779,"name":"Daniel Berrange","email":"berrange@redhat.com","username":"berrange"},"change_message_id":"cf3806801e59a98952c68359bbd9ebf916475017","unresolved":false,"context_lines":[{"line_number":18,"context_line":"import base64"},{"line_number":19,"context_line":"import mox"},{"line_number":20,"context_line":"import netaddr"},{"line_number":21,"context_line":"import StringIO"},{"line_number":22,"context_line":"import sys"},{"line_number":23,"context_line":"import traceback"},{"line_number":24,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"AAAAMH%2F%2FzOg%3D","line":21,"updated":"2012-11-22 08:47:03.000000000","message":"Looks like these 3 new imports are left over from a previous version of this patch, as they\u0027re not used in your additions here","commit_id":"3608c313cefb08fba2b8d7128023bc86042266f9"}],"nova/utils.py":[{"author":{"_account_id":5511,"name":"Nikola Dipanov","email":"ndipanov@redhat.com","username":"ndipanov"},"change_message_id":"adaf0ea157fa6c898ee9ebc95b40731e2bf06f9a","unresolved":false,"context_lines":[{"line_number":1187,"context_line":""},{"line_number":1188,"context_line":"    :param file_like_object: The file to read"},{"line_number":1189,"context_line":"    :param number: The number of lines to return"},{"line_number":1190,"context_line":"    \"\"\""},{"line_number":1191,"context_line":""},{"line_number":1192,"context_line":"    # Seek to the end of the file"},{"line_number":1193,"context_line":"    file_like_object.seek(-1, os.SEEK_END)"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAMH%2F%2F0js%3D","line":1190,"updated":"2012-11-21 12:21:04.000000000","message":"I\u0027m worried that hand-rolling a \u0027tail\u0027 in python like this might open nova up to some type of DOS attack on some type of inputs (seeking can be slow).\n\nWould it be possible to have some timing/benchmark on this vs an actuall tail (with forking) vs maybe just reading lines of a file (deque maybe).\n\ntail seems to be a solved problem, we shouldn\u0027t re-implement it","commit_id":"b31eb01aee208994ef7bd741b855e2a296343f00"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"9b80abfc395b86fbcf412bedc467fa6c12c05509","unresolved":false,"context_lines":[{"line_number":1182,"context_line":"    execute(*args)"},{"line_number":1183,"context_line":""},{"line_number":1184,"context_line":""},{"line_number":1185,"context_line":"def last_bytes(file_like_object, number):"},{"line_number":1186,"context_line":"    \"\"\"Return the last number of bytes in the file, and if truncation occurred."},{"line_number":1187,"context_line":""},{"line_number":1188,"context_line":"    :param file_like_object: The file to read"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAMH%2F%2Fzuo%3D","line":1185,"updated":"2012-11-21 22:36:39.000000000","message":"The docstring here isn\u0027t quite enough to explain whats going on (or perhaps I\u0027m not smart enough to tell :)\n\nIt looks like you expect the file to always have started at 0 - but that isn\u0027t listed as a precondition of the function. So a file which has had lots of stuff added will return True for truncated always.\n\nI suggest doing the function something like:\nfile_contents(file_obj, max_size):\n\"\"\"Return up to max_size bytes from file_obj, from the end.\n\n:param file_obj: The file to read content from.\n:param max_size: The maximum number of bytes to return.\n:returns: (content_bytes, excess_size)\n\"\"\"\nfile_obj.seek(-max_size, os.SEEK_END)\nexcess \u003d file_obj.tell()\nreturn (file_obj, excess)\n\nThis will give callers more information when an excess is found.","commit_id":"b04b178974999dd7954678636af5c9a60905b624"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"73b1265685bf94697223c1dcc250dcdbb2f6e733","unresolved":false,"context_lines":[{"line_number":1182,"context_line":"    execute(*args)"},{"line_number":1183,"context_line":""},{"line_number":1184,"context_line":""},{"line_number":1185,"context_line":"def last_bytes(file_like_object, number):"},{"line_number":1186,"context_line":"    \"\"\"Return the last number of bytes in the file, and if truncation occurred."},{"line_number":1187,"context_line":""},{"line_number":1188,"context_line":"    :param file_like_object: The file to read"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAMH%2F%2FzsQ%3D","line":1185,"in_reply_to":"AAAAMH%2F%2Fzuo%3D","updated":"2012-11-21 22:52:11.000000000","message":"As discussed on IRC, I\u0027ll tweak this.","commit_id":"b04b178974999dd7954678636af5c9a60905b624"}],"nova/virt/libvirt/driver.py":[{"author":{"_account_id":1812,"name":"p-draigbrady","email":"P@draigBrady.com","username":"p-draigbrady"},"change_message_id":"d52244400d1527d1a0995a83c5137965db23f0e1","unresolved":false,"context_lines":[{"line_number":1177,"context_line":""},{"line_number":1178,"context_line":"        with libvirt_utils.file_open(fpath, \u0027rb\u0027) as fp:"},{"line_number":1179,"context_line":"            log_data, remaining \u003d utils.last_bytes(fp, MAX_CONSOLE_BYTES)"},{"line_number":1180,"context_line":"            LOG.info(_(\u0027Truncated console log returned, %d bytes ignored\u0027),"},{"line_number":1181,"context_line":"                     remaining, instance\u003dinstance)"},{"line_number":1182,"context_line":"            return log_data"},{"line_number":1183,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"AAAAMH%2F%2Fy8s%3D","line":1180,"updated":"2012-11-22 15:04:45.000000000","message":"shouldn\u0027t there be an if remaining \u003e 0 here too?","commit_id":"0be72004208bd296f5c2bff42c84fe0450cd3ff2"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"fbf43a36c169e85e584742ef599312769533f214","unresolved":false,"context_lines":[{"line_number":1177,"context_line":""},{"line_number":1178,"context_line":"        with libvirt_utils.file_open(fpath, \u0027rb\u0027) as fp:"},{"line_number":1179,"context_line":"            log_data, remaining \u003d utils.last_bytes(fp, MAX_CONSOLE_BYTES)"},{"line_number":1180,"context_line":"            LOG.info(_(\u0027Truncated console log returned, %d bytes ignored\u0027),"},{"line_number":1181,"context_line":"                     remaining, instance\u003dinstance)"},{"line_number":1182,"context_line":"            return log_data"},{"line_number":1183,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"AAAAMH%2F%2Fyws%3D","line":1180,"in_reply_to":"AAAAMH%2F%2Fy8s%3D","updated":"2012-11-22 20:09:00.000000000","message":"Doh, you\u0027re right. Good catch.","commit_id":"0be72004208bd296f5c2bff42c84fe0450cd3ff2"},{"author":{"_account_id":1082,"name":"Scott Moser","email":"smoser@ubuntu.com","username":"smoser"},"change_message_id":"ec03ade5a8f5d049ff378f5987a101d6290f1e3f","unresolved":false,"context_lines":[{"line_number":1153,"context_line":"                                                           MAX_CONSOLE_BYTES)"},{"line_number":1154,"context_line":"                    if remaining \u003e 0:"},{"line_number":1155,"context_line":"                        LOG.info(_(\u0027Truncated console log returned, %d bytes \u0027"},{"line_number":1156,"context_line":"                                   \u0027ignored\u0027), remaining, instance\u003dinstance)"},{"line_number":1157,"context_line":"                    return log_data"},{"line_number":1158,"context_line":""},{"line_number":1159,"context_line":"        # Try \u0027pty\u0027 types"}],"source_content_type":"text/x-python","patch_set":7,"id":"AAAAMH%2F%2Fx5E%3D","line":1156,"updated":"2012-11-25 21:05:08.000000000","message":"I\u0027d suggest that \"info\" is a bit high for this message.\nJust about any linux instance that has been rebooted will have console log of \u003e 100k.  Thus, just about every request for console access will produce this info level message.","commit_id":"fc4f4bd09a0ef3a65514c5dc733c7b2fd6ac7ead"}]}
