|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
1 |
#!/usr/bin/python
|
2 |
# Mythbuntu Live CD Session Startup Script
|
|
|
8
by Mario Limonciello
fix line wrapping in man page |
3 |
# Copyright (C) 2007, Mario Limonciello <superm1@mythbuntu.org>
|
|
5
by Mario Limonciello
add upstream changelog, and licensing preambles |
4 |
#
|
5 |
#
|
|
|
13
by Mario Limonciello
add command line behavior |
6 |
# Exit error codes:
|
7 |
# 0: normal exit
|
|
8 |
# 1: permissions error
|
|
9 |
# 2: --help called
|
|
10 |
# 3: didn't find file
|
|
11 |
#
|
|
12 |
#
|
|
|
5
by Mario Limonciello
add upstream changelog, and licensing preambles |
13 |
# This program is free software; you can redistribute it and/or modify
|
14 |
# it under the terms of the GNU General Public License as published by
|
|
15 |
# the Free Software Foundation; either version 3 of the License, or
|
|
16 |
# (at your option) any later version.
|
|
17 |
#
|
|
18 |
# This program is distributed in the hope that it will be useful,
|
|
19 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 |
# GNU General Public License for more details.
|
|
22 |
#
|
|
23 |
# You should have received a copy of the GNU General Public License
|
|
24 |
# along with this program; if not, write to the Free Software
|
|
25 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
26 |
||
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
27 |
|
|
9
by Mario Limonciello
first variation of the glade addon. |
28 |
#Text backend requirements
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
29 |
import os |
|
15
by Mario Limonciello
add proper support for changing users and groups |
30 |
import subprocess |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
31 |
import sys |
|
15
by Mario Limonciello
add proper support for changing users and groups |
32 |
import string |
33 |
import stat |
|
|
17
by Mario Limonciello
add basic lirc support |
34 |
import shutil |
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
35 |
import debconf |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
36 |
import ConfigParser |
37 |
||
|
9
by Mario Limonciello
first variation of the glade addon. |
38 |
#Gui requirements
|
39 |
import pygtk |
|
40 |
pygtk.require('2.0') |
|
|
10
by Mario Limonciello
rearrange gui. |
41 |
import gtk.glade |
|
9
by Mario Limonciello
first variation of the glade addon. |
42 |
import MySQLdb |
|
17
by Mario Limonciello
add basic lirc support |
43 |
import re |
|
9
by Mario Limonciello
first variation of the glade addon. |
44 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
45 |
RELEASE="7.10" |
46 |
||
|
9
by Mario Limonciello
first variation of the glade addon. |
47 |
# Define global path
|
|
14
by Mario Limonciello
update debian/* documentation |
48 |
PATH = '/usr/share/mythbuntu' |
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
49 |
#PATH = '/home/supermario/Software/source/mythbuntu/mythbuntu-live-autostart/mythbuntu-live-autostart-0.22'
|
|
9
by Mario Limonciello
first variation of the glade addon. |
50 |
|
51 |
||
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
52 |
class MythbuntuStartup(): |
53 |
def __init__(self): |
|
|
9
by Mario Limonciello
first variation of the glade addon. |
54 |
#initialize text backend
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
55 |
self.configfile = None |
56 |
self.config = ConfigParser.ConfigParser() |
|
57 |
self.config.add_section("mythbuntu") |
|
|
9
by Mario Limonciello
first variation of the glade addon. |
58 |
#initialize gui
|
59 |
self.glade = gtk.glade.XML(PATH + '/mythbuntu_live_autostart.glade') |
|
|
11
by Mario Limonciello
gui is 90% active now. |
60 |
self.glade.signal_autoconnect(self) |
61 |
for widget in self.glade.get_widget_prefix(""): |
|
62 |
setattr(self, widget.get_name(), widget) |
|
63 |
if isinstance(widget, gtk.Label): |
|
64 |
widget.set_property('can-focus', False) |
|
65 |
#for some reason, that above initialization doesn't catch the about
|
|
66 |
#dialog, so we need to manually do it too
|
|
67 |
setattr(self, "about_dialog", self.glade.get_widget("about_dialog")) |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
68 |
debconf.runFrontEnd() |
|
19
by Mario Limonciello
fix more debconf toys |
69 |
self.db = debconf.Debconf() |
|
11
by Mario Limonciello
gui is 90% active now. |
70 |
|
71 |
def find_configuration(self): |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
72 |
"""Finds a mythbuntu configuration file"""
|
73 |
directories = [ x for x in os.listdir('/media') if not x.startswith('.')] |
|
74 |
for directory in directories: |
|
75 |
files = os.listdir(os.path.join('/media', directory)) |
|
76 |
for file in files: |
|
77 |
if file == 'mythbuntu_configuration.ini': |
|
78 |
self.configfile=os.path.join('/media/', directory, file) |
|
79 |
return True |
|
80 |
return False |
|
81 |
||
82 |
def load_configuration(self): |
|
83 |
"""Parses a mythbuntu configuration file"""
|
|
84 |
file_name = open(self.configfile, "r") |
|
85 |
self.config.readfp(file_name) |
|
86 |
file_name.close() |
|
87 |
||
|
12
by Mario Limonciello
add support for samba user name and password |
88 |
def check_autostart(self): |
89 |
"""Determines whether we want to automatically start"""
|
|
90 |
if self.config.has_option("mythbuntu", "autostart"): |
|
91 |
if self.config.get("mythbuntu", "autostart") == "True": |
|
92 |
return True |
|
93 |
return False |
|
94 |
||
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
95 |
def print_configuration(self): |
96 |
"""Outputs everything parsed from a configuration"""
|
|
97 |
print "Found a configuration @: " + self.configfile |
|
98 |
print " Version: " + self.config.get("mythbuntu", "version") |
|
|
11
by Mario Limonciello
gui is 90% active now. |
99 |
print " Automatically Start: " + self.config.get("mythbuntu", "autostart") |
100 |
print " Use External Home Directory: " + self.config.get("mythbuntu", "externalhome") |
|
|
17
by Mario Limonciello
add basic lirc support |
101 |
print " Remote Control Enabled: " + self.config.get("mythbuntu", "remote_en") |
102 |
print " Remote Control: " + self.config.get("mythbuntu", "remotecontrol") |
|
103 |
print " Remote Driver: " + self.config.get("mythbuntu", "remotedriver") |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
104 |
print " Remote Module(s): " + self.config.get("mythbuntu", "remotemodules") |
|
17
by Mario Limonciello
add basic lirc support |
105 |
print " Remote Config: " + self.config.get("mythbuntu", "remoteconfig") |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
106 |
print " Hostname: "+ self.config.get("mythbuntu", "hostname") |
107 |
print " MySQL User Name: "+ self.config.get("mythbuntu", "mysql_user") |
|
108 |
print " MySQL Password: "+ self.config.get("mythbuntu", "mysql_pass") |
|
109 |
print " MySQL Database: "+ self.config.get("mythbuntu", "mysql_db") |
|
110 |
print " MySQL Hostname: "+ self.config.get("mythbuntu", "mysql_host") |
|
111 |
print " Video Mount: "+ self.config.get("mythbuntu", "videos_type") |
|
112 |
print " Video Server: "+ self.config.get("mythbuntu", "videos_server") |
|
113 |
print " Video Path: "+ self.config.get("mythbuntu", "videos_path") |
|
|
11
by Mario Limonciello
gui is 90% active now. |
114 |
print " Video Share Authentiation: "+ self.config.get("mythbuntu", "videos_auth") |
115 |
print " Video User: "+ self.config.get("mythbuntu", "videos_user") |
|
116 |
print " Video Pass: "+ self.config.get("mythbuntu", "videos_pass") |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
117 |
print " Pictures Mount: "+ self.config.get("mythbuntu", "pictures_type") |
118 |
print " Pictures Server: "+ self.config.get("mythbuntu", "pictures_server") |
|
119 |
print " Pictures Path: "+ self.config.get("mythbuntu", "pictures_path") |
|
|
11
by Mario Limonciello
gui is 90% active now. |
120 |
print " Pictures Share Authentiation: "+ self.config.get("mythbuntu", "pictures_auth") |
121 |
print " Pictures Share User: "+ self.config.get("mythbuntu", "pictures_user") |
|
122 |
print " Pictures Share Pass: "+ self.config.get("mythbuntu", "pictures_pass") |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
123 |
print " Music Mount: "+ self.config.get("mythbuntu", "music_type") |
124 |
print " Music Server: "+ self.config.get("mythbuntu", "music_server") |
|
125 |
print " Music Path: "+ self.config.get("mythbuntu", "music_path") |
|
|
11
by Mario Limonciello
gui is 90% active now. |
126 |
print " Music Share Authentication: "+ self.config.get("mythbuntu", "music_auth") |
127 |
print " Music Share User: "+ self.config.get("mythbuntu", "music_user") |
|
128 |
print " Music Share Pass: "+ self.config.get("mythbuntu", "music_pass") |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
129 |
|
130 |
def process_master_backend_info(self): |
|
131 |
"""Sets up the info to contact the master backend for the box"""
|
|
132 |
if self.config.has_option("mythbuntu", "mysql_user") and \ |
|
133 |
self.config.has_option("mythbuntu", "mysql_pass") and \ |
|
134 |
self.config.has_option("mythbuntu", "mysql_db") and \ |
|
135 |
self.config.has_option("mythbuntu", "mysql_host"): |
|
|
19
by Mario Limonciello
fix more debconf toys |
136 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
137 |
#Read new settings
|
138 |
user = self.config.get("mythbuntu", "mysql_user") |
|
139 |
passwd = self.config.get("mythbuntu", "mysql_pass") |
|
140 |
database = self.config.get("mythbuntu", "mysql_db") |
|
141 |
host = self.config.get("mythbuntu", "mysql_host") |
|
|
19
by Mario Limonciello
fix more debconf toys |
142 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
143 |
#Update Debconf
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
144 |
self.db.set("mythtv/mysql_mythtv_user", user) |
145 |
self.db.set("mythtv/mysql_mythtv_password", passwd) |
|
146 |
self.db.set("mythtv/mysql_mythtv_dbname", database) |
|
147 |
self.db.set("mythtv/mysql_host", host) |
|
|
19
by Mario Limonciello
fix more debconf toys |
148 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
149 |
#Update /etc/mythtv/mysql.txt
|
150 |
out_f = open("/etc/mythtv/mysql.txt", "w") |
|
|
15
by Mario Limonciello
add proper support for changing users and groups |
151 |
out_f.write("DBHostName=" + host + "\n") |
152 |
out_f.write("DBUserName=" + user + "\n") |
|
153 |
out_f.write("DBName=" + database + "\n") |
|
154 |
out_f.write("DBPassword=" + passwd + "\n") |
|
|
9
by Mario Limonciello
first variation of the glade addon. |
155 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
156 |
def start_frontend(self): |
157 |
"""Starts the frontend"""
|
|
|
12
by Mario Limonciello
add support for samba user name and password |
158 |
newhome=os.getenv('HOME') |
159 |
if self.config.has_option("mythbuntu","externalhome") and \ |
|
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
160 |
self.config.get("mythbuntu", "externalhome") == "True" and \ |
161 |
self.configfile != None: |
|
|
12
by Mario Limonciello
add support for samba user name and password |
162 |
newhome=os.path.split(self.configfile)[0] |
163 |
os.putenv('HOME',newhome) |
|
|
16
by Mario Limonciello
better live frontend startup handling |
164 |
#Disable permission changing for now. It doesn't get along well with autostart
|
165 |
#os.chown(newhome,int(os.getenv('SUDO_UID')),int(os.getenv('SUDO_GID')))
|
|
166 |
#existing_permissions = stat.S_IMODE(os.stat(newhome).st_mode)
|
|
167 |
#new_permissions = existing_permissions | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
|
|
168 |
#os.chmod(newhome,new_permissions)
|
|
169 |
login=os.getenv('USERNAME') |
|
|
15
by Mario Limonciello
add proper support for changing users and groups |
170 |
groups=string.split(subprocess.Popen(["id","-G", login], stdout=subprocess.PIPE).communicate()[0]) |
171 |
mapped_groups = map(lambda x: int(x), groups) |
|
172 |
os.setgroups(mapped_groups) |
|
173 |
os.setgid(int(os.getenv('SUDO_GID'))) |
|
174 |
os.setuid(int(os.getenv('SUDO_UID'))) |
|
175 |
start_command = "mythfrontend.real --logfile " + newhome + "/mythfrontend.log" |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
176 |
if os.system(start_command) != 0: |
177 |
print "Unable to start frontend via " + start_command |
|
178 |
||
179 |
def process_hostname(self): |
|
180 |
"""Sets the new hostname for the box"""
|
|
181 |
if self.config.has_option("mythbuntu", "hostname"): |
|
182 |
#bad hack for now.
|
|
|
12
by Mario Limonciello
add support for samba user name and password |
183 |
permissions_command = "xhost + > /dev/null" |
184 |
host_command = "hostname " + self.config.get("mythbuntu", "hostname") |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
185 |
os.system(permissions_command) |
186 |
os.system(host_command) |
|
187 |
||
|
17
by Mario Limonciello
add basic lirc support |
188 |
def process_remote(self): |
189 |
"""Processes the remote control that we have chosen"""
|
|
190 |
if self.config.has_option("mythbuntu", "remote_en") and \ |
|
191 |
self.config.has_option("mythbuntu", "remotecontrol") and \ |
|
192 |
self.config.has_option("mythbuntu", "remotedriver") and \ |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
193 |
self.config.has_option("mythbuntu", "remotemodules") and \ |
|
17
by Mario Limonciello
add basic lirc support |
194 |
self.config.has_option("mythbuntu", "remoteconfig"): |
195 |
if self.config.get("mythbuntu", "remote_en") == "True": |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
196 |
|
197 |
#Get settings from config
|
|
198 |
remote=self.config.get("mythbuntu", "remotecontrol") |
|
199 |
if remote == "(No Remote Selected)": |
|
200 |
driver="" |
|
201 |
modules="" |
|
202 |
config="" |
|
203 |
else: |
|
204 |
modules=self.config.get("mythbuntu", "remotemodules") |
|
205 |
if modules == "none": |
|
206 |
modules="" |
|
207 |
driver=self.config.get("mythbuntu", "remotedriver") |
|
208 |
p1 = subprocess.Popen(["lircd","-H","help"], stderr=subprocess.PIPE) |
|
209 |
p2 = subprocess.Popen(["awk", "$0!~/^S|^D/{print $1}"], stdin=p1.stderr, stdout=subprocess.PIPE) |
|
210 |
p3 = subprocess.Popen(["tr", "'\\n'", "'\ '"],stdin=p2.stdout, stdout=subprocess.PIPE) |
|
211 |
supporteddrivers=p3.communicate()[0] |
|
|
19
by Mario Limonciello
fix more debconf toys |
212 |
pattern=re.compile(driver) |
213 |
if pattern.search(supporteddrivers) is None: |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
214 |
driver="" |
215 |
config=self.config.get("mythbuntu", "remoteconfig") |
|
216 |
||
217 |
#Put this info into debconf
|
|
218 |
self.db.set("lirc/remote", remote) |
|
219 |
self.db.set("lirc/modules", modules) |
|
220 |
self.db.set("lirc/lircd_conf", config) |
|
221 |
self.db.set("lirc/driver", driver) |
|
|
19
by Mario Limonciello
fix more debconf toys |
222 |
self.db.set("lirc/modules", modules) |
223 |
||
224 |
#copy over configuration
|
|
225 |
if config != "": |
|
226 |
shutil.copy('/usr/share/lirc/remotes/' + config, '/etc/lirc/lircd.conf') |
|
227 |
||
228 |
#Set up hardware.conf
|
|
229 |
in_f = open("/etc/lirc/hardware.conf") |
|
230 |
out_f = open("/etc/lirc/hardware.conf.new", 'w') |
|
231 |
patternline="^MODULES" |
|
232 |
patternline+="|^DRIVER" |
|
233 |
patternline+="|^LIRCD_CONF" |
|
234 |
pattern=re.compile(patternline) |
|
235 |
found_modules=False |
|
236 |
found_driver=False |
|
237 |
found_lircd_conf=False |
|
238 |
for line in in_f: |
|
239 |
if pattern.search(line) is None: |
|
240 |
out_f.write(line) |
|
241 |
else: |
|
242 |
if not found_modules and re.compile("MODULES").search(line): |
|
243 |
out_f.write("MODULES=\"" + modules + "\"\n") |
|
244 |
found_modules = True |
|
245 |
elif not found_driver and re.compile("DRIVER").search(line): |
|
246 |
out_f.write("DRIVER=\"" + driver + "\"\n") |
|
247 |
found_driver = True |
|
248 |
elif not found_lircd_conf and re.compile("LIRCD_CONF").search(line): |
|
249 |
out_f.write("LIRCD_CONF=\"" + config + "\"\n") |
|
250 |
found_lircd_conf = True |
|
251 |
if not found_modules: |
|
252 |
out_f.write("MODULES=\"" + modules + "\"\n") |
|
253 |
if not found_driver: |
|
254 |
out_f.write("DRIVER=\"" + driver + "\"\n") |
|
255 |
if not found_lircd_conf: |
|
256 |
out_f.write("LIRCD_CONF=\"" + config + "\"\n") |
|
257 |
in_f.close() |
|
258 |
out_f.close() |
|
259 |
shutil.move("/etc/lirc/hardware.conf.new", "/etc/lirc/hardware.conf") |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
260 |
|
261 |
#Apply settings and restart lirc
|
|
|
19
by Mario Limonciello
fix more debconf toys |
262 |
#os.system('invoke-rc.d lirc restart')
|
263 |
start_lirc = subprocess.Popen(["invoke-rc.d", "lirc", "restart"],stdout=subprocess.PIPE).communicate()[0] |
|
264 |
print start_lirc |
|
|
17
by Mario Limonciello
add basic lirc support |
265 |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
266 |
##Create a Lircrc in the right place##
|
267 |
||
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
268 |
#Check and see if we have one in $HOME. If not, make one there.
|
269 |
#We might not use it, but it doesn't hurt to have
|
|
270 |
if not os.path.exists(os.getenv('HOME') + '/.lircrc'): |
|
271 |
generate_command="mythbuntu-lircrc-generator --lircd /etc/lirc/lircd.conf" |
|
|
19
by Mario Limonciello
fix more debconf toys |
272 |
if os.path.exists('/usr/bin/mythbuntu-lircrc-generator'): |
273 |
os.system(generate_command) |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
274 |
|
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
275 |
#create the .mythtv directory.
|
276 |
#Again, not a big deal if we don't use it
|
|
277 |
if not os.path.exists(os.getenv('HOME') + '/.mythtv'): |
|
278 |
os.mkdir(os.getenv('HOME') + '/.mythtv') |
|
279 |
os.chmod(os.getenv('HOME') + '/.mythtv', int('777',8)) |
|
280 |
||
281 |
#Find the external path (of course only present if
|
|
282 |
#we have saved so far)
|
|
283 |
if self.configfile != None: |
|
284 |
newhome=os.path.split(self.configfile)[0] |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
285 |
else: |
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
286 |
newhome=os.getenv('HOME') |
287 |
||
288 |
#copy over possible existing config if we are not using an external home
|
|
289 |
#or we haven't defined an external home yet
|
|
290 |
if (self.config.has_option("mythbuntu","externalhome") and \ |
|
291 |
self.config.get("mythbuntu", "externalhome") == "False"): |
|
292 |
||
293 |
#check if we are working in the same home (eg hasn't been saved)
|
|
294 |
#otherwise copy over a possibly existing .lircrc
|
|
295 |
if newhome != os.getenv('HOME'): |
|
296 |
if os.path.exists(newhome + '/.lircrc'): |
|
297 |
shutil.copy(newhome + '/.lircrc', os.getenv('HOME')) |
|
|
21
by Mario Limonciello
minor typo |
298 |
if os.path.exists(newhome + '/.mythtv/lircrc'): |
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
299 |
shutil.copy(newhome + '/.mythtv/lircrc', os.getenv('HOME') + '/.mythtv') |
300 |
||
301 |
elif self.configfile != None: |
|
302 |
||
|
19
by Mario Limonciello
fix more debconf toys |
303 |
#create the .mythtv directory
|
304 |
if not os.path.exists(newhome + '/.mythtv'): |
|
305 |
os.mkdir(newhome + '/.mythtv') |
|
306 |
os.chmod(newhome + '/.mythtv', int('777',8)) |
|
|
20
by Mario Limonciello
add dependency to mythbuntu-lirc-generator |
307 |
|
308 |
#copy config if we dont already have one
|
|
309 |
if not os.path.exists(newhome + '/.lircrc'): |
|
310 |
shutil.copy(os.getenv('HOME') + '/.lircrc', newhome + '/.lircrc') |
|
311 |
if not os.path.exists(newhome + '/.mythtv/lircrc'): |
|
312 |
shutil.copy(os.getenv('HOME') + '/.mythtv/lircrc', newhome + '/.mythtv') |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
313 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
314 |
def process_mountpoints(self): |
315 |
"""Processes all required mount options per the configuration file"""
|
|
316 |
def mount_nfs(server, path, target): |
|
317 |
"""Mounts via NFS at target"""
|
|
|
12
by Mario Limonciello
add support for samba user name and password |
318 |
mount_command = "mount " + server + ":" + path + " " + target |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
319 |
os.system(mount_command) |
320 |
||
|
12
by Mario Limonciello
add support for samba user name and password |
321 |
def mount_samba(server, path, target, auth=False, username=None, password=None): |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
322 |
"""Mounts via SMB at target"""
|
|
12
by Mario Limonciello
add support for samba user name and password |
323 |
if auth: |
324 |
mount_command = "mount " + "-o guest,user=" + username + ",password=" + password + "-t smbfs //" + server + "/" + path + " " + target |
|
325 |
else: |
|
326 |
mount_command = "mount " + "-o guest -t smbfs //" + server + "/" + path + " " + target |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
327 |
os.system(mount_command) |
328 |
||
329 |
#Videos
|
|
330 |
if self.config.has_option("mythbuntu", "videos_type") and \ |
|
331 |
self.config.has_option("mythbuntu", "videos_server") and \ |
|
332 |
self.config.has_option("mythbuntu", "videos_path"): |
|
333 |
if self.config.get("mythbuntu", "videos_type") == "NFS": |
|
334 |
mount_nfs(self.config.get("mythbuntu", "videos_server"), self.config.get("mythbuntu", "videos_path"), '/var/lib/mythtv/videos') |
|
335 |
elif self.config.get("mythbuntu", "videos_type") == "SMB": |
|
|
12
by Mario Limonciello
add support for samba user name and password |
336 |
if self.config.has_option("mythbuntu", "videos_auth") and \ |
337 |
self.config.has_option("mythbuntu", "videos_user") and \ |
|
338 |
self.config.has_option("mythbuntu", "videos_pass"): |
|
339 |
if self.config.get("mythbuntu","videos_auth") == "True": |
|
340 |
mount_samba(self.config.get("mythbuntu", "videos_server"), self.config.get("mythbuntu", "videos_path"), '/var/lib/mythtv/videos', True, self.config.get("mythbuntu", "videos_user"), self.config.get("mythbuntu", "videos_pass")) |
|
341 |
else: |
|
342 |
mount_samba(self.config.get("mythbuntu", "videos_server"), self.config.get("mythbuntu", "videos_path"), '/var/lib/mythtv/videos') |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
343 |
|
344 |
#Pictures
|
|
345 |
if self.config.has_option("mythbuntu", "pictures_type") and \ |
|
346 |
self.config.has_option("mythbuntu", "pictures_server") and \ |
|
347 |
self.config.has_option("mythbuntu", "pictures_path"): |
|
348 |
if self.config.get("mythbuntu", "pictures_type") == "NFS": |
|
349 |
mount_nfs(self.config.get("mythbuntu", "pictures_server"), self.config.get("mythbuntu", "pictures_path"), '/var/lib/mythtv/pictures') |
|
350 |
elif self.config.get("mythbuntu", "pictures_type") == "SMB": |
|
|
12
by Mario Limonciello
add support for samba user name and password |
351 |
if self.config.has_option("mythbuntu", "pictures_auth") and \ |
352 |
self.config.has_option("mythbuntu", "pictures_user") and \ |
|
353 |
self.config.has_option("mythbuntu", "pictures_pass"): |
|
354 |
if self.config.get("mythbuntu","pictures_auth") == "True": |
|
355 |
mount_samba(self.config.get("mythbuntu", "pictures_server"), self.config.get("mythbuntu", "pictures_path"), '/var/lib/mythtv/pictures', True, self.config.get("mythbuntu", "pictures_user"), self.config.get("mythbuntu", "pictures_pass")) |
|
356 |
else: |
|
357 |
mount_samba(self.config.get("mythbuntu", "pictures_server"), self.config.get("mythbuntu", "pictures_path"), '/var/lib/mythtv/pictures') |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
358 |
|
359 |
#Music
|
|
360 |
if self.config.has_option("mythbuntu", "music_type") and \ |
|
361 |
self.config.has_option("mythbuntu", "music_server") and \ |
|
362 |
self.config.has_option("mythbuntu", "music_path"): |
|
363 |
if self.config.get("mythbuntu", "music_type") == "NFS": |
|
364 |
mount_nfs(self.config.get("mythbuntu", "music_server"), self.config.get("mythbuntu", "music_path"), '/var/lib/mythtv/music') |
|
365 |
elif self.config.get("mythbuntu", "music_type") == "SMB": |
|
|
12
by Mario Limonciello
add support for samba user name and password |
366 |
if self.config.has_option("mythbuntu", "music_auth") and \ |
367 |
self.config.has_option("mythbuntu", "music_user") and \ |
|
368 |
self.config.has_option("mythbuntu", "music_pass"): |
|
369 |
if self.config.get("mythbuntu","music_auth") == "True": |
|
370 |
mount_samba(self.config.get("mythbuntu", "music_server"), self.config.get("mythbuntu", "music_path"), '/var/lib/mythtv/music', True, self.config.get("mythbuntu", "music_user"), self.config.get("mythbuntu", "music_pass")) |
|
371 |
else: |
|
372 |
mount_samba(self.config.get("mythbuntu", "music_server"), self.config.get("mythbuntu", "music_path"), '/var/lib/mythtv/music') |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
373 |
|
|
11
by Mario Limonciello
gui is 90% active now. |
374 |
#Callback handlers
|
375 |
def run(self): |
|
376 |
"""Runs the PyGTK gui for the user"""
|
|
|
17
by Mario Limonciello
add basic lirc support |
377 |
#We only want to take the time to load into the gui and load the lirc db
|
|
11
by Mario Limonciello
gui is 90% active now. |
378 |
#If we are showing the gui
|
|
17
by Mario Limonciello
add basic lirc support |
379 |
self.populate_lirc() |
|
19
by Mario Limonciello
fix more debconf toys |
380 |
self.clear_settings() |
|
11
by Mario Limonciello
gui is 90% active now. |
381 |
self.load_configuration_gui() |
382 |
self.main_window.show() |
|
383 |
gtk.main() |
|
384 |
||
385 |
def connection_test(self,widget): |
|
386 |
"""Tests to make sure that the backend is accessible"""
|
|
387 |
host = self.mysql_server.get_text() |
|
388 |
database = self.mysql_database.get_text() |
|
389 |
user = self.mysql_user.get_text() |
|
390 |
password = self.mysql_pass.get_text() |
|
391 |
try: |
|
392 |
db = MySQLdb.connect(host=host, user=user, passwd=password,db=database) |
|
393 |
cursor = db.cursor() |
|
394 |
cursor.execute("SELECT NULL") |
|
395 |
result = cursor.fetchone() |
|
396 |
cursor.close() |
|
397 |
db.close() |
|
398 |
result = "Successful" |
|
399 |
except: |
|
400 |
result = "Failure" |
|
401 |
self.connection_results_label.show() |
|
402 |
self.connection_results.set_text(result) |
|
403 |
||
404 |
def menu_clicked(self,widget): |
|
405 |
"""Catches signals sent from all menu items"""
|
|
406 |
if (widget is not None and widget.get_name() == 'new_menuitem'): |
|
407 |
self.clear_settings() |
|
408 |
elif (widget is not None and widget.get_name() == 'open_menuitem'): |
|
409 |
self.open_configuration() |
|
410 |
elif (widget is not None and widget.get_name() == 'save_menuitem'): |
|
411 |
self.save_configuration() |
|
412 |
elif (widget is not None and widget.get_name() == 'quit_menuitem'): |
|
413 |
self.destroy(None) |
|
414 |
elif (widget is not None and widget.get_name() == 'about_menuitem'): |
|
415 |
self.about_dialog.run() |
|
416 |
self.about_dialog.hide() |
|
417 |
||
418 |
def open_configuration(self): |
|
419 |
"""Presents the user with a dialog to open a configuration"""
|
|
420 |
self.open_dialog.set_filename("/media/disk") |
|
421 |
filter=gtk.FileFilter() |
|
422 |
filter.set_name("Mythbuntu Configuration Files") |
|
423 |
filter.add_pattern("mythbuntu_configuration.ini") |
|
424 |
self.open_dialog.add_filter(filter) |
|
425 |
response = self.open_dialog.run() |
|
426 |
if response == gtk.RESPONSE_OK: |
|
427 |
self.configfile = self.open_dialog.get_filename() |
|
428 |
self.load_configuration() |
|
429 |
self.load_configuration_gui() |
|
430 |
self.open_dialog.hide() |
|
431 |
||
432 |
def clear_settings(self): |
|
433 |
"""Clears all modified settings"""
|
|
434 |
self.mysql_user.set_text("mythtv") |
|
435 |
self.mysql_pass.set_text("") |
|
436 |
self.mysql_database.set_text("mythconverg") |
|
437 |
self.mysql_server.set_text("") |
|
438 |
self.connection_results_label.hide() |
|
439 |
self.connection_results.set_text("") |
|
440 |
self.videos_type.set_active(0) |
|
441 |
self.pictures_type.set_active(0) |
|
442 |
self.music_type.set_active(0) |
|
|
17
by Mario Limonciello
add basic lirc support |
443 |
self.remotecontrol.set_active(False) |
444 |
self.remote_list.set_active(0) |
|
|
11
by Mario Limonciello
gui is 90% active now. |
445 |
self.autostart.set_active(True) |
446 |
self.externalhome.set_active(True) |
|
447 |
self.hostname.set_text("ubuntu") |
|
448 |
||
449 |
def save_start_session(self,widget): |
|
450 |
"""Saves all settings and then proceeds to carry on"""
|
|
451 |
self.save_configuration() |
|
452 |
self.start_session() |
|
453 |
||
454 |
def save_configuration(self,widget=None): |
|
455 |
"""Saves all settings"""
|
|
456 |
||
457 |
self.save_dialog.set_filename("/media/disk") |
|
458 |
response = self.save_dialog.run() |
|
459 |
if response == gtk.RESPONSE_OK: |
|
460 |
self.configfile = self.save_dialog.get_filename() + '/mythbuntu_configuration.ini' |
|
461 |
self.process_gui() |
|
462 |
file_name = open(self.configfile, "w") |
|
463 |
self.config.write(file_name) |
|
464 |
file_name.close() |
|
465 |
self.save_dialog.hide() |
|
466 |
||
467 |
def process_gui(self): |
|
468 |
"""Processes all inputs within the gui"""
|
|
|
17
by Mario Limonciello
add basic lirc support |
469 |
#Version number
|
|
11
by Mario Limonciello
gui is 90% active now. |
470 |
self.config.set("mythbuntu", "version", RELEASE) |
|
17
by Mario Limonciello
add basic lirc support |
471 |
#Autostart Frontend
|
|
11
by Mario Limonciello
gui is 90% active now. |
472 |
if self.autostart.get_active(): |
473 |
self.config.set("mythbuntu", "autostart", "True") |
|
474 |
else: |
|
475 |
self.config.set("mythbuntu", "autostart", "False") |
|
|
17
by Mario Limonciello
add basic lirc support |
476 |
#External Home Directory
|
|
11
by Mario Limonciello
gui is 90% active now. |
477 |
if self.externalhome.get_active(): |
478 |
self.config.set("mythbuntu", "externalhome", "True") |
|
479 |
else: |
|
480 |
self.config.set("mythbuntu", "externalhome", "False") |
|
|
17
by Mario Limonciello
add basic lirc support |
481 |
#Remote Control
|
482 |
if self.remotecontrol.get_active(): |
|
483 |
self.config.set("mythbuntu", "remote_en", "True") |
|
|
19
by Mario Limonciello
fix more debconf toys |
484 |
self.config.set("mythbuntu", "remotecontrol", self.remote_list.get_active_text()) |
|
17
by Mario Limonciello
add basic lirc support |
485 |
self.config.set("mythbuntu", "remotedriver", self.remote_driver.get_active_text()) |
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
486 |
self.config.set("mythbuntu", "remotemodules", self.remote_modules.get_active_text()) |
|
17
by Mario Limonciello
add basic lirc support |
487 |
self.config.set("mythbuntu", "remoteconfig", self.remote_rc.get_active_text()) |
488 |
else: |
|
489 |
self.config.set("mythbuntu", "remote_en", "False") |
|
490 |
self.config.set("mythbuntu", "remotecontrol", "none") |
|
491 |
self.config.set("mythbuntu", "remotedriver", "none") |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
492 |
self.config.set("mythbuntu", "remotemodules", "none") |
|
17
by Mario Limonciello
add basic lirc support |
493 |
self.config.set("mythbuntu", "remoteconfig", "none") |
494 |
#Master Backend Info
|
|
|
11
by Mario Limonciello
gui is 90% active now. |
495 |
self.config.set("mythbuntu", "hostname", self.hostname.get_text()) |
496 |
self.config.set("mythbuntu", "mysql_user", self.mysql_user.get_text()) |
|
497 |
self.config.set("mythbuntu", "mysql_pass", self.mysql_pass.get_text()) |
|
498 |
self.config.set("mythbuntu", "mysql_db", self.mysql_database.get_text()) |
|
499 |
self.config.set("mythbuntu", "mysql_host", self.mysql_server.get_text()) |
|
|
17
by Mario Limonciello
add basic lirc support |
500 |
#Videos Plugin
|
|
11
by Mario Limonciello
gui is 90% active now. |
501 |
if self.videos_type.get_active() == 0: |
502 |
self.config.set("mythbuntu", "videos_type", "none") |
|
503 |
self.config.set("mythbuntu", "videos_server", "none") |
|
504 |
self.config.set("mythbuntu", "videos_path", "none") |
|
505 |
self.config.set("mythbuntu", "videos_auth", "False") |
|
506 |
self.config.set("mythbuntu", "videos_user", "none") |
|
507 |
self.config.set("mythbuntu", "videos_pass", "none") |
|
508 |
elif self.videos_type.get_active() == 1: |
|
509 |
self.config.set("mythbuntu", "videos_type", "NFS") |
|
510 |
self.config.set("mythbuntu", "videos_server", self.videos_server.get_text()) |
|
511 |
self.config.set("mythbuntu", "videos_path", self.videos_share.get_text()) |
|
512 |
self.config.set("mythbuntu", "videos_auth", "False") |
|
513 |
self.config.set("mythbuntu", "videos_user", "none") |
|
514 |
self.config.set("mythbuntu", "videos_pass", "none") |
|
515 |
else: |
|
516 |
self.config.set("mythbuntu", "videos_type", "SMB") |
|
517 |
self.config.set("mythbuntu", "videos_server", self.videos_server.get_text()) |
|
518 |
self.config.set("mythbuntu", "videos_path", self.videos_share.get_text()) |
|
519 |
if self.videos_authentication.get_active(): |
|
520 |
self.config.set("mythbuntu", "videos_auth", "True") |
|
521 |
self.config.set("mythbuntu", "videos_user", self.videos_username.get_text()) |
|
522 |
self.config.set("mythbuntu", "videos_pass", self.videos_password.get_text()) |
|
523 |
else: |
|
524 |
self.config.set("mythbuntu", "videos_auth", "False") |
|
525 |
self.config.set("mythbuntu", "videos_user", "none") |
|
526 |
self.config.set("mythbuntu", "videos_pass", "none") |
|
|
17
by Mario Limonciello
add basic lirc support |
527 |
#Pictures Plugin
|
|
11
by Mario Limonciello
gui is 90% active now. |
528 |
if self.pictures_type.get_active() == 0: |
529 |
self.config.set("mythbuntu", "pictures_type", "none") |
|
530 |
self.config.set("mythbuntu", "pictures_server", "none") |
|
531 |
self.config.set("mythbuntu", "pictures_path", "none") |
|
532 |
self.config.set("mythbuntu", "pictures_auth", "False") |
|
533 |
self.config.set("mythbuntu", "pictures_user", "none") |
|
534 |
self.config.set("mythbuntu", "pictures_pass", "none") |
|
535 |
elif self.pictures_type.get_active() == 1: |
|
536 |
self.config.set("mythbuntu", "pictures_type", "NFS") |
|
537 |
self.config.set("mythbuntu", "pictures_server", self.pictures_server.get_text()) |
|
538 |
self.config.set("mythbuntu", "pictures_path", self.pictures_share.get_text()) |
|
539 |
self.config.set("mythbuntu", "pictures_auth", "False") |
|
540 |
self.config.set("mythbuntu", "pictures_user", "none") |
|
541 |
self.config.set("mythbuntu", "pictures_pass", "none") |
|
542 |
else: |
|
543 |
self.config.set("mythbuntu", "pictures_type", "SMB") |
|
544 |
self.config.set("mythbuntu", "pictures_server", self.pictures_server.get_text()) |
|
545 |
self.config.set("mythbuntu", "pictures_path", self.pictures_share.get_text()) |
|
546 |
if self.pictures_authentication.get_active(): |
|
547 |
self.config.set("mythbuntu", "pictures_auth", "True") |
|
548 |
self.config.set("mythbuntu", "pictures_user", self.pictures_username.get_text()) |
|
549 |
self.config.set("mythbuntu", "pictures_pass", self.pictures_password.get_text()) |
|
550 |
else: |
|
551 |
self.config.set("mythbuntu", "pictures_auth", "False") |
|
552 |
self.config.set("mythbuntu", "pictures_user", "none") |
|
553 |
self.config.set("mythbuntu", "pictures_pass", "none") |
|
|
17
by Mario Limonciello
add basic lirc support |
554 |
#Music Plugin
|
|
11
by Mario Limonciello
gui is 90% active now. |
555 |
if self.music_type.get_active() == 0: |
556 |
self.config.set("mythbuntu", "music_type", "none") |
|
557 |
self.config.set("mythbuntu", "music_server", "none") |
|
558 |
self.config.set("mythbuntu", "music_path", "none") |
|
559 |
self.config.set("mythbuntu", "music_auth", "False") |
|
560 |
self.config.set("mythbuntu", "music_user", "none") |
|
561 |
self.config.set("mythbuntu", "music_pass", "none") |
|
562 |
elif self.music_type.get_active() == 1: |
|
563 |
self.config.set("mythbuntu", "music_type", "NFS") |
|
564 |
self.config.set("mythbuntu", "music_server", self.music_server.get_text()) |
|
565 |
self.config.set("mythbuntu", "music_path", self.music_share.get_text()) |
|
566 |
self.config.set("mythbuntu", "music_auth", "False") |
|
567 |
self.config.set("mythbuntu", "music_user", "none") |
|
568 |
self.config.set("mythbuntu", "music_pass", "none") |
|
569 |
else: |
|
570 |
self.config.set("mythbuntu", "music_type", "SMB") |
|
571 |
self.config.set("mythbuntu", "music_server", self.music_server.get_text()) |
|
572 |
self.config.set("mythbuntu", "music_path", self.music_share.get_text()) |
|
573 |
if self.music_authentication.get_active(): |
|
574 |
self.config.set("mythbuntu", "music_auth", "True") |
|
575 |
self.config.set("mythbuntu", "music_user", self.music_username.get_text()) |
|
576 |
self.config.set("mythbuntu", "music_pass", self.music_password.get_text()) |
|
577 |
else: |
|
578 |
self.config.set("mythbuntu", "music_auth", "False") |
|
579 |
self.config.set("mythbuntu", "music_user", "none") |
|
580 |
self.config.set("mythbuntu", "music_pass", "none") |
|
581 |
||
|
15
by Mario Limonciello
add proper support for changing users and groups |
582 |
def start_session(self,widget=None): |
|
11
by Mario Limonciello
gui is 90% active now. |
583 |
"""Starts the session"""
|
584 |
#We will only need to reprocess the gui if we enter this method
|
|
585 |
#From within the gui. Otherwise, assume an automatic load
|
|
586 |
if (widget is not None and widget.get_name() == 'start'): |
|
587 |
self.process_gui() |
|
588 |
self.process_mountpoints() |
|
589 |
self.process_hostname() |
|
590 |
self.process_master_backend_info() |
|
|
17
by Mario Limonciello
add basic lirc support |
591 |
self.process_remote() |
|
19
by Mario Limonciello
fix more debconf toys |
592 |
self.db.stop() |
|
11
by Mario Limonciello
gui is 90% active now. |
593 |
self.start_frontend() |
|
15
by Mario Limonciello
add proper support for changing users and groups |
594 |
sys.exit(0) |
|
11
by Mario Limonciello
gui is 90% active now. |
595 |
|
|
17
by Mario Limonciello
add basic lirc support |
596 |
def remote_changed(self,widget): |
597 |
"""Called when the remote checkbox is toggled"""
|
|
598 |
if (widget is not None and widget.get_name() == 'remotecontrol'): |
|
599 |
if widget.get_active() == True: |
|
600 |
self.remote_hbox.set_sensitive(True) |
|
601 |
else: |
|
602 |
self.remote_hbox.set_sensitive(False) |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
603 |
self.remote_list.set_active(0) |
|
17
by Mario Limonciello
add basic lirc support |
604 |
elif (widget is not None and widget.get_name() == 'remote_list'): |
605 |
active_num = widget.get_active() |
|
606 |
self.remote_driver.set_active(active_num) |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
607 |
self.remote_modules.set_active(active_num) |
|
17
by Mario Limonciello
add basic lirc support |
608 |
self.remote_rc.set_active(active_num) |
609 |
||
610 |
def populate_lirc(self): |
|
611 |
"""Fills the lirc pages with the appropriate data"""
|
|
612 |
#Note, this requires lirc >= 0.8.2
|
|
613 |
self.remote_count=1 |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
614 |
hwdb = open('/usr/share/lirc/lirc.hwdb').readlines() |
615 |
hwdb.sort() |
|
616 |
#Filter out uncessary lines
|
|
|
17
by Mario Limonciello
add basic lirc support |
617 |
filter = "^\#|^\[" |
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
618 |
#Filter out the /dev/input/eventX remote
|
|
17
by Mario Limonciello
add basic lirc support |
619 |
filter += "|http" |
620 |
pattern = re.compile(filter) |
|
621 |
for line in hwdb: |
|
622 |
if pattern.search(line) is None: |
|
623 |
list = string.split(line, ";") |
|
624 |
if len(list) > 1: |
|
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
625 |
#Make sure we have a config file before including
|
|
17
by Mario Limonciello
add basic lirc support |
626 |
if list[4] != "": |
|
18
by Mario Limonciello
rework lirc to take advantage of lirc 0.8.2-0ubuntu3 |
627 |
self.remote_list.append_text(list[0].translate(string.maketrans('',''),',')) |
628 |
self.remote_driver.append_text(list[1]) |
|
629 |
self.remote_modules.append_text(list[2]) |
|
|
17
by Mario Limonciello
add basic lirc support |
630 |
self.remote_rc.append_text(list[4]) |
631 |
self.remote_count = self.remote_count + 1 |
|
632 |
self.remote_list.set_active(0) |
|
633 |
||
|
11
by Mario Limonciello
gui is 90% active now. |
634 |
def videos_changed(self,widget): |
635 |
if (widget is not None and widget.get_name() == 'videos_type'): |
|
636 |
if widget.get_active_text() == "SMB": |
|
637 |
self.videos_input_vbox.set_sensitive(True) |
|
638 |
self.samba_videos_vbox.set_sensitive(True) |
|
639 |
elif widget.get_active_text() == "NFS": |
|
640 |
self.videos_input_vbox.set_sensitive(True) |
|
641 |
self.samba_videos_vbox.set_sensitive(False) |
|
642 |
self.videos_authentication.set_active(False) |
|
643 |
elif widget.get_active_text() == "None": |
|
644 |
self.videos_input_vbox.set_sensitive(False) |
|
645 |
self.samba_videos_vbox.set_sensitive(False) |
|
646 |
self.videos_authentication.set_active(False) |
|
647 |
self.videos_server.set_text("") |
|
648 |
self.videos_share.set_text("") |
|
649 |
elif (widget is not None and widget.get_name() == 'videos_authentication'): |
|
650 |
if widget.get_active(): |
|
651 |
self.videos_authentication_vbox.set_sensitive(True) |
|
652 |
else: |
|
653 |
self.videos_authentication_vbox.set_sensitive(False) |
|
654 |
self.videos_username.set_text("") |
|
655 |
self.videos_password.set_text("") |
|
656 |
||
657 |
def pictures_changed(self,widget): |
|
658 |
if (widget is not None and widget.get_name() == 'pictures_type'): |
|
659 |
if widget.get_active_text() == "SMB": |
|
660 |
self.pictures_input_vbox.set_sensitive(True) |
|
661 |
self.samba_pictures_vbox.set_sensitive(True) |
|
662 |
elif widget.get_active_text() == "NFS": |
|
663 |
self.pictures_input_vbox.set_sensitive(True) |
|
664 |
self.samba_pictures_vbox.set_sensitive(False) |
|
665 |
self.pictures_authentication.set_active(False) |
|
666 |
elif widget.get_active_text() == "None": |
|
667 |
self.pictures_input_vbox.set_sensitive(False) |
|
668 |
self.samba_pictures_vbox.set_sensitive(False) |
|
669 |
self.pictures_authentication.set_active(False) |
|
670 |
self.pictures_server.set_text("") |
|
671 |
self.pictures_share.set_text("") |
|
672 |
elif (widget is not None and widget.get_name() == 'pictures_authentication'): |
|
673 |
if widget.get_active(): |
|
674 |
self.pictures_authentication_vbox.set_sensitive(True) |
|
675 |
else: |
|
676 |
self.pictures_authentication_vbox.set_sensitive(False) |
|
677 |
self.pictures_username.set_text("") |
|
678 |
self.pictures_password.set_text("") |
|
679 |
||
680 |
def music_changed(self,widget): |
|
681 |
if (widget is not None and widget.get_name() == 'music_type'): |
|
682 |
if widget.get_active_text() == "SMB": |
|
683 |
self.music_input_vbox.set_sensitive(True) |
|
684 |
self.samba_music_vbox.set_sensitive(True) |
|
685 |
elif widget.get_active_text() == "NFS": |
|
686 |
self.music_input_vbox.set_sensitive(True) |
|
687 |
self.samba_music_vbox.set_sensitive(False) |
|
688 |
self.music_authentication.set_active(False) |
|
689 |
elif widget.get_active_text() == "None": |
|
690 |
self.music_input_vbox.set_sensitive(False) |
|
691 |
self.samba_music_vbox.set_sensitive(False) |
|
692 |
self.music_authentication.set_active(False) |
|
693 |
self.music_server.set_text("") |
|
694 |
self.music_share.set_text("") |
|
695 |
elif (widget is not None and widget.get_name() == 'music_authentication'): |
|
696 |
if widget.get_active(): |
|
697 |
self.music_authentication_vbox.set_sensitive(True) |
|
698 |
else: |
|
699 |
self.music_authentication_vbox.set_sensitive(False) |
|
700 |
self.music_username.set_text("") |
|
701 |
self.music_password.set_text("") |
|
702 |
||
703 |
def destroy(self, widget, data=None): |
|
704 |
gtk.main_quit() |
|
705 |
||
706 |
def display_error(self,message): |
|
707 |
"""Displays an error message"""
|
|
|
13
by Mario Limonciello
add command line behavior |
708 |
dialog = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL, |
|
11
by Mario Limonciello
gui is 90% active now. |
709 |
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, |
710 |
message) |
|
711 |
dialog.run() |
|
712 |
sys.exit(1) |
|
713 |
||
714 |
def load_configuration_gui(self): |
|
715 |
"""Loads all options into the gui"""
|
|
716 |
#Master backend info
|
|
717 |
if self.config.has_option("mythbuntu", "mysql_user") and \ |
|
718 |
self.config.has_option("mythbuntu", "mysql_pass") and \ |
|
719 |
self.config.has_option("mythbuntu", "mysql_db") and \ |
|
720 |
self.config.has_option("mythbuntu", "mysql_host"): |
|
721 |
||
722 |
self.mysql_user.set_text(self.config.get("mythbuntu", "mysql_user")) |
|
723 |
self.mysql_pass.set_text(self.config.get("mythbuntu", "mysql_pass")) |
|
724 |
self.mysql_database.set_text(self.config.get("mythbuntu", "mysql_db")) |
|
725 |
self.mysql_server.set_text(self.config.get("mythbuntu", "mysql_host")) |
|
726 |
||
727 |
#Music Plugin
|
|
728 |
if self.config.has_option("mythbuntu", "music_type") and \ |
|
729 |
self.config.has_option("mythbuntu", "music_server") and \ |
|
730 |
self.config.has_option("mythbuntu", "music_path"): |
|
731 |
if self.config.get("mythbuntu", "music_type") == "SMB": |
|
732 |
self.music_type.set_active(2) |
|
733 |
self.music_server.set_text(self.config.get("mythbuntu", "music_server")) |
|
734 |
self.music_share.set_text(self.config.get("mythbuntu", "music_path")) |
|
735 |
if self.config.has_option("mythbuntu", "music_auth") and \ |
|
736 |
self.config.has_option("mythbuntu", "music_pass") and \ |
|
737 |
self.config.has_option("mythbuntu", "music_user"): |
|
738 |
if self.config.get("mythbuntu", "music_auth") == "True": |
|
739 |
self.music_authentication.set_active(True) |
|
740 |
self.music_username.set_text(self.config.get("mythbuntu", "music_user")) |
|
741 |
self.music_password.set_text(self.config.get("mythbuntu", "music_pass")) |
|
742 |
elif self.config.get("mythbuntu", "music_type") == "NFS": |
|
743 |
self.music_type.set_active(1) |
|
744 |
self.music_server.set_text(self.config.get("mythbuntu", "music_server")) |
|
745 |
self.music_share.set_text(self.config.get("mythbuntu", "music_path")) |
|
746 |
else: |
|
747 |
self.music_type.set_active(0) |
|
748 |
||
749 |
#Videos Plugin
|
|
750 |
if self.config.has_option("mythbuntu", "videos_type") and \ |
|
751 |
self.config.has_option("mythbuntu", "videos_server") and \ |
|
752 |
self.config.has_option("mythbuntu", "videos_path"): |
|
753 |
if self.config.get("mythbuntu", "videos_type") == "SMB": |
|
754 |
self.videos_type.set_active(2) |
|
755 |
self.videos_server.set_text(self.config.get("mythbuntu", "videos_server")) |
|
756 |
self.videos_share.set_text(self.config.get("mythbuntu", "videos_path")) |
|
757 |
if self.config.has_option("mythbuntu", "videos_auth") and \ |
|
758 |
self.config.has_option("mythbuntu", "videos_pass") and \ |
|
759 |
self.config.has_option("mythbuntu", "videos_user"): |
|
760 |
if self.config.get("mythbuntu", "videos_auth") == "True": |
|
761 |
self.videos_authentication.set_active(True) |
|
762 |
self.videos_username.set_text(self.config.get("mythbuntu", "videos_user")) |
|
763 |
self.videos_password.set_text(self.config.get("mythbuntu", "videos_pass")) |
|
764 |
elif self.config.get("mythbuntu", "videos_type") == "NFS": |
|
765 |
self.videos_type.set_active(1) |
|
766 |
self.videos_server.set_text(self.config.get("mythbuntu", "videos_server")) |
|
767 |
self.videos_share.set_text(self.config.get("mythbuntu", "videos_path")) |
|
768 |
else: |
|
769 |
self.videos_type.set_active(0) |
|
770 |
||
771 |
#Pictures Plugins
|
|
772 |
if self.config.has_option("mythbuntu", "pictures_type") and \ |
|
773 |
self.config.has_option("mythbuntu", "pictures_server") and \ |
|
774 |
self.config.has_option("mythbuntu", "pictures_path"): |
|
775 |
if self.config.get("mythbuntu", "pictures_type") == "SMB": |
|
776 |
self.pictures_type.set_active(2) |
|
777 |
self.pictures_server.set_text(self.config.get("mythbuntu", "pictures_server")) |
|
778 |
self.pictures_share.set_text(self.config.get("mythbuntu", "pictures_path")) |
|
779 |
if self.config.has_option("mythbuntu", "pictures_auth") and \ |
|
780 |
self.config.has_option("mythbuntu", "pictures_pass") and \ |
|
781 |
self.config.has_option("mythbuntu", "pictures_user"): |
|
782 |
if self.config.get("mythbuntu", "pictures_auth") == "True": |
|
783 |
self.pictures_authentication.set_active(True) |
|
784 |
self.pictures_username.set_text(self.config.get("mythbuntu", "pictures_user")) |
|
785 |
self.pictures_password.set_text(self.config.get("mythbuntu", "pictures_pass")) |
|
786 |
elif self.config.get("mythbuntu", "pictures_type") == "NFS": |
|
787 |
self.pictures_type.set_active(1) |
|
788 |
self.pictures_server.set_text(self.config.get("mythbuntu", "pictures_server")) |
|
789 |
self.pictures_share.set_text(self.config.get("mythbuntu", "pictures_path")) |
|
790 |
else: |
|
791 |
self.pictures_type.set_active(0) |
|
792 |
||
793 |
#Autostart information
|
|
794 |
if self.config.has_option("mythbuntu", "autostart"): |
|
795 |
if self.config.get("mythbuntu", "autostart") == "True": |
|
796 |
self.autostart.set_active(True) |
|
797 |
elif self.config.get("mythbuntu", "autostart") == "False": |
|
798 |
self.autostart.set_active(False) |
|
799 |
||
800 |
#External Home Directory Information
|
|
801 |
if self.config.has_option("mythbuntu", "externalhome"): |
|
802 |
if self.config.get("mythbuntu", "externalhome") == "True": |
|
803 |
self.externalhome.set_active(True) |
|
804 |
elif self.config.get("mythbuntu", "externalhome") == "False": |
|
805 |
self.externalhome.set_active(False) |
|
806 |
||
807 |
#Hostname
|
|
808 |
if self.config.has_option("mythbuntu", "hostname"): |
|
809 |
self.hostname.set_text(self.config.get("mythbuntu", "hostname")) |
|
810 |
||
|
17
by Mario Limonciello
add basic lirc support |
811 |
#Remote Control
|
812 |
if self.config.has_option("mythbuntu", "remote_en") and \ |
|
813 |
self.config.has_option("mythbuntu", "remotecontrol"): |
|
814 |
if self.config.get("mythbuntu", "remote_en") == "True": |
|
815 |
self.remotecontrol.set_active(True) |
|
816 |
for item in range(self.remote_count): |
|
817 |
self.remote_list.set_active(item) |
|
|
19
by Mario Limonciello
fix more debconf toys |
818 |
if self.remote_list.get_active_text() == self.config.get("mythbuntu", "remotecontrol"): |
|
17
by Mario Limonciello
add basic lirc support |
819 |
break
|
820 |
else: |
|
821 |
self.remotecontrol.set_active(False) |
|
822 |
self.remote_list.set_active(0) |
|
823 |
||
|
13
by Mario Limonciello
add command line behavior |
824 |
def display_help(): |
825 |
"""Shows the help for this application"""
|
|
|
14
by Mario Limonciello
update debian/* documentation |
826 |
print "" |
827 |
print "mythbuntu-startup is used to create and run a custom Mythbuntu Live Session" |
|
828 |
print "If you have not yet created a configuration to use with it," |
|
829 |
print "" |
|
|
13
by Mario Limonciello
add command line behavior |
830 |
print "USAGE:" |
|
14
by Mario Limonciello
update debian/* documentation |
831 |
print "" |
832 |
print "mythbuntu-startup [--help]" |
|
833 |
print " Display this help" |
|
834 |
print "" |
|
835 |
print "mythbuntu-startup [--load]" |
|
836 |
print " The application can be launched with the optional switch --load" |
|
837 |
print " Providing no additional arguments after --load will imply a search" |
|
838 |
print " Within the first level of directories located in /media" |
|
839 |
print " If nothing is found, the application will simply exit" |
|
840 |
print "" |
|
|
13
by Mario Limonciello
add command line behavior |
841 |
print "mythbuntu-startup [--load] [file]" |
|
14
by Mario Limonciello
update debian/* documentation |
842 |
print " Launching with a file after --load will attempt to start the application" |
843 |
print " loading that file" |
|
844 |
print "" |
|
|
13
by Mario Limonciello
add command line behavior |
845 |
print "mythbuntu-startup [--edit]" |
|
14
by Mario Limonciello
update debian/* documentation |
846 |
print " Lastly mythbuntu-startup can load directly into edit mode, disregarding" |
847 |
print " Any automatic loading listed in the file. This is useful when a typographical" |
|
848 |
print " Error within the file is preventing things from working correctly." |
|
849 |
print "" |
|
850 |
print "mythbuntu-startup" |
|
851 |
print " Launching the application with no arguments will search within the first level" |
|
852 |
print " of directories within /media. If nothing is found, the configuration editor" |
|
853 |
print " will be launched." |
|
|
13
by Mario Limonciello
add command line behavior |
854 |
sys.exit(2) |
|
11
by Mario Limonciello
gui is 90% active now. |
855 |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
856 |
if __name__ == '__main__': |
|
13
by Mario Limonciello
add command line behavior |
857 |
|
858 |
for arg in sys.argv: |
|
859 |
if arg == "--help" or arg == "-help" or arg == "--h" or arg == "-h": |
|
860 |
display_help() |
|
861 |
||
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
862 |
mythbuntu = MythbuntuStartup() |
|
13
by Mario Limonciello
add command line behavior |
863 |
|
864 |
#check to make sure we are running root via sudo
|
|
865 |
if (os.getuid() != 0) or ('SUDO_UID' not in os.environ) or ('SUDO_GID' not in os.environ): |
|
866 |
mythbuntu.display_error('This application must be run with administrative privileges from gksu, gksudo, sudo, or kdesu. It can not be ran directly as root or a normal user, and cannot continue.') |
|
867 |
||
868 |
||
869 |
#We are presented with the --load switch without a file
|
|
870 |
#This happens during the initial boot and should be the
|
|
871 |
#most common case
|
|
872 |
if len(sys.argv) == 2 and sys.argv[1] == "--load": |
|
873 |
if mythbuntu.find_configuration(): |
|
874 |
mythbuntu.load_configuration() |
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
875 |
else: |
|
13
by Mario Limonciello
add command line behavior |
876 |
sys.exit(3) |
877 |
#We are presented with a file to directly load
|
|
878 |
elif len(sys.argv) > 2 and sys.argv[1] == "--load": |
|
879 |
mythbuntu.configfile= sys.argv[2] |
|
880 |
mythbuntu.load_configuration() |
|
881 |
#We have a normal startup without arguments
|
|
882 |
#Try to start from a configuration file, otherwise
|
|
883 |
#Show the gui
|
|
884 |
elif mythbuntu.find_configuration(): |
|
885 |
mythbuntu.load_configuration() |
|
886 |
||
887 |
#Debug mode
|
|
888 |
if 'DEBUG' in os.environ: |
|
889 |
print "****** WARNING: Debug mode enabled *****" |
|
890 |
mythbuntu.print_configuration() |
|
891 |
||
892 |
#Start the session if indicated by the file
|
|
893 |
#And if the override isn't present
|
|
894 |
if mythbuntu.check_autostart() and not ( len(sys.argv) == 2 and sys.argv[1] == "--edit"): |
|
|
14
by Mario Limonciello
update debian/* documentation |
895 |
mythbuntu.start_session() |
|
13
by Mario Limonciello
add command line behavior |
896 |
#Otherwise, show the gui
|
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
897 |
else: |
|
9
by Mario Limonciello
first variation of the glade addon. |
898 |
mythbuntu.run() |
|
2
by Mario Limonciello
add manpages, new script, install script, fix lintian errors |
899 |
sys.exit(0) |