[fbt-commit] SF.net SVN: fbt:[93] trunk/bin/synplify_wrapper.py
Status: Beta
Brought to you by:
dave_infj
|
From: <dav...@us...> - 2010-04-14 14:59:45
|
Revision: 93
http://fbt.svn.sourceforge.net/fbt/?rev=93&view=rev
Author: dave_infj
Date: 2010-04-14 14:59:39 +0000 (Wed, 14 Apr 2010)
Log Message:
-----------
now implements the equivalent of tail -f on log file, so progress of synth can
be watched.
Add an exception to handle (naively) synplify subprocess ident lines
Unknown log lines now result in a warning, rather than an error.
Modified Paths:
--------------
trunk/bin/synplify_wrapper.py
Modified: trunk/bin/synplify_wrapper.py
===================================================================
--- trunk/bin/synplify_wrapper.py 2010-04-13 16:53:18 UTC (rev 92)
+++ trunk/bin/synplify_wrapper.py 2010-04-14 14:59:39 UTC (rev 93)
@@ -34,6 +34,8 @@
import sys
import os
+import subprocess
+import time
import errno
import re
import getopt
@@ -92,6 +94,19 @@
return (type, code, file, lno, msg)
+def tail_f(file, run_condition):
+ interval = 0.5
+
+ while run_condition():
+ where = file.tell()
+ line = file.readline()
+ if not line:
+ time.sleep(interval)
+ file.seek(where)
+ else:
+ yield line
+
+
def exec_synplify( project, verbose, exe ):
# various filenames
path, entity = os.path.split( os.path.splitext(project)[0] )
@@ -114,7 +129,8 @@
raise e
# Do synthesis run
- syn_result = os.system( '%s -batch %s' % (exe, project) )
+ syn_proc = subprocess.Popen( '%s -batch %s' % (exe, project), shell=True )
+ time.sleep( 1 )
if not os.path.isfile( synth_input_log ):
raise Panic( "synthesis log does not exist. %s may not have run properly." %
(exe) )
@@ -164,15 +180,25 @@
""" % (prog_name(), exe, project, os.path.abspath(synth_input_log)) )
with open( synth_input_log ) as sil:
- for line in sil:
+ for line in tail_f(sil, lambda: syn_proc.poll() is None):
# Want only useful messages (^@), and not @END lines
line = line.strip()
+
+ # Print the sub-programme header, so one can see progress
+ if line.startswith('Synpl'):
+ line = line[:80]
+ print '\n%s\n%s\n%s\n' % ('-'*len(line),
+ line,
+ '-'*len(line))
+
+ # Otherwise, process only message lines
if not line.startswith('@') or line in at_ignores:
continue
match = m_parse_log.search( line )
if not match:
- raise Panic( "unknown log entry:\n%s" % (line) )
+ print "%s: warning: unknown log entry:\n%s" % (prog_name(), line)
+ continue
# Parse log line, doing any type conversions
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|