Skip to content

Commit

Permalink
LCI v1.9: snapshot/rollback mechanism added (for extracted sources)
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@188 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Aug 19, 2008
1 parent c60124d commit cbfba73
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions topics/convergence/lci/lci.py
Expand Up @@ -14,6 +14,7 @@
graph_small = []
log = None
tools = {}
almostfailed = []
failednode = []
failedarc = []
failedaction = []
Expand Down Expand Up @@ -151,6 +152,8 @@ def dumpgraph(df):
dot.write(quote(x))
if x in failednode:
dot.write(' [color=red]')
elif x in almostfailed:
dot.write(' [color=blue]')
dot.write(';')
dot.write('}\n')
dot.write('node [shape=octagon, style=bold];\n')
Expand Down Expand Up @@ -180,6 +183,8 @@ def dumpgraph(df):
if node not in targets.keys():
if node in failednode:
dot.write(quote(node)+' [color=red];')
elif node in almostfailed:
dot.write(quote(node)+' [color=blue];')
dot.write('}')
dot.close()
run = 'dot -Tpdf '+dot.name+' -o '+df+'_large.pdf'
Expand All @@ -191,13 +196,17 @@ def dumpgraph(df):
dot.write(quote(x))
if x in failednode:
dot.write(' [color=red]')
elif x in almostfailed:
dot.write(' [color=blue]')
dot.write(';')
dot.write('}')
dot.write('node [shape=octagon]\n')
for x in targets.keys():
dot.write(quote(x))
if x in failednode:
dot.write(' [color=red]')
elif x in almostfailed:
dot.write(' [color=blue]')
dot.write(';')
for arc in graph_small:
dot.write(quote(arc[0])+'->'+quote(arc[1]))
Expand All @@ -210,14 +219,28 @@ def dumpgraph(df):
logwrite(run)
os.system(run)

def copyfile(x,y):
xh=open(x,'r')
yh=open(y,'w')
yh.writelines(xh.readlines())
xh.close()
yh.close()

def extractall():
for bgf in sources.keys():
run = ' '.join(sources[bgf])+' bgf/'+bgf+'.bgf'
logwrite(run)
if os.system(run+shutup):
print 'Extraction failed on',bgf
failednode.append(bgf)
if os.access('snapshot/'+bgf+'.bgf',os.R_OK):
print 'Rolled back to the saved version, proceeding...'
copyfile('snapshot/'+bgf+'.bgf','bgf/'+bgf+'.bgf')
almostfailed.append(bgf)
else:
failednode.append(bgf)
#sysexit(3)
else:
copyfile('bgf/'+bgf+'.bgf','snapshot/'+bgf+'.bgf')
print 'Extraction finished.'

def validateall():
Expand Down Expand Up @@ -442,7 +465,7 @@ def checkconsistency():
#sysexit(8)

if __name__ == "__main__":
print 'Language Covergence Infrastructure v1.8'
print 'Language Covergence Infrastructure v1.9'
if len(sys.argv) == 3:
log = open(sys.argv[1].split('.')[0]+'.log','w')
readxmlconfig(sys.argv[1])
Expand All @@ -462,6 +485,7 @@ def checkconsistency():
dumpgraph(sys.argv[2])
#print failednode
#print failedarc
#print almostfailed
if failednode or failedarc:
sysexit(100)
log.close()
Expand Down

0 comments on commit cbfba73

Please sign in to comment.