10 #gc.set_debug(gc.DEBUG_LEAK)
15 print "(no GUI, but that's OK)"
18 from rox
import choices
20 def error(message
, title
= 'Error'):
21 print "*********", title
23 rox
.report_error
= error
25 rox
.report_exception
= exc
28 #from xml.dom import ext
29 from Ft
.Xml
.Domlette
import PrettyPrint
31 from Model
import Model
32 from View
import View
, Done
, InProgress
33 from Program
import Program
, load_dome_program
35 if len(sys
.argv
) > 1 and sys
.argv
[1] == '--profile':
41 if len(sys
.argv
) > 1 and sys
.argv
[1] == '--xmlonly':
48 print "Usage: python nogui.py [--profile] [--xmlonly] <document>"
54 def __init__(self
, fn
):
57 def idle_add(function
):
58 new
= Callback(function
)
70 xml_data
= sys
.argv
[2]
73 model
= Model(source
, dome_data
= xml_data
)
75 view
= View(model
, callback_handlers
= (idle_add
, idle_remove
))
78 print "Starting root program of", source
83 view
.do_action(['play', model
.root_program
.name
])
91 for i
in idle_list
[:]:
100 profile
.run('run_nogui()')
105 raise Exception("Processing stopped in a chroot! -- not saving")
107 view
.model
.strip_space()
112 shutil
.copyfile(source
, source
+ '.bak')
113 doc
= view
.export_all()
114 PrettyPrint(doc
, stream
= open(source
, 'w'))
119 if source
[-5:] == '.dome':
120 output
= source
[:-5] + '.xml'
122 output
= source
+ '.xml'
123 PrettyPrint(view
.model
.doc
, stream
= open(output
+ '.new', 'w'))
126 os
.rename(output
+ '.new', output
)