3 import findrox
; findrox
.version(1, 9, 6)
4 from zeroinstall
.injector
.policy
import Policy
6 from rox
import g
, processes
, saving
7 from cStringIO
import StringIO
9 zero2bundle_uri
= "http://rox.sourceforge.net/2006/interfaces/Zero2Bundle.xml"
11 def try_interface(uri
):
13 launcher
= processes
.PipeThroughCommand(
14 ["0launch", "-d", "-g", "--", uri
],
18 except processes
.ChildError
, ex
:
19 if '(256)' not in str(ex
):
22 rox
.report_exception()
27 if len(sys
.argv
) == 1:
28 from chooser
import Chooser
33 if resp
!= g
.RESPONSE_OK
:
36 uri
= m
.uri
.get_text()
37 if try_interface(uri
):
40 elif len(sys
.argv
) == 2:
42 if not try_interface(uri
):
45 rox
.alert("Multiple arguments to Zero2Bundle (%s)!" % `sys
.argv
[1:]`
)
53 from bundle
import BundleMaker
55 maker
= BundleMaker(policy
)
56 default_name
= os
.path
.basename(uri
)
57 if default_name
.endswith('.xml'):
58 default_name
= default_name
[:-4]
59 box
= saving
.SaveBox(maker
, default_name
, 'inode/directory')
63 # Icon format must be PNG (to avoid attacks)
64 loader
= g
.gdk
.PixbufLoader('png')
66 loader
.write(file(maker
.icon
).read())
69 icon_pixbuf
= loader
.get_pixbuf()
71 print >>sys
.stderr
, "Failed to load cached PNG icon: %s" % ex
73 image
.set_from_pixbuf(icon_pixbuf
)
74 box
.set_type('inode/directory', image
)