def _test_indent_print(): # Indent test code doesnt work in doctest blocks. import utool as ut flag = ut.ensure_logging() print('Checking indent. Should have none') with ut.Indenter('[INDENT] '): print('Checking indent. Should be indented') print('Should no longer be indented') text = ut.get_current_log_text() # The last line might sometimes be empty or not. # Not sure. # New hack: had to put in stride. Seems like logs get written # with two line breaks now last_lines = text.split('\n')[-8::2] if last_lines[-1] != '': assert False, 'DEV ERROR. REMOVE FIRST LINE INSTEAD OF LAST' last_lines = last_lines[:-1] #print('last_lines = %r' % (ut.repr3(last_lines))) try: assert last_lines[0].find('[INDENT] ') == -1, last_lines[0] assert last_lines[1].find('[INDENT] ') >= 0, 'did not indent %r' % ( last_lines[1], ) assert last_lines[2].find('[INDENT] ') == -1, last_lines[2] except AssertionError: print('Error. Last 3 lines') print(ut.repr3(last_lines)) raise if not flag: ut.stop_logging()
def _test_indent_print(): # Indent test code doesnt work in doctest blocks. import utool as ut flag = ut.ensure_logging() print('Checking indent. Should have none') with ut.Indenter('[INDENT] '): print('Checking indent. Should be indented') print('Should no longer be indented') text = ut.get_current_log_text() # The last line might sometimes be empty or not. # Not sure. # New hack: had to put in stride. Seems like logs get written # with two line breaks now last_lines = text.split('\n')[-8::2] if last_lines[-1] != '': assert False, 'DEV ERROR. REMOVE FIRST LINE INSTEAD OF LAST' last_lines = last_lines[:-1] #print('last_lines = %r' % (ut.repr3(last_lines))) try: assert last_lines[0].find('[INDENT] ') == -1, last_lines[0] assert last_lines[1].find('[INDENT] ') >= 0, 'did not indent %r' % (last_lines[1],) assert last_lines[2].find('[INDENT] ') == -1, last_lines[2] except AssertionError: print('Error. Last 3 lines') print(ut.repr3(last_lines)) raise if not flag: ut.stop_logging()
def get_current_log_text(self): r""" Example: >>> # xdoctest: +REQUIRES(--web-tests) >>> import wbia >>> with wbia.opendb_with_web('testdb1') as (ibs, client): ... resp = client.get('/log/current/') >>> resp.json {'status': {'success': True, 'code': 200, 'message': '', 'cache': -1}, 'response': None} """ text = ut.get_current_log_text() return text
def get_current_log_text(ibs): r""" CommandLine: python -m wbia.control.IBEISControl --exec-get_current_log_text python -m wbia.control.IBEISControl --exec-get_current_log_text --domain http://52.33.105.88 Example: >>> # xdoctest: +REQUIRES(--web-tests) >>> from wbia.control.IBEISControl import * # NOQA >>> import wbia >>> import wbia.web >>> with wbia.opendb_bg_web('testdb1', start_job_queue=False, managed=True) as web_ibs: ... resp = web_ibs.send_wbia_request('/log/current/', 'get') >>> print('\n-------Logs ----: \n' ) >>> print(resp) >>> print('\nL____ END LOGS ___\n') """ text = ut.get_current_log_text() return text
def get_current_log_text(ibs): r""" CommandLine: python -m ibeis.control.IBEISControl --exec-get_current_log_text python -m ibeis.control.IBEISControl --exec-get_current_log_text --domain http://52.33.105.88 Example: >>> # WEB_DOCTEST >>> from ibeis.control.IBEISControl import * # NOQA >>> import ibeis >>> import ibeis.web >>> web_ibs = ibeis.opendb_bg_web('testdb1', wait=.5, start_job_queue=False) >>> resp = web_ibs.send_ibeis_request('/log/current/', 'get') >>> print('\n-------Logs ----: \n' ) >>> print(resp) >>> print('\nL____ END LOGS ___\n') >>> web_ibs.terminate2() """ text = ut.get_current_log_text() return text