~isantop/system76-driver/pkexec

« back to all changes in this revision

Viewing changes to usr/bin/system76-driver.py

  • Committer: Ian Santopietro
  • Date: 2012-06-07 14:30:02 UTC
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: ian@system76.com-20120607143002-hwt1i0jf42uckks0
Fix logs issue in GTK2 interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
## System76, Inc.
4
 
## Universal Driver
5
 
## Copyright System76, Inc.
6
 
## Copyright (C) 2010 System76, Inc.
7
 
## Released under the GNU General Public License (See LICENSE)
8
 
##
9
 
## Startup script
10
 
#
11
 
#
12
 
##TODO: Remove debugging OS version string for final release!
13
 
 
14
 
#import system python modules
15
 
import os
16
 
import sys
17
 
import optparse
18
 
 
19
 
#setup working directory
20
 
dir='/opt/system76/system76-driver/src/'
21
 
 
22
 
if os.path.isdir(dir):
23
 
    sys.path.append(dir)
24
 
 
25
 
os.chdir(dir)
26
 
 
27
 
#import System76 specific files
28
 
import base_system
29
 
import driverscontrol
30
 
import driversdescribe
31
 
import ubuntuversion
32
 
 
33
 
osversion = ubuntuversion.release()
34
 
driverversion = ubuntuversion.driver()
35
 
descriptionFile = "/tmp/sys76-drivers" #setup our description file that will hold descriptions of all of the drivers to be installed...
36
 
os.system("rm " + descriptionFile + " 2>/dev/null") #...and silently remove it if it exists.
37
 
 
38
 
def main():
39
 
    
40
 
    parser = optparse.OptionParser(usage="%prog [options]", version=driverversion)
41
 
    parser.add_option("-d", "--drivers", action="store_true", dest="drivers",
42
 
                help="Install Drivers for your Computer (requires sudo)")
43
 
    parser.add_option("-r", "--restore", action="store_true", dest="restore",
44
 
                help="Restore Computer to Factory Defaults (requires sudo)")
45
 
    parser.add_option("-l", "--list", action="store_true", dest="list",
46
 
                help="List drivers to be installed on this system (requires sudo)")
47
 
 
48
 
    (options, args) = parser.parse_args()
49
 
 
50
 
    if options.restore:
51
 
        base_system.app_install()
52
 
        driverscontrol.installDrivers()
53
 
    elif options.drivers:
54
 
        driverscontrol.installDrivers()
55
 
    elif options.list:
56
 
        if driversdescribe.describeDrivers() == "true":
57
 
            os.system("echo 'All of the drivers for this system are provided by Ubuntu.' > " + descriptionFile)
58
 
            os.system("cat " + descriptionFile)
59
 
        else:
60
 
            os.system("echo 'This application will install the following drivers/fixes:' > " + descriptionFile)
61
 
            driversdescribe.describeDrivers()
62
 
            os.system("cat " + descriptionFile)
63
 
    else:
64
 
    
65
 
        if osversion != '6.06' and osversion != '6.10' and osversion != '7.04' and osversion != '7.10' and osversion != '8.04' and osversion != '8.10' and osversion != '9.04' and osversion != '9.10' and osversion != '10.04' and osversion != '10.10' and osversion != '11.04':
66
 
            try:
67
 
                print("NOTE: 11.10 or later detected! Running GTK3 version.")
68
 
                os.environ['KDE_FULL_SESSION'] == 'true'
69
 
                os.system('kdesudo --comment "System76 Driver" python /opt/system76/system76-driver/src/System76Drivergtk3.py')
70
 
            except:
71
 
                print("NOTE: 11.10 or later detected! Running GTK3 version.")
72
 
                os.environ['GDMSESSION'] == 'default'
73
 
                os.system('gksu --description /usr/share/applications/system76-driver.desktop python /opt/system76/system76-driver/src/System76Drivergtk3.py')
74
 
            else:
75
 
                print("NOTE: 11.10 or later detected! Running GTK3 version.")
76
 
                os.system('gksu --description /usr/share/applications/system76-driver.desktop python /opt/system76/system76-driver/src/System76Drivergtk3.py')
77
 
        else:
78
 
            try:
79
 
                print("NOTE: 11.04 or earlier detected! Running GTK2 version.")
80
 
                os.environ['KDE_FULL_SESSION'] == 'true'
81
 
                os.system('kdesudo --comment "System76 Driver" python /opt/system76/system76-driver/src/System76Driver.py')
82
 
            except:
83
 
                print("NOTE: 11.04 or earlier detected! Running GTK2 version.")
84
 
                os.environ['GDMSESSION'] == 'default'
85
 
                os.system('gksu --description /usr/share/applications/system76-driver.desktop python /opt/system76/system76-driver/src/System76Driver.py')
86
 
            else:
87
 
                print("NOTE: 11.04 or earlier detected! Running GTK2 version.")
88
 
                os.system('gksu --description /usr/share/applications/system76-driver.desktop python /opt/system76/system76-driver/src/System76Driver.py')
89
 
 
90
 
if __name__ == "__main__":
91
 
    main()
92