1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
#!/usr/bin/env python
#
## System76, Inc.
## Copyright System76, Inc.
## Released under the GNU General Public License (See LICENSE)
##
## Main frontend - Legacy GTK2 Version
import os
import sys
import time
import gobject
import restore
import model
import system
import drivers
import ubuntuversion
import detect
import getpass
try:
import pygtk
pygtk.require("2.0")
except:
pass
try:
import gtk
import gtk.glade
except:
sys.exit(1)
IMAGEDIR = os.path.join(os.path.dirname(__file__), 'images')
SYS76LOGO_IMAGE = os.path.join(IMAGEDIR, 'logo.png')
SYS76SQUARE_LOGO = os.path.join(IMAGEDIR, 'logoSQUARE.png')
WINDOW_ICON = os.path.join(IMAGEDIR, '76icon.svg')
class aboutDlg:
"""Shows the about dialog box"""
def __init__(self, datadir):
#setup the glade file
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'aboutDialog')
def run(self):
"""Loads the about Dialog"""
self.dlg = self.wTree.get_widget("aboutDialog")
self.square_logo = gtk.gdk.pixbuf_new_from_file(os.path.join(SYS76SQUARE_LOGO))
self.icon = gtk.gdk.pixbuf_new_from_file(os.path.join(WINDOW_ICON))
self.dlg.set_logo(self.square_logo)
self.dlg.set_icon(self.icon)
self.dlg.set_version(ubuntuversion.driver())
#run the dialog
self.dlg.run()
#we are done with the dialog, destroy it
self.dlg.destroy()
class aptErrorDlg:
"""Shows another package manager running dialog"""
def __init__(self, datadir):
#setup the glade file
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'aptRunning')
def run(self):
"""Loads the apt running Dialog"""
self.dlg = self.wTree.get_widget("aptRunning")
self.icon = gtk.gdk.pixbuf_new_from_file(os.path.join(WINDOW_ICON))
self.dlg.set_icon(self.icon)
#run the dialog
self.dlg.run()
#we are done with the dialog, destroy it
self.dlg.destroy()
class archiveCreated:
"""Shows archive created dialog"""
def __init__(self, datadir):
#setup the glade file
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'logArchiveCreated')
def run(self):
"""Loads the archive created Dialog"""
self.dlg = self.wTree.get_widget("logArchiveCreated")
self.icon = gtk.gdk.pixbuf_new_from_file(os.path.join(WINDOW_ICON))
self.dlg.set_icon(self.icon)
#run the dialog
self.dlg.run()
#we are done with the dialog, destroy it
self.dlg.destroy()
class connectDlg:
"""Shows no connection dialog"""
def __init__(self, datadir):
#setup the glade file
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'noConnection')
def run(self):
"""Loads the no connection Dialog"""
self.dlg = self.wTree.get_widget("noConnection")
self.icon = gtk.gdk.pixbuf_new_from_file(os.path.join(WINDOW_ICON))
self.dlg.set_icon(self.icon)
#run the dialog
self.dlg.run()
#we are done with the dialog, destroy it
self.dlg.destroy()
def supported(datadir):
"""
This function will determine System76 and Ubuntu
Version support and run appropriate functions
"""
modelname = model.determine_model()
version = ubuntuversion.release()
if version == ('8.04.1'):
version = '8.04'
if version != '6.06' and version != '6.10' and version != '7.04' and version != '7.10' and version != '8.04' and version != '8.10' and version != '9.04' and version != '9.10' and version != '10.04' and version != '10.10' and version != '11.04':
notsupported = unsupported(datadir);
notsupported.run()
elif modelname == ('nonsystem76'):
notsupported = unsupported(datadir);
notsupported.run()
else:
ui = System76Driver(datadir)
ui.run()
class System76Driver:
"""This is the System76Driver application"""
def __init__(self, datadir):
#Set directory
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'mainWindow')
#load logos
self.system76logo = gtk.gdk.pixbuf_new_from_file(os.path.join(SYS76LOGO_IMAGE))
self.wTree.get_widget('system76logo').set_from_pixbuf(self.system76logo)
self.icon = gtk.gdk.pixbuf_new_from_file(os.path.join(WINDOW_ICON))
self.wTree.get_widget('mainWindow').set_icon(self.icon)
#Grab our widgets
self.sysName = self.wTree.get_widget("sysName")
self.sysModel = self.wTree.get_widget("sysModel")
self.sysProcessor = self.wTree.get_widget("sysProcessor")
self.sysMemory = self.wTree.get_widget("sysMemory")
self.sysHardDrive = self.wTree.get_widget("sysHardDrive")
#Create our dictionary and connect it
dic = {"on_mainWindow_destroy" : gtk.main_quit
, "on_about_clicked" : self.on_about_clicked
, "on_close_clicked" : gtk.main_quit
, "on_create_clicked" : self.on_create_clicked
, "on_driverInstall_clicked" : self.on_driverInstall_clicked
, "on_restore_clicked" : self.on_restore_clicked}
self.wTree.signal_autoconnect(dic)
#Grab the data
modelname = model.determine_model()
systemname = system.name()
#Change the labels
self.sysName.set_label(systemname)
self.sysModel.set_label(modelname)
def on_about_clicked(self, widget):
#Calls aboutDlg class to display dialog
aboutDialog = aboutDlg(datadir);
aboutDialog.run()
def on_create_clicked(self, widget):
#Creates an archive of common support files and logs
today = time.strftime('%Y%m%d_h%Hm%Ms%S')
modelname = model.determine_model()
version = ubuntuversion.release()
os.mkdir('/tmp/system_logs_%s' % today)
TARGETDIR = '/tmp/system_logs_%s' % today
fileObject = file('/tmp/system_logs_%s/systeminfo.txt' % today, 'wt')
fileObject.write('System76 Model: %s\n' % modelname)
fileObject.write('OS Version: %s\n' % version)
fileObject.close()
os.system('sudo dmidecode > %s/dmidecode' % TARGETDIR)
os.system('lspci -vv > %s/lspci' % TARGETDIR)
os.system('sudo lsusb -vv > %s/lsusb' % TARGETDIR)
os.system('cp /etc/X11/xorg.conf %s/' % TARGETDIR)
os.system('cp /etc/default/acpi-support %s/' % TARGETDIR)
os.system('cp /var/log/daemon.log %s/' % TARGETDIR)
os.system('cp /var/log/dmesg %s/' % TARGETDIR)
os.system('cp /var/log/messages %s/' % TARGETDIR)
os.system('cp /var/log/syslog %s/' % TARGETDIR)
os.system('cp /var/log/Xorg.0.log %s/' % TARGETDIR)
os.system('tar -zcvf logs.tar %s/' % TARGETDIR)
x = open("/tmp/sys76-username")
username = x.read()
x.close()
os.system('cp logs.tar /home/%s/' % username)
archiveCreatedDialog = archiveCreated(datadir);
archiveCreatedDialog.run()
def on_driverInstall_clicked(self, widget):
#Check if another package manager is running
aptrunning = detect.aptcheck()
#Grab internet connection test
connection = detect.connectivityCheck()
#Calls drivers module when user clicks Driver Install button
if connection == "noConnectionExists":
notConnected = connectDlg(datadir);
notConnected.run()
elif aptrunning == "running":
aptError = aptErrorDlg(datadir);
aptError.run()
else:
drivers.start()
def on_restore_clicked(self, widget):
#Check if another package manager is running
aptrunning = detect.aptcheck()
#Grab internet connection test
connection = detect.connectivityCheck()
#Calls restore module when user clicks Restore button
if connection == "noConnectionExists":
notConnected = connectDlg(datadir);
notConnected.run()
elif aptrunning == "running":
aptError = aptErrorDlg(datadir);
aptError.run()
else:
restore.start()
def run(self):
gtk.main()
class unsupported:
"""Shows the Unsupported dialog box"""
def __init__(self, datadir):
#setup the glade file
self.datadir = datadir
self.wTree = gtk.glade.XML(os.path.join(self.datadir, 'system76driver.glade'), 'unsupported')
def run(self):
"""Loads the unsupported Dialog"""
self.dlg = self.wTree.get_widget("unsupported")
#run the dialog
self.dlg.run()
#we are done with the dialog, destroy it
self.dlg.destroy()
if __name__ == "__main__":
datadir = os.path.join(os.path.dirname(__file__),'.')
supported(datadir)
|