Hi All , I need some help to print error lines from a log file :
for example the following logfile : SQL> SQL> SET PAGESIZE 0 SQL> SELECT 'Starting apply for patch 26925263/21857460 on ' || 2 SYSTIMESTAMP FROM dual; Starting apply for patch 26925263/21857460 on 28-JUN-18 07.46.34.893957 PM -05:00 1 row selected. SQL> SET PAGESIZE 10 SQL> SQL> BEGIN 2 dbms_sqlpatch.patch_initialize(p_patch_id => 26925263, 3 p_patch_uid => 21857460, 4 p_flags => '&flags', 5 p_description => '&description', 6 p_action => 'APPLY', 7 p_logfile => '&full_logfile', 8 p_bundle_series => '&bundle_series'); 9 END; 10 / BEGIN * ERROR at line 1: ORA-20001: set_patch_metadata not called ORA-06512: at "SYS.DBMS_SQLPATCH", line 647 ORA-06512: at line 2 SQL> SQL> COLUMN install_file NEW_VALUE sql_script SQL> SQL> SQL> ALTER SESSION SET CURRENT_SCHEMA = SYS; Session altered. So here I want to open the log file and find the error and print all the lines from starting till the error : ORA-20001: set_patch_metadata not called f4 = open (r"file1.log", 'r') string2=f4.readlines() for i in range(len(string2)): position=i lastposition =position+1 while True: if re.search('ORA-20001: set_patch_metadata not called',string2[lastposition]): break elif lastposition==len(string2)-1: break else: lastposition += 1 errorcheck=string2[position:lastposition] print errorcheck It gives me error : IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--NotebookApp.iopub_data_rate_limit`. Current values: NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec) NotebookApp.rate_limit_window=3.0 (secs) the first for loop will search for the error and provide me the position of the error . I think the logic I am using is correct but need some expert comment to make it work also some guidance on how to print all the lines until the error is received . Please advice, -- Asad Hasan +91 9582111698 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor