1 from policy
import Policy
5 from reader
import InvalidInterface
6 from model
import SafeException
11 class GUIPolicy(Policy
):
16 def __init__(self
, interface
, prog_args
):
17 Policy
.__init
__(self
, interface
)
23 self
.window
= mainwindow
.MainWindow(prog_args
)
24 self
.window
.browser
.set_root(policy
.get_interface(policy
.root
))
26 def monitor_download(self
, dl
):
27 error_stream
= dl
.start()
28 def error_ready(src
, cond
):
29 got
= os
.read(src
.fileno(), 100)
33 if self
.n_downloads
== 0:
34 self
.window
.progress
.hide()
35 gtk
.timeout_remove(self
.pulse
)
38 data
= dl
.error_stream_closed()
39 self
.check_signed_data(dl
, data
)
40 except download
.DownloadError
, ex
:
41 dialog
.alert(self
.window
,
42 "Error downloading interface '%s':\n\n%s" %
43 (dl
.interface
.uri
, ex
))
44 except InvalidInterface
, ex
:
45 dialog
.alert(self
.window
,
46 "Syntax error in downloaded interface '%s':\n\n%s" %
47 (dl
.interface
.uri
, ex
))
48 except SafeException
, ex
:
49 dialog
.alert(self
.window
,
50 "Error updating interface '%s':\n\n%s" %
51 (dl
.interface
.uri
, ex
))
53 dl
.error_stream_data(got
)
56 gtk
.input_add(error_stream
, gtk
.gdk
.INPUT_READ
, error_ready
)
59 if self
.pulse
is None:
60 progress
= self
.window
.progress
61 self
.pulse
= gtk
.timeout_add(50, lambda: progress
.pulse() or True)
64 def confirm_trust_keys(self
, interface
, sigs
, iface_xml
):
66 trust_box
.trust_box
.confirm_trust(interface
, sigs
, iface_xml
)