3 from xml
.dom
import minidom
5 class AppLauncher(saving
.Saveable
):
6 def __init__(self
, uri
, icon
):
10 def save_to_file(self
, path
):
12 assert "'" not in self
.uri
13 apprun
= os
.fdopen(os
.open(os
.path
.join(path
, 'AppRun'), os
.O_CREAT | os
.O_WRONLY
, 0777), 'w')
14 if self
.uri
== 'http://rox.sourceforge.net/2005/interfaces/AddApp':
15 # Funky special case: AddApp behaves differently when run through AppRun
16 apprun
.write("""#!/bin/sh
17 if [ "$*" = "--versions" ]; then
18 exec 0launch -gd '%s' "$@"
19 elif [ "$*" = "" ]; then
20 exec 0launch '%s' --prompt
22 exec 0launch '%s' "$@"
23 fi""" % (self
.uri
, self
.uri
, self
.uri
))
25 apprun
.write("""#!/bin/sh
26 if [ "$*" = "--versions" ]; then
27 exec 0launch -gd '%s' "$@"
29 exec 0launch '%s' "$@"
30 fi""" % (self
.uri
, self
.uri
))
34 shutil
.copyfile(self
.icon
.name
, os
.path
.join(path
, '.DirIcon'))
36 doc
= minidom
.parseString("""<?xml version="1.0"?>
39 <Item option='--versions'>
40 <Label xml:lang="en">Versions...</Label>
45 info_file
= file(os
.path
.join(path
, 'AppInfo.xml'), 'w')
46 doc
.writexml(info_file
)