28
def run_scope(scope_class, args=None):
29
if args and len(args) > 1 and args[1] == 'make':
30
build_scope_files(scope_class, args)
31
elif args and len(args) > 1 and args[1] == 'install':
32
install_scope_files(scope_class, args)
33
#elif args and len(args) > 1 and args[1] == 'uninstall':
34
#uninstall_lens_files(lens_class, args)
35
#elif args and len(args) > 1 and args[1] == 'package':
36
#build_package_files(lens_class, args)
37
#elif args and len(args) > 1 and args[1] == 'release':
38
#build_release_files(lens_class, args)
40
run_scope_daemon(scope_class)
42
28
def run_lens(lens_class, args=None):
43
if args and len(args) > 1 and args[1] == 'make':
44
build_lens_files(lens_class, args)
45
elif args and len(args) > 1 and args[1] == 'install':
46
install_lens_files(lens_class, args)
47
elif args and len(args) > 1 and args[1] == 'uninstall':
48
uninstall_lens_files(lens_class, args)
49
elif args and len(args) > 1 and args[1] == 'package':
50
build_package_files(lens_class, args)
51
elif args and len(args) > 1 and args[1] == 'release':
52
build_release_files(lens_class, args)
54
run_lens_daemon(lens_class)
56
def build_lens_files(lens_class, args):
57
service_file = open('./unity-%s-lens.service' % lens_class._meta.name, 'w')
58
service_file.write('''[D-BUS Service]
60
Exec=/usr/lib/singlet/%s
61
''' % (lens_class._meta.bus_name, args[0]))
64
lens_file = open('./%s.lens' % lens_class._meta.name, 'w')
65
lens_file.write('''[Lens]
69
Icon=/usr/share/unity/lenses/%(name)s/%(icon_name)s
70
Description=%(description)s
71
SearchHint=%(search_hint)s
75
X-Ubuntu-Gettext-Domain=%(name)s
77
'name': lens_class._meta.name,
78
'title': lens_class._meta.title,
79
'description': lens_class._meta.description,
80
'search_hint': lens_class._meta.search_hint,
81
'icon_name': os.path.basename(lens_class._meta.icon),
82
'bus_path': lens_class._meta.bus_path,
83
'bus_name': lens_class._meta.bus_name })
86
def build_scope_files(scope_class, args):
87
service_file = open('./unity-%s-scope.service' % scope_class._meta.name, 'w')
88
service_file.write('''[D-BUS Service]
90
Exec=/usr/lib/singlet/%s
91
''' % (scope_class._meta.bus_name, args[0]))
94
scope_file = open('./%s.scope' % scope_class._meta.name, 'w')
95
scope_file.write('''[Scope]
99
Description=%(description)s
102
X-Ubuntu-Gettext-Domain=%(name)s
104
'name': scope_class._meta.name,
105
'title': scope_class._meta.title,
106
'description': scope_class._meta.description,
107
'bus_path': scope_class._meta.bus_path,
108
'bus_name': scope_class._meta.bus_name })
111
def install_lens_files(lens_class, args):
112
if not os.path.exists('/usr/share/unity/lenses/%s' % lens_class._meta.name):
113
os.mkdir('/usr/share/unity/lenses/%s' % lens_class._meta.name)
114
shutil.copy('./unity-%s-lens.service' % lens_class._meta.name, '/usr/share/dbus-1/services/')
115
shutil.copy('./%s.lens' % lens_class._meta.name, '/usr/share/unity/lenses/%s' % lens_class._meta.name)
116
shutil.copy(lens_class._meta.icon, '/usr/share/unity/lenses/%s' % lens_class._meta.name)
118
if not os.path.exists('/usr/lib/singlet'):
119
os.mkdir('/usr/lib/singlet')
120
shutil.copy(args[0], '/usr/lib/singlet/')
122
def uninstall_lens_files(lens_class, args):
123
os.remove(os.path.join('/usr/share/dbus-1/services/', 'unity-%s-lens.service' % lens_class._meta.name))
124
os.remove(os.path.join('/usr/share/unity/lenses/%s' % lens_class._meta.name, '%s.lens' % lens_class._meta.name))
125
os.remove(os.path.join('/usr/share/unity/lenses/%s' % lens_class._meta.name, os.path.basename(lens_class._meta.icon)))
126
os.rmdir('/usr/share/unity/lenses/%s' % lens_class._meta.name)
128
os.remove(os.path.join('/usr/lib/singlet/', args[0]))
130
def install_scope_files(scope_class, args):
131
if not os.path.exists('/usr/share/unity/lenses/%s' % scope_class._meta.lens_name):
132
os.mkdir('/usr/share/unity/lenses/%s' % scope_class._meta.lens_name)
133
shutil.copy('./unity-%s-scope.service' % scope_class._meta.name, '/usr/share/dbus-1/services/')
134
shutil.copy('./%s.scope' % scope_class._meta.name, '/usr/share/unity/lenses/%s' % scope_class._meta.lens_name)
136
if not os.path.exists('/usr/lib/singlet'):
137
os.mkdir('/usr/lib/singlet')
138
shutil.copy(args[0], '/usr/lib/singlet/')
140
def uninstall_scope_files(scope_class, args):
141
os.remove(os.path.join('/usr/share/dbus-1/services/', 'unity-%s-scope.service' % scope_class._meta.lens_name))
142
os.remove(os.path.join('/usr/share/unity/lenses/%s' % scope_class._meta.lens_name, '%s.scope' % scope_class._meta.name))
144
os.remove(os.path.join('/usr/lib/singlet/', args[0]))
146
def build_package_files(lens_class, args):
147
setup_file = open('./setup.py', 'w')
148
setup_file.write('''#!/usr/bin/env python
150
from distutils.core import setup
152
setup(name='unity-%(name)s-lens',
154
description='%(description)s',
155
author='%(debfullname)s',
156
author_email='%(debemail)s',
158
url='http://launchpad.net/singlet',
159
#requires=['unity-singlet (>=%(version)s)'],
162
'name': lens_class._meta.name,
163
'description': lens_class._meta.description,
164
'debfullname': os.environ.get('DEBFULLNAME', 'Add your name here'),
165
'debemail': os.environ.get('DEBEMAIL', 'Add your email here'),
166
'version': singlet.__version__})
169
subprocess.call(['python-mkdebian','--dependency=unity-singlet (>= %s)' % singlet.__version__,'--dependency=unity'])
171
def release_package_files(lens_class, args):
174
def run_lens_daemon(lens_class):
175
29
session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
176
30
session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
177
31
'org.freedesktop.DBus',