def main(self, argv): # Handle arguments try: opts, args = getopt.getopt(argv, 'ic:dl:', ['install', 'codes=', 'debug', 'log']) except getopt.GetoptError: usage() sys.exit(2) for opt, arg in opts: if opt in ('-d', '--debug'): self.debug = True elif opt in ('-i', '--install'): self.install = True elif opt in ('-c', '--codes'): self.hwPreSelectList = arg.split(',') elif opt in ('-l', '--log'): self.logPath = arg # Initialize logging logFile = '' if self.debug: if self.logPath == '': self.logPath = 'ddm.log' self.log = Logger(self.logPath, 'debug', True, self.statusbar) functions.log = self.log # Set initial values self.text = self.conf.getValue('About', 'comments') self.lblText.set_text(self.text) # Show message that we're busy self.btnInstall.set_sensitive(False) self.btnRemove.set_sensitive(False) msg = 'Checking your hardware...' self.log.write(msg, 'ddm.main', 'info') functions.pushMessage(self.statusbar, msg) functions.repaintGui() # Fill hardware list self.fillHardware() self.btnInstall.set_sensitive(True) self.btnRemove.set_sensitive(True) # Show version number in status bar functions.pushMessage(self.statusbar, self.version) # Start automatic install if self.install: self.log.write('Start automatic driver install', 'ddm.main', 'info') self.installHardware(None) # Show window gtk.main()
def rtobjectWrite(self, message): if self.rtobject is not None and self.typeString != '': if self.typeString == 'gtk.Label': self.rtobject.set_text(message) elif self.typeString == 'gtk.TreeView': functions.appendRowToTreeView(self.rtobject, message, True) elif self.typeString == 'gtk.Statusbar': functions.pushMessage(self.rtobject, message) else: # For obvious reasons: do not log this... print 'Return object type not implemented: ' + self.typeString
def rtobjectWrite(self, message): if self.rtobject is not None and self.typeString != '': if self.typeString == 'gtk.Label': self.rtobject.set_text(message) elif self.typeString == 'gtk.TreeView': tvHandler = TreeViewHandler(None, self.rtobject) tvHandler.fillTreeview([message], ['str'], [-1], 0, 400, False, True, True, fontSize=10000) elif self.typeString == 'gtk.Statusbar': functions.pushMessage(self.rtobject, message) else: # For obvious reasons: do not log this... print 'Return object type not implemented: %s' % self.typeString
def main(self, argv): # Handle arguments try: opts, args = getopt.getopt(argv, 'ic:dfl:', ['install', 'codes=', 'debug', 'force', 'log=']) except getopt.GetoptError: print 'Arguments cannot be parsed: ' + str(argv) sys.exit(2) for opt, arg in opts: if opt in ('-d', '--debug'): self.debug = True elif opt in ('-i', '--install'): self.install = True elif opt in ('-c', '--codes'): self.hwPreSelectList = arg.split(',') elif opt in ('-l', '--log'): self.logPath = arg # Initialize logging if self.debug: if self.logPath == '': self.logPath = 'ddm.log' self.log = Logger(self.logPath, 'debug', True, self.statusbar, self.window) functions.log = self.log # Set initial values self.lblText.set_text('Currently Nvidia, ATI and Broadcom drivers are supported and it detects multi-core 32-bit systems so that the PAE kernel can be installed.') # Show message that we're busy self.btnInstall.set_sensitive(False) self.btnRemove.set_sensitive(False) msg = 'Checking your hardware...' self.log.write(msg, 'ddm.main', 'info') functions.pushMessage(self.statusbar, msg) functions.repaintGui() # Fill hardware list self.fillHardware() self.btnInstall.set_sensitive(True) self.btnRemove.set_sensitive(True) # Show version number in status bar self.version = functions.getPackageVersion('device-driver-manager') functions.pushMessage(self.statusbar, self.version) # Start automatic install if self.install: self.log.write('Start automatic driver install', 'ddm.main', 'info') self.installHardware(None) # Show window and keep it on top of other windows self.window.set_keep_above(True) gtk.main()
def checkThread(self, actionString): #print 'Thread count = ' + str(threading.active_count()) # As long there's a thread active, keep spinning if threading.active_count() > 1: self.spinner.start() return True # Thread is done: stop spinner and make button sensitive again self.fillHardware() self.toggleGuiElements(False) # Show message that we're done if actionString == 'install': msg = 'Done installing drivers' else: msg = 'Done removing drivers' functions.pushMessage(self.statusbar, msg) self.log.write(msg, 'ddm.checkThread', 'info') return False
def rtobjectWrite(self, message): if self.rtobject is not None and self.typeString != '': if 'label' in self.typeString.lower(): self.rtobject.set_text(message) elif 'treeview' in self.typeString.lower(): tvHandler = TreeViewHandler(self.rtobject) tvHandler.fillTreeview([message], ['str'], [-1], 0, 400, False, True, True, fontSize=10000) elif 'statusbar' in self.typeString.lower(): functions.pushMessage(self.rtobject, message) else: # For obvious reasons: do not log this... print('Return object type not implemented: %s' % self.typeString)
def rtobjectWrite(self, message): if self.rtobject != None and self.typeString != '': if self.typeString == 'gtk.Label': self.rtobject.set_text(message) elif self.typeString == 'gtk.TreeView': functions.appendRowToTreeView(self.rtobject, message, True) elif self.typeString == 'gtk.Statusbar': functions.pushMessage(self.rtobject, message) else: # For obvious reasons: do not log this... print 'Return object type not implemented: ' + self.typeString # Test #log = Logger('myapp.log') # Log file and console #log = Logger() # Console only #log.write('Dit is een debug test', 'myapp.gui', 'debug') # Should not end up in console when writing to log file #log.write('Dit is een info test', 'myapp.gui', 'info') #log.write('Dit is een warning test', 'myapp.gui', 'warning') #log.write('Dit is een error test', 'myapp.gui', 'error')
def showOutput(self, message): print(message) pushMessage(self.statusbar, message)
def showOutput(self, message): print(message) functions.pushMessage(self.statusbar, message)
def __init__(self): self.scriptDir = abspath(dirname(__file__)) # Load window and widgets self.builder = Gtk.Builder() self.builder.add_from_file(join(self.scriptDir, '../../../share/solydxk/conky/conky.glade')) go = self.builder.get_object self.window = go('conkyWindow') self.ebTitle = go('ebTitle') self.lblTitle = go('lblTitle') self.lblMenuTitle = go('lblMenuTitle') self.statusbar = go('statusbar') self.ebMenu = go('ebMenu') self.ebMenuPreferences = go('ebMenuPreferences') self.lblMenuPreferences = go('lblMenuPreferences') self.ebMenuNetwork = go('ebMenuNetwork') self.lblMenuNetwork = go('lblMenuNetwork') self.ebMenuSystem = go('ebMenuSystem') self.lblMenuSystem = go('lblMenuSystem') self.nbConky = go('nbConky') self.btnSave = go('btnSave') # Preferences objects self.lblPrefAction = go('lblPrefAction') self.cmbPrefAction = go('cmbPrefAction') self.lsAction = go('lsAction') self.btnPrefActionApply = go('btnPrefActionApply') self.lblPrefAutostart = go('lblPrefAutostart') self.chkPrefAutostart = go('chkPrefAutostart') self.lblPrefAutostartText = go('lblPrefAutostartText') self.lblPrefSleep = go('lblPrefSleep') self.cmbPrefSleep = go('cmbPrefSleep') self.lsSleep = go('lsSleep') self.lblPrefSleepText = go('lblPrefSleepText') self.lblPrefAlign = go('lblPrefAlign') self.cmbPrefAlign = go('cmbPrefAlign') self.lsAlign = go('lsAlign') self.lblPrefAlignText = go('lblPrefAlignText') # Network objects self.lblNetwInterface = go('lblNetwInterface') self.txtNetwInterface = go('txtNetwInterface') self.lblNetwInterfaceText = go('lblNetwInterfaceText') self.lblNetwDownSpeed = go('lblNetwDownSpeed') self.txtNetwDownSpeed = go('txtNetwDownSpeed') self.lblNetwSpeedText = go('lblNetwSpeedText') self.lblNetwUpSpeed = go('lblNetwUpSpeed') self.txtNetwUpSpeed = go('txtNetwUpSpeed') self.btnNetspeed = go('btnNetspeed') self.lblNetwLanIP = go('lblNetwLanIP') self.chkNetwLanIP = go('chkNetwLanIP') self.lblNetwLanIPText = go('lblNetwLanIPText') self.lblNetwIP = go('lblNetwIP') self.chkNetwIP = go('chkNetwIP') # System objects self.lblSysCoresTemp = go('lblSysCoresTemp') self.chkSysCores = go('chkSysCores') self.lblSysCoresTempText = go('lblSysCoresTempText') self.lblSysHdTemp = go('lblSysHdTemp') self.chkSysHd = go('chkSysHd') self.lblSysTempUnit = go('lblSysTempUnit') self.cmbSysTempUnit = go('cmbSysTempUnit') self.lsTemp = go('lsTemp') self.lblSysCpuFan = go('lblSysCpuFan') self.chkSysCpuFan = go('chkSysCpuFan') self.lblSysChassisFan = go('lblSysChassisFan') self.chkSysChassisFan = go('chkSysChassisFan') self.lblSysKernel = go('lblSysKernel') self.chkSysKernel = go('chkSysKernel') self.lblSysUP = go('lblSysUP') self.chkSysUP = go('chkSysUP') # Read from config file self.cfg = Config(join(self.scriptDir, 'conky.conf')) self.clrTitleFg = Gdk.color_parse(self.cfg.getValue('COLORS', 'title_fg')) self.clrTitleBg = Gdk.color_parse(self.cfg.getValue('COLORS', 'title_bg')) self.clrMenuSelect = Gdk.color_parse(self.cfg.getValue('COLORS', 'menu_select')) self.clrMenuHover = Gdk.color_parse(self.cfg.getValue('COLORS', 'menu_hover')) self.clrMenuBg = Gdk.color_parse(self.cfg.getValue('COLORS', 'menu_bg')) # Set background and forground colors self.ebTitle.modify_bg(Gtk.StateType.NORMAL, self.clrTitleBg) self.lblTitle.modify_fg(Gtk.StateType.NORMAL, self.clrTitleFg) self.lblMenuPreferences.modify_fg(Gtk.StateType.NORMAL, self.clrTitleBg) self.lblMenuNetwork.modify_fg(Gtk.StateType.NORMAL, self.clrTitleBg) self.lblMenuSystem.modify_fg(Gtk.StateType.NORMAL, self.clrTitleBg) self.lblMenuTitle.modify_fg(Gtk.StateType.NORMAL, self.clrTitleBg) self.ebMenu.modify_bg(Gtk.StateType.NORMAL, self.clrMenuBg) self.ebMenuPreferences.modify_bg(Gtk.StateType.NORMAL, self.clrMenuBg) self.ebMenuNetwork.modify_bg(Gtk.StateType.NORMAL, self.clrMenuBg) self.ebMenuSystem.modify_bg(Gtk.StateType.NORMAL, self.clrMenuBg) # Translations self.window.set_title(_("SolydXK Conky")) self.lblTitle.set_text(self.window.get_title()) self.lblMenuPreferences.set_text(_("Preferences")) self.lblMenuNetwork.set_text(_("Network")) self.lblMenuSystem.set_text(_("System")) self.btnSave.set_label(_("Save")) self.lblPrefAction.set_text(_("Action")) self.btnPrefActionApply.set_label(_("Apply")) self.lblPrefAutostart.set_text(_("Autostart")) self.lblPrefAutostartText.set_text(_("Autostart Conky on login.")) self.lblPrefSleep.set_text(_("Sleep")) self.lblPrefSleepText.set_text(_("Seconds to wait before starting Conky.\nDefault is 20 seconds.")) self.lblPrefAlign.set_text(_("Align")) self.lblPrefAlignText.set_text(_("Conky alignment on the desktop.")) self.lblNetwInterface.set_text(_("Interface")) self.lblNetwInterfaceText.set_text(_("Auto detected (use ifconfig).")) self.lblNetwDownSpeed.set_text(_("Download speed")) self.lblNetwSpeedText.set_text(_("Test your download and upload speed\nwith speed.net (in Kilobytes).")) self.lblNetwUpSpeed.set_text(_("Upload speed")) self.btnNetspeed.set_label(_("speedtest.net")) self.lblNetwLanIP.set_text(_("LAN IP")) self.lblNetwLanIPText.set_text(_("Check to show these items.")) self.lblNetwIP.set_text(_("IP")) self.lblSysCoresTemp.set_text(_("Core temperature")) self.lblSysCoresTempText.set_text(_("Check to show these items.")) self.lblSysHdTemp.set_text(_("HD temperature")) self.lblSysTempUnit.set_text(_("Temperature unit")) self.lblSysCpuFan.set_text(_("CPU fan speed")) self.lblSysChassisFan.set_text(_("Chassis fan speed")) self.lblSysKernel.set_text(_("Kernel")) self.lblSysUP.set_text(_("Update Pack")) # Fill combos actions = [[_("Start")], [_("Stop")], [_("Remove")]] for a in actions: self.lsAction.append(a) self.sleep = [[0], [10], [20], [30], [40], [50], [60]] for s in self.sleep: self.lsSleep.append(s) align = [[_("Right")], [_("Left")]] for a in align: self.lsAlign.append(a) temperature = [[_("Celsius")], [_("Fahrenheit")]] for t in temperature: self.lsTemp.append(t) # Initialize logging self.log = Logger('', 'debug', True, self.statusbar) # Get command lines self.commandCore = self.cfg.getValue('COMMANDS', 'core') self.commandCpu = self.cfg.getValue('COMMANDS', 'cpu') self.commandChassis = self.cfg.getValue('COMMANDS', 'chassis') self.commandHdd = self.cfg.getValue('COMMANDS', 'hdd') self.commandLanIp = self.cfg.getValue('COMMANDS', 'lanip') self.commandIp = self.cfg.getValue('COMMANDS', 'ip') self.commandKernel = self.cfg.getValue('COMMANDS', 'kernel') self.commandUp = self.cfg.getValue('COMMANDS', 'up') # Init variables self.ec = ExecCmd(self.log) self.selectedMenuItem = None self.defaultSpeed = '1000' self.home = expanduser("~/") self.dist = functions.getDistribution(False) self.luaDir = join(self.home, '.lua/scripts') self.lua = join(self.luaDir, 'clock_rings.lua') self.conkyrc = join(self.home, '.conkyrc') self.conkyStart = join(self.home, '.conky-start') self.autostartDir = join(self.home, '.config/autostart') self.desktop = join(self.autostartDir, 'conky.desktop') # Get current settings self.getSettings() # Show version number in status bar self.version = functions.getPackageVersion('solydxk-conky') functions.pushMessage(self.statusbar, self.version) # Show preferences at startup self.on_ebMenuPreferences_button_release_event() self.builder.connect_signals(self) self.window.show()
def __init__(self): self.scriptDir = abspath(dirname(__file__)) # Load window and widgets self.builder = Gtk.Builder() self.builder.add_from_file(join(self.scriptDir, '../../../share/solydxk/conky/conky.glade')) go = self.builder.get_object self.window = go('conkyWindow') self.lblMenuTitle = go('lblMenuTitle') self.statusbar = go('statusbar') self.btnPreferences = go('btnPreferences') self.btnNetwork = go('btnNetwork') self.btnSystem = go('btnSystem') self.btnColors = go('btnColors') self.nbConky = go('nbConky') self.btnSave = go('btnSave') # Preferences objects self.lblPrefAction = go('lblPrefAction') self.cmbPrefAction = go('cmbPrefAction') self.lsAction = go('lsAction') self.btnPrefActionApply = go('btnPrefActionApply') self.lblPrefAutostart = go('lblPrefAutostart') self.chkPrefAutostart = go('chkPrefAutostart') self.lblPrefAutostartText = go('lblPrefAutostartText') self.lblPrefSleep = go('lblPrefSleep') self.cmbPrefSleep = go('cmbPrefSleep') self.lsSleep = go('lsSleep') self.lblPrefSleepText = go('lblPrefSleepText') self.lblPrefAlign = go('lblPrefAlign') self.cmbPrefAlign = go('cmbPrefAlign') self.lsAlign = go('lsAlign') self.lblPrefAlignText = go('lblPrefAlignText') # Network objects self.lblNetwInterface = go('lblNetwInterface') self.txtNetwInterface = go('txtNetwInterface') self.lblNetwInterfaceText = go('lblNetwInterfaceText') self.lblNetwDownSpeed = go('lblNetwDownSpeed') self.txtNetwDownSpeed = go('txtNetwDownSpeed') self.lblNetwSpeedText = go('lblNetwSpeedText') self.lblNetwUpSpeed = go('lblNetwUpSpeed') self.txtNetwUpSpeed = go('txtNetwUpSpeed') self.btnNetspeed = go('btnNetspeed') self.lblNetwLanIP = go('lblNetwLanIP') self.chkNetwLanIP = go('chkNetwLanIP') self.lblNetwLanIPText = go('lblNetwLanIPText') self.lblNetwIP = go('lblNetwIP') self.chkNetwIP = go('chkNetwIP') # System objects self.lblSysCoresTemp = go('lblSysCoresTemp') self.chkSysCores = go('chkSysCores') self.lblSysCoresTempText = go('lblSysCoresTempText') self.lblSysHdTemp = go('lblSysHdTemp') self.chkSysHd = go('chkSysHd') self.lblSysTempUnit = go('lblSysTempUnit') self.cmbSysTempUnit = go('cmbSysTempUnit') self.lsTemp = go('lsTemp') self.lblSysCpuFan = go('lblSysCpuFan') self.chkSysCpuFan = go('chkSysCpuFan') self.lblSysChassisFan = go('lblSysChassisFan') self.chkSysChassisFan = go('chkSysChassisFan') self.lblSysKernel = go('lblSysKernel') self.chkSysKernel = go('chkSysKernel') # Color objects self.colorchooser = go('colorchooserDialog') self.lblDateTitle = go('lblDateTitle') self.lblDayClock = go('lblDayClock') self.lblSystemInfo = go('lblSystemInfo') self.colorBtnDateTitle = go('colorBtnDateTitle') self.colorBtnDayClock = go('colorBtnDayClock') self.colorBtnSystemInfo = go('colorBtnSystemInfo') self.dateTitleColor = None self.dayClockColor = None self.systemInfoColor = None self.dateTitleColorNew = None self.dayClockColorNew = None self.systemInfoColorNew = None # Translations self.window.set_title(_("SolydXK Conky")) self.btnPreferences.set_label(_("Preferences")) self.btnNetwork.set_label(_("Network")) self.btnSystem.set_label(_("System")) self.btnColors.set_label(_("Colors")) self.btnSave.set_label(_("Save")) self.lblPrefAction.set_label(_("Action")) self.btnPrefActionApply.set_label(_("Apply")) self.lblPrefAutostart.set_label(_("Autostart")) self.lblPrefAutostartText.set_label(_("Autostart Conky on login.")) self.lblPrefSleep.set_label(_("Sleep")) self.lblPrefSleepText.set_label(_("Seconds to wait before starting Conky.\nDefault is 20 seconds.")) self.lblPrefAlign.set_label(_("Align")) self.lblPrefAlignText.set_label(_("Conky alignment on the desktop.")) self.lblNetwInterface.set_label(_("Interface")) self.lblNetwInterfaceText.set_label(_("Auto detected (use ifconfig).")) self.lblNetwDownSpeed.set_label(_("Download speed")) self.lblNetwSpeedText.set_label(_("Test your download and upload speed\nwith speedtest.net (in Kilobytes).")) self.lblNetwUpSpeed.set_label(_("Upload speed")) self.btnNetspeed.set_label("speedtest.net") self.lblNetwLanIP.set_label(_("LAN IP")) self.lblNetwLanIPText.set_label(_("Check to show these items.")) self.lblNetwIP.set_label(_("IP")) self.lblSysCoresTemp.set_label(_("Core temperature")) self.lblSysCoresTempText.set_label(_("Check to show these items.")) self.lblSysHdTemp.set_label(_("HD temperature")) self.lblSysTempUnit.set_label(_("Temperature unit")) self.lblSysCpuFan.set_label(_("CPU fan speed")) self.lblSysChassisFan.set_label(_("Chassis fan speed")) self.lblSysKernel.set_label(_("Kernel")) self.lblDateTitle.set_label(_("Date and title")) self.lblDayClock.set_label(_("Day and clock")) self.lblSystemInfo.set_label(_("System information")) self.corelbl = _("Core temp") self.cpulbl = _("CPU fan") self.chassislbl = _("Chassis fan") self.hdlbl = _("HD temp") self.lanlbl = _("LAN IP") self.iplbl = _("IP") self.kernellbl = _("Kernel") reset = _("Reset") go('btnResetDateTitle').set_label(reset) go('btnResetDayClock').set_label(reset) go('btnResetSystemInfo').set_label(reset) # Fill combos actions = [[_("Start")], [_("Stop")], [_("Remove")]] for a in actions: self.lsAction.append(a) self.sleep = [[0], [10], [20], [30], [40], [50], [60]] for s in self.sleep: self.lsSleep.append(s) align = [[_("Right")], [_("Left")]] for a in align: self.lsAlign.append(a) temperature = [[_("Celsius")], [_("Fahrenheit")]] for t in temperature: self.lsTemp.append(t) # Initialize logging self.log = Logger('', 'debug', True, self.statusbar) # Get distribution specific settings self.dist = functions.getDistribution(False).lower() conf_path = join(self.scriptDir, 'cfg/conky-k.conf') self.conkyrc_template = join(self.scriptDir, 'cfg/conkyrc-k') self.lua_template = join(self.scriptDir, 'cfg/clock_rings-k.lua') self.dateTitleColorDefault = DATE_TITLE_K.upper() self.dayClockColorDefault = DAY_CLOCK_K.upper() self.systemInfoColorDefault = SYS_INFO_K.upper() if 'solydx' in self.dist: conf_path = join(self.scriptDir, 'cfg/conky-x.conf') self.conkyrc_template = join(self.scriptDir, 'cfg/conkyrc-x') self.lua_template = join(self.scriptDir, 'cfg/clock_rings-x.lua') self.dateTitleColorDefault = DATE_TITLE_X.upper() self.dayClockColorDefault = DAY_CLOCK_X.upper() self.systemInfoColorDefault = SYS_INFO_X.upper() # Read from config file self.cfg = Config(conf_path) self.commandCore = self.cfg.getValue('COMMANDS', 'core') self.commandCpu = self.cfg.getValue('COMMANDS', 'cpu') self.commandChassis = self.cfg.getValue('COMMANDS', 'chassis') self.commandHdd = self.cfg.getValue('COMMANDS', 'hdd') self.commandLanIp = self.cfg.getValue('COMMANDS', 'lanip') self.commandIp = self.cfg.getValue('COMMANDS', 'ip') self.commandKernel = self.cfg.getValue('COMMANDS', 'kernel') # Init variables self.ec = ExecCmd(self.log) self.selectedMenuItem = None self.defaultSpeed = '1000' self.home = expanduser("~/") self.luaDir = join(self.home, '.lua/scripts') self.lua = join(self.luaDir, 'clock_rings.lua') self.conkyrc = join(self.home, '.conkyrc') self.conkyStart = join(self.home, '.conky-start') self.autostartDir = join(self.home, '.config/autostart') self.desktop = join(self.autostartDir, 'conky.desktop') # Get current settings self.getSettings() # Show version number in status bar self.version = functions.getPackageVersion('solydxk-conky') functions.pushMessage(self.statusbar, self.version) # Show preferences at startup self.on_btnPreferences_clicked() self.builder.connect_signals(self) self.window.show()