3 import findrox
; findrox
.version(1, 9, 8)
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':
47 if len(sys
.argv
) > 1 and sys
.argv
[1] == '--leaks':
54 print "Usage: python nogui.py [--profile] [--xmlonly] [--leaks] <document>"
60 def __init__(self
, fn
):
63 def idle_add(function
):
64 new
= Callback(function
)
76 xml_data
= sys
.argv
[2]
81 print "Starting root program of", source
86 view
.do_action(['play', model
.root_program
.name
])
94 for i
in idle_list
[:]:
102 model
= Model(source
, dome_data
= xml_data
)
103 view
= View(model
, callback_handlers
= (idle_add
, idle_remove
))
107 print "First, run, to init everything..."
110 for x
in gc
.get_objects():
112 old_len
= len(gc
.get_objects())
114 print "Second run, to check for leaks"
116 for x
in gc
.get_objects():
120 for y
in gc
.get_referrers(x
):
121 if id(y
) in old
and y
is not globals():
122 print "\t%s" % `y`
[:60]
123 print "No. objects after first run:", old_len
124 print "No. objects after second run:", len(gc
.get_objects())
128 model
= Model(source
, dome_data
= xml_data
)
129 view
= View(model
, callback_handlers
= (idle_add
, idle_remove
))
134 profile
.run('run_nogui()')
139 raise Exception("Processing stopped in a chroot! -- not saving")
141 view
.model
.strip_space()
146 shutil
.copyfile(source
, source
+ '.bak')
147 doc
= view
.export_all()
148 PrettyPrint(doc
, stream
= open(source
, 'w'))
153 if source
[-5:] == '.dome':
154 output
= source
[:-5] + '.xml'
156 output
= source
+ '.xml'
157 PrettyPrint(view
.model
.doc
, stream
= open(output
+ '.new', 'w'))
160 os
.rename(output
+ '.new', output
)