~system76-dev/system76-driver/3.0

« back to all changes in this revision

Viewing changes to System76Drivergtk3.py

  • Committer: Carl Richell
  • Date: 2012-06-06 16:45:38 UTC
  • mfrom: (48.1.14 development)
  • Revision ID: carl@system76.com-20120606164538-fpysot4mry0i9p4e
Merge from Ian's tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#import system python libraries:
10
10
import os
11
11
import sys
12
 
import getopt
13
12
import time
14
13
import threading
15
14
 
40
39
SYS76LOGO_IMAGE = os.path.join(IMAGEDIR, 'logo.png')
41
40
SYS76SQUARE_LOGO = os.path.join(IMAGEDIR, 'logoSQUARE.png')
42
41
WINDOW_ICON = os.path.join(IMAGEDIR, '76icon.svg')
43
 
DETAILS_SHOW = True
44
42
 
45
43
def setNotify(icon, text): #Allows us to set the notification text and icon in the bottom of the window
46
44
    notifyIcon = builder.get_object("notifyImage")
57
55
    #Creates an archive of common support files and logs    
58
56
    if os.path.isfile(lockFile) == True:
59
57
        print("FAIL: System76 Driver is currently locked! Wait for it to finish. If this error persists, please reboot.")
60
 
        setNotify("gtk-dialog-error", "The driver is currently processing other operations.\nPlease wait for it to finish")
 
58
        setNotify("gtk-dialog-error", "The driver is currently processing another operation.\nPlease wait for it to finish")
61
59
    else:
62
60
        os.system('touch ' + lockFile)
63
61
        username = getpass.getuser()
88
86
#        os.system('sudo chmod 777 /home/%s/logs.tar' % username)
89
87
        os.system('rm ' + lockFile)
90
88
        
91
 
        setNotify("gtk-ok", "File (logs.tar) created in your home folder. Please\nsend it to support at www.system76.com/support")
 
89
        setNotify("gtk-ok", "A log file (logs.tar) was created in your home folder. Please send it to\nsupport via www.system76.com/support")
92
90
 
93
91
#########################
94
92
## Driver installation ##
102
100
        GObject.idle_add(setNotify, "gtk-execute", "Now installing drivers. This may take a while...")
103
101
        time.sleep(0.1)
104
102
        if driverscontrol.installDrivers() == "true":
105
 
            GObject.idle_add(setNotify, "gtk-dialog-info", "All of your drivers for this system\nare provided by Ubuntu.")
 
103
            GObject.idle_add(setNotify, "gtk-dialog-info", "All of the drivers for this system are provided by Ubuntu.")
106
104
            time.sleep(0.1)
107
105
            os.system('rm ' + lockFile)
108
106
        else:
109
 
            GObject.idle_add(setNotify, "gtk-apply", "Installation finished!\nReboot your machine now.")
 
107
            GObject.idle_add(setNotify, "gtk-apply", "Installation is complete! Reboot your machine for the changes to take effect.")
110
108
            time.sleep(0.1)
111
109
            os.system('rm ' + lockFile)
112
110
 
114
112
    #Manages installing the driver
115
113
    if os.path.isfile(lockFile) == True:
116
114
        print("FAIL: System76 Driver is currently locked! Wait for it to finish. If this error persists, please reboot.")
117
 
        setNotify("gtk-dialog-error", "The driver is currently processing other operations.\nPlease wait for it to finish")
 
115
        setNotify("gtk-dialog-error", "The driver is currently processing another operation.\nPlease wait for it to finish")
118
116
    elif detect.connectivityCheck() == "noConnectionExists": #Check to ensure there's a connection
119
117
        print("FAIL: No internet connection, or connection to server down.")
120
 
        setNotify("gtk-dialog-warning", "You are not currently connected to the internet!\nPlease establish a wired or wireless connetion.")
 
118
        setNotify("gtk-dialog-warning", "You are not currently connected to the internet!\nPlease establish a wired or wireless internet connection.")
121
119
    elif detect.aptcheck() == "running": #Check if there's an APT process running.
122
120
        print("FAIL: Another APT process running. Please close it and retry or reboot")
123
 
        setNotify("gtk-dialog-warning", "A package manager is running!\nPlease close it or reboot.")
 
121
        setNotify("gtk-dialog-warning", "A package manager is running! Please close it or\nreboot your system.")
124
122
    else:
125
123
        os.system('touch ' + lockFile)
126
124
        print("NOTE: Installing Drivers")
136
134
        threading.Thread.__init__(self)
137
135
 
138
136
    def run(self):
139
 
        GObject.idle_add(setNotify, "gtk-execute", "Now restoring factory settings.\nThis may take a while...")
 
137
        GObject.idle_add(setNotify, "gtk-execute", "Now restoring factory settings. This may take a while...")
140
138
        time.sleep(0.1)
141
139
        base_system.app_install()
142
140
        driverscontrol.installDrivers()
143
141
        os.system('rm ' + lockFile)
144
 
        GObject.idle_add(setNotify, "gtk-apply", "System restore finished! Reboot your machine now.")
 
142
        GObject.idle_add(setNotify, "gtk-apply", "System restore is complete! Reboot your machine for\nthe changes to take effect.")
145
143
        time.sleep(0.1)
146
144
 
147
145
def onRestoreClicked(driverRestore):
148
146
    #This method restores the system to factory state.
149
147
    if os.path.isfile(lockFile) == True:
150
148
        print("FAIL: System76 Driver is currently locked! Wait for it to finish. If this error persists, please reboot.")
151
 
        setNotify("gtk-dialog-error", "The driver is currently processing other operations.\nPlease wait for it to finish")
 
149
        setNotify("gtk-dialog-error", "The driver is currently processing another operation.\nPlease wait for it to finish")
152
150
    elif detect.connectivityCheck() == "noConnectionExists": #Check to ensure there's a connection
153
 
        setNotify("gtk-dialog-warning", "You are not currently connected to the internet!\nPlease establish a wired or wireless connetion.")
 
151
        setNotify("gtk-dialog-warning", "You are not currently connected to the internet!\nPlease establish a wired or wireless internet connetion.")
154
152
    elif detect.aptcheck() == "running": #Check if there's an APT process running.
155
153
        setNotify("gtk-dialog-warning", "A package manager is running!\nPlease close it or reboot.")
156
154
    else:
203
201
    "onCreateClicked": onCreateClicked,
204
202
    "onCloseClicked": Gtk.main_quit,
205
203
    "onAboutClicked": onAboutClicked,
206
 
    "onDetailsClicked": onDetailsClicked,
207
204
}
208
205
builder.connect_signals(handlers)
209
206
    
254
251
        #set the strings and labels
255
252
        modelName.set_text(system.name())
256
253
        modelNumber.set_text(model.determine_model())
257
 
        oSystem.set_text(ubuntuversion.getOsName() + " Version:")
 
254
        oSystem.set_text(ubuntuversion.getOsName() + " Version")
258
255
        ubuntuVersion.set_text(ubuntuversion.getVersion())
259
256
        driverVersion.set_text(programVersion)
260
257
        
 
258
        #set up the drivers details pane
 
259
        b = open(descriptionFile)
 
260
        d = b.read()
 
261
        b.close()
 
262
        builder.get_object("detailsText").set_text(d)
 
263
        
261
264
        #show the window.
262
265
        builder.get_object("mainWindow").show()
263
266
        Gtk.main()
272
275
if getSupported() == True:
273
276
    if driversdescribe.describeDrivers() == "true":
274
277
        os.system("echo 'All of the drivers for this system are provided by Ubuntu.' > " + descriptionFile)
 
278
        os.system("cat " + descriptionFile)
275
279
    else:
276
 
        os.system("echo 'The following drivers/fixes will be installed:' > " + descriptionFile)
277
 
        driversdescribe.describeDrivers()
278
 
    os.system("cat " + descriptionFile)
 
280
        os.system("cat " + descriptionFile)
279
281
    system76Driver().run()
280
282
else:
281
283
    notSupport().run()