10 #gc.set_debug(gc.DEBUG_LEAK)
15 print "(no GUI, but that's OK)"
17 from rox
import choices
, support
19 def error(message
, title
= 'Error'):
20 print "*********", title
22 support
.report_error
= error
25 #from xml.dom import ext
26 from Ft
.Xml
.Domlette
import PrettyPrint
28 from Model
import Model
29 from View
import View
, Done
, InProgress
30 from Program
import Program
, load_dome_program
32 if len(sys
.argv
) > 1 and sys
.argv
[1] == '--profile':
38 if len(sys
.argv
) > 1 and sys
.argv
[1] == '--xmlonly':
45 print "Usage: python nogui.py [--profile] [--xmlonly] <document>"
51 def __init__(self
, fn
):
54 def idle_add(function
):
55 new
= Callback(function
)
67 xml_data
= sys
.argv
[2]
70 model
= Model(source
, dome_data
= xml_data
)
72 view
= View(model
, callback_handlers
= (idle_add
, idle_remove
))
75 print "Starting root program of", source
80 view
.do_action(['play', model
.root_program
.name
])
88 for i
in idle_list
[:]:
97 profile
.run('run_nogui()')
102 raise Exception("Processing stopped in a chroot! -- not saving")
104 view
.model
.strip_space()
109 shutil
.copyfile(source
, source
+ '.bak')
110 doc
= view
.export_all()
111 PrettyPrint(doc
, stream
= open(source
, 'w'))
116 if source
[-5:] == '.dome':
117 output
= source
[:-5] + '.xml'
119 output
= source
+ '.xml'
120 PrettyPrint(view
.model
.doc
, stream
= open(output
+ '.new', 'w'))
123 os
.rename(output
+ '.new', output
)