def getPackageStatus(packageName): try: cmdChk = 'apt-cache policy ' + str(packageName) status = '' ec = ExecCmd(log) packageCheck = ec.run(cmdChk, False) for line in packageCheck: instChk = re.search('installed:.*\d.*', line.lower()) if not instChk: instChk = re.search('installed.*', line.lower()) if instChk: # Package is not installed log.write('Package not installed: ' + str(packageName), 'drivers.getPackageStatus', 'debug') status = packageStatus[1] break else: # Package is installed log.write('Package is installed: ' + str(packageName), 'drivers.getPackageStatus', 'debug') status = packageStatus[0] break # Package is not found: uninstallable if not status: log.write('Package not found: ' + str(packageName), 'drivers.getPackageStatus', 'warning') status = packageStatus[2] except: # If something went wrong: assume that package is uninstallable log.write('Could not get status info for package: ' + str(packageName), 'drivers.getPackageStatus', 'error') status = packageStatus[2] return status
def getCurrentTheme(): curTheme = [''] if getCurrentResolution() != '': cmd = '/usr/sbin/plymouth-set-default-theme' ec = ExecCmd(log) curTheme = ec.run(cmd, False) return curTheme[0]
def __init__(self, collectData=True): # Get the settings self.scriptDir = abspath(dirname(__file__)) self.filesDir = join(self.scriptDir, "files") self.ec = ExecCmd() self.cfg = Config(join(self.filesDir, 'updatemanager.conf')) self.settings = self.getSettings() self.umfiles = {} self.umfiles['umupd'] = join(self.filesDir, ".umupd") self.umfiles['umrefresh'] = join(self.filesDir, ".umrefresh") self.umfiles['ummaintenance'] = join(self.filesDir, ".ummaintenance") self.umfiles['uminstallum'] = join(self.filesDir, ".uminstallum") # Variables self.localUpdVersion = None self.serverUpdVersion = None self.newUpd = False self.hasInternet = False self.repos = [] # Set global variables self.umfilesUrl = self.getUmFilesUrl() if collectData: self.collectData()
def getLatestLunuxHeader(includeString='', excludeString=''): lhList = [] ec = ExecCmd(log) list = ec.run('apt search linux-headers', False) startIndex = 14 for item in list: lhMatch = re.search('linux-headers-\d[a-zA-Z0-9-\.]*', item) if lhMatch: lh = lhMatch.group(0) addLh = True if includeString != '': inclMatch = re.search(includeString, lh) if inclMatch: if excludeString != '': exclMatch = re.search(excludeString, lh) if exclMatch: addLh = False else: addLh = False # Append to list if addLh: lhList.append(lh) lhList.sort(reverse=True) return lhList[0]
def __init__(self, mountDir, unpackIso, unpackDir, queue): threading.Thread.__init__(self) self.ec = ExecCmd() self.mountDir = mountDir self.unpackIso = unpackIso self.unpackDir = unpackDir self.queue = queue self.returnMessage = None
def previewPlymouth(): cmd = "su -c 'plymouthd; plymouth --show-splash ; for ((I=0; I<10; I++)); do plymouth --update=test$I ; sleep 1; done; plymouth quit'" log.write('Preview command: ' + cmd, 'drivers.previewPlymouth', 'debug') try: ec = ExecCmd(log) ec.run(cmd, False) except Exception, detail: log.write(detail, 'drivers.previewPlymouth', 'error')
def __init__(self): # Check if script is running self.scriptDir = abspath(dirname(__file__)) self.filesDir = join(self.scriptDir, "files") self.scriptName = basename(__file__) self.umglobal = UmGlobal() self.ec = ExecCmd() # Handle arguments parser = argparse.ArgumentParser( description='Trail Update Manager Tray') parser.add_argument('-r', '--reload', action="store_true", help='') args, extra = parser.parse_known_args() print((">> args = {}".format(args))) if args.reload: pids = self.umglobal.getScriptPids("updatemanagertray.py") if len(pids) > 1: print(("updatemanagertray.py already running - kill pid {}". format(pids[0]))) os.system("kill {}".format(pids[0])) # Build status icon menu self.refreshText = _("Refresh") self.quitText = _("Quit") menu = Gtk.Menu() menuUm = Gtk.MenuItem(_("Update Manager")) menuUm.connect('activate', self.open_um) menu.append(menuUm) # Separator not functioning in wheezy #menuSep1 = Gtk.SeparatorMenuItem() #menu.append(menuSep1) menuPref = Gtk.MenuItem(_("Preferences")) menuPref.connect('activate', self.open_preferences) menu.append(menuPref) menuRefresh = Gtk.MenuItem(self.refreshText) menuRefresh.connect('activate', self.manualRefresh) menu.append(menuRefresh) menuQuit = Gtk.MenuItem(self.quitText) menuQuit.connect('activate', self.quit_tray) menu.append(menuQuit) self.statusIcon = Gtk.StatusIcon() self.umrefresh = UmRefresh(self.statusIcon, self.umglobal) self.notifier = UmNotifier(self.statusIcon, self.umglobal, self.umrefresh) self.statusIcon.connect('activate', self.icon_activate) self.statusIcon.connect('popup-menu', self.popup_menu, menu) # Initiate first check self.refresh() # Loop the refresh function # For some reason you cannot start a threaded class from init self.timeout = int(self.umglobal.settings["hrs-check-status"] * 60 * 60) GObject.timeout_add_seconds(self.timeout, self.refresh)
def getDistribution(): distribution = '' try: cmdDist = 'cat /etc/*-release | grep DISTRIB_CODENAME' ec = ExecCmd(log) dist = ec.run(cmdDist, False)[0] distribution = dist[dist.find('=') + 1:] except Exception, detail: log.write(detail, 'functions.getDistribution', 'error')
def __init__(self, distribution, loggerObject): self.distribution = distribution.lower() self.log = loggerObject self.ec = ExecCmd(self.log) # Install nvidia-detect if it isn't installed already if functions.getPackageStatus('nvidia-detect') == packageStatus[1]: self.log.write('Install nvidia-detect', 'nvidia.getNvidia', 'info') self.ec.run('apt-get -y --force-yes install nvidia-detect')
def __init__(self, distribution, loggerObject): self.distribution = distribution.lower() self.log = loggerObject self.ec = ExecCmd(self.log) self.status = '' self.currentChip = '' self.installableChip = '' self.installableDriver = '' self.hw = ''
def __init__(self, distroPath): self.ec = ExecCmd() self.dg = DistroGeneral(distroPath) distroPath = distroPath.rstrip('/') if basename(distroPath) == "root": distroPath = dirname(distroPath) self.rootPath = join(distroPath, "root") # ISO edition self.edition = self.dg.edition
def getGraphicsCard(): global graphicsCard if graphicsCard == None: cmdGraph = 'lspci | grep VGA' ec = ExecCmd(log) hwGraph = ec.run(cmdGraph, False) for line in hwGraph: graphicsCard = line[line.find(': ') + 2:] break return graphicsCard
def getDistributionDescription(): distribution = '' try: cmdDist = 'cat /etc/*-release | grep DISTRIB_DESCRIPTION' ec = ExecCmd(log) dist = ec.run(cmdDist, False)[0] distribution = dist[dist.find('=') + 1:] distribution = string.replace(distribution, '"', '') except Exception, detail: log.write(detail, 'functions.getDistributionDescription', 'error')
def __init__(self, distroPath, queue): threading.Thread.__init__(self) self.ec = ExecCmd() self.dg = DistroGeneral(distroPath) self.ed = EditDistro(distroPath) self.queue = queue self.returnMessage = None # Paths distroPath = distroPath.rstrip('/') if basename(distroPath) == "root": distroPath = dirname(distroPath) self.distroPath = distroPath self.rootPath = join(distroPath, "root") self.bootPath = join(distroPath, "boot") self.livePath = join(self.bootPath, "live") self.scriptDir = abspath(dirname(__file__)) # Check for old dir oldDir = join(self.bootPath, "solydxk") if exists(oldDir): self.ec.run("rm -r %s" % oldDir) # Make sure live directory exists if not exists(self.livePath): self.ec.run("mkdir -p %s" % self.livePath) # ISO Name self.isoName = self.dg.description # ISO distribution self.isoBaseName = self.dg.getIsoFileName() self.isoFileName = join(self.distroPath, self.isoBaseName) # Trackers, and webseeds self.trackers = "" self.webseeds = "" trackersPath = join(self.scriptDir, "files/trackers") webseedsPath = join(self.scriptDir, "files/webseeds") if exists(trackersPath): with open(trackersPath, "r") as f: lines = f.readlines() trList = [] for line in lines: trList.append(line.strip()) self.trackers = ",".join(trList) if exists(webseedsPath): with open(webseedsPath, "r") as f: lines = f.readlines() wsList = [] for line in lines: #wsList.append("%s/%s" % (line.strip(), webseedIsoName)) wsList.append("%s/%s" % (line.strip(), self.isoBaseName)) self.webseeds = ",".join(wsList)
def __init__(self, treeView, statusIcon, builder, prefs, log, newUpVersion, rtobject=None): threading.Thread.__init__(self) self.treeView = treeView self.statusIcon = statusIcon self.builder = builder self.window = self.builder.get_object("umWindow") self.newUpVersion = newUpVersion self.prefs = prefs self.log = log self.curdir = os.path.dirname(os.path.realpath(__file__)) self.sharedir = os.path.join(self.curdir.replace('/lib/', '/share/')) self.ec = ExecCmd(rtobject) print ">>>> InstallThread"
def __init__(self, treeview_update, statusIcon, builder, prefs, log, app_hidden, newUpVersion=None): threading.Thread.__init__(self) self.treeview_update = treeview_update self.statusIcon = statusIcon self.builder = builder self.window = self.builder.get_object("umWindow") self.prefs = prefs self.log = log self.app_hidden = app_hidden self.newUpVersion = newUpVersion self.curdir = os.path.dirname(os.path.realpath(__file__)) self.cfgignored = os.path.join(self.curdir, 'updatemanager.ignored') self.ec = ExecCmd() print ">>>> RefreshThread"
def __init__(self, umglobal): self.ec = ExecCmd() self.umglobal = umglobal self.kernelArchitecture = self.umglobal.getKernelArchitecture() self.packagesInfo = [] self.downgradablePackages = [] self.kernelPackages = [] self.upgradablePackages = [] self.newPackages = [] self.removedPackages = [] self.heldbackPackages = [] self.notavailablePackages = [] self.orphanedPackages = []
def getAvailableThemes(): startmatch = '39m-' cmd = 'apt search ' + avlThemesSearchstr + ' | grep ^p' ec = ExecCmd(log) availableThemes = ec.run(cmd) avlThemes = [] for line in availableThemes: matchObj = re.search('plymouth-themes-([a-zA-Z0-9-]*)', line) if matchObj: theme = matchObj.group(1) if not 'all' in theme: avlThemes.append(theme) return avlThemes
def getRemovablePackageName(theme): cmd = 'dpkg -S ' + theme + '.plymouth' log.write('Search package command: ' + cmd, 'drivers.getRemovablePackageName', 'debug') package = '' ec = ExecCmd(log) packageNames = ec.run(cmd, False) for line in packageNames: if avlThemesSearchstr in line: matchObj = re.search('(^.*):', line) if matchObj: package = matchObj.group(1) break log.write('Package found ' + package, 'drivers.getRemovablePackageName', 'debug') return package
def __init__(self, statusIcon, umglobal): self.scriptDir = abspath(dirname(__file__)) self.ec = ExecCmd() self.statusIcon = statusIcon self.umglobal = umglobal #self.apt = UmApt(self.umglobal) self.pbExec = GdkPixbuf.Pixbuf.new_from_file( self.umglobal.settings["icon-exec"]) self.pbApply = GdkPixbuf.Pixbuf.new_from_file( self.umglobal.settings["icon-apply"]) self.pbInfo = GdkPixbuf.Pixbuf.new_from_file( self.umglobal.settings["icon-info"]) self.pbDisconnected = GdkPixbuf.Pixbuf.new_from_file( self.umglobal.settings["icon-disconnected"]) self.pbError = GdkPixbuf.Pixbuf.new_from_file( self.umglobal.settings["icon-error"]) self.counter = 0 self.quit = False
def __init__(self, distroPath): self.ec = ExecCmd() distroPath = distroPath.rstrip('/') if basename(distroPath) == "root": distroPath = dirname(distroPath) self.distroPath = distroPath self.rootPath = join(distroPath, "root") self.edition = basename(distroPath) self.description = "SolydXK" infoPath = join(self.rootPath, "etc/solydxk/info") if exists(infoPath): self.edition = self.ec.run( cmd="grep EDITION= {} | cut -d'=' -f 2".format(infoPath), returnAsList=False).strip('"') self.description = self.ec.run( cmd="grep DESCRIPTION= {} | cut -d'=' -f 2".format(infoPath), returnAsList=False).strip('"')
def __init__(self, umglobal): self.ec = ExecCmd() self.umglobal = umglobal self.kernelArchitecture = self.umglobal.getKernelArchitecture() self.packagesInfo = [] self.downgradablePackages = [] self.kernelPackages = [] self.upgradablePackages = [] self.newPackages = [] self.removedPackages = [] self.heldbackPackages = [] self.notavailablePackages = [] self.orphanedPackages = [] # --force-yes is deprecated in stretch self.force = self.umglobal.get_apt_force()
def __init__(self, collectData=True): # Get the settings self.scriptDir = abspath(dirname(__file__)) self.filesDir = join(self.scriptDir, "files") self.shareDir = self.scriptDir.replace('lib', 'share') self.iconsDir = join(self.shareDir, 'icons') self.htmlDir = join(self.shareDir, "html") self.ec = ExecCmd() self.cfg = Config(join(self.filesDir, 'updatemanager.conf')) self.title = _("Update Manager") self.status = None self.isKf5 = False # Autostart self.autostartDir = '/etc/xdg/autostart' self.autostartFile = 'updatemanagertray.desktop' self.autostartSourceFile = join(self.filesDir, self.autostartFile) self.autostartDestFile = join(self.autostartDir, self.autostartFile) self.umfiles = {} self.umfiles['umupd'] = join(self.filesDir, ".umupd") self.umfiles['umrefresh'] = join(self.filesDir, ".umrefresh") self.umfiles['ummaintenance'] = join(self.filesDir, ".ummaintenance") self.umfiles['uminstallum'] = join(self.filesDir, ".uminstallum") # Status texts self.connectedText = _("Your system is up to date") self.disconnectedText = _("No internet connection") self.errorText = _("Error") self.executeText = _("Executing command") self.updatesText = _("There are updates available") self.warningText = _("Warning") # Variables self.localUpdVersion = None self.serverUpdVersion = None self.newUpd = False self.hasInternet = False self.repos = [] # Set global variables if collectData: self.collectData()
def getResolutions(minRes='', maxRes='', reverseOrder=False): cmd = 'xrandr' ec = ExecCmd(log) cmdList = ec.run(cmd, False) avlRes = [] avlResTmp = [] minW = 0 minH = 0 maxW = 0 maxH = 0 # Split the minimum and maximum resolutions if 'x' in minRes: minResList = minRes.split('x') minW = strToInt(minResList[0]) minH = strToInt(minResList[1]) if 'x' in maxRes: maxResList = maxRes.split('x') maxW = strToInt(maxResList[0]) maxH = strToInt(maxResList[1]) # Fill the list with screen resolutions for line in cmdList: for item in line.split(): if item and 'x' in item and len(item) > 2 and not '+' in item and not 'axis' in item and not 'maximum' in item: log.write('Resolution found: ' + item, 'functions.getResolutions', 'debug') itemList = item.split('x') itemW = strToInt(itemList[0]) itemH = strToInt(itemList[1]) # Check if it can be added if itemW >= minW and itemH >= minH and (maxW == 0 or itemW <= maxW) and (maxH == 0 or itemH <= maxH): log.write('Resolution added: ' + item, 'functions.getResolutions', 'debug') avlResTmp.append([itemW, itemH]) # Sort the list and return as readable resolution strings avlResTmp.sort(key=operator.itemgetter(0), reverse=reverseOrder) for res in avlResTmp: avlRes.append(str(res[0]) + 'x' + str(res[1])) return avlRes
def __init__(self): # Check if script is running self.scriptName = basename(__file__) self.umglobal = UmGlobal() # Handle arguments parser = argparse.ArgumentParser( description='SolydXK Update Manager Preferences') parser.add_argument('-r', '--reload', action="store_true", help='') args, extra = parser.parse_known_args() print(("args = {}".format(args))) if args.reload: pids = self.umglobal.getProcessPids("updatemanagerpref.py") if len(pids) > 1: print(("updatemanagerpref.py already running - kill pid {}". format(pids[0]))) os.system("kill {}".format(pids[0])) # Initiate logging self.logFile = join('/var/log', self.umglobal.settings['log']) self.log = Logger(self.logFile) # Load window and widgets self.builder = Gtk.Builder() self.builder.add_from_file( join(self.umglobal.shareDir, 'updatemanagerpref.glade')) # Preferences window objects go = self.builder.get_object self.window = go("windowPref") self.nbPref = go('nbPref') self.btnSaveMirrors = go('btnSaveMirrors') self.btnCheckMirrorsSpeed = go("btnCheckMirrorsSpeed") self.lblMirrors = go('lblMirrors') self.tvMirrors = go("tvMirrors") self.btnRemoveBlackList = go("btnRemoveBlacklist") self.btnAddBlackList = go("btnAddBlacklist") self.tvBlacklist = go("tvBlacklist") self.tvAvailable = go("tvAvailable") self.lblGeneral = go("lblGeneral") self.btnSaveGeneral = go("btnSaveGeneral") self.chkHideMaintenance = go("chkHideMaintenance") self.chkAutostart = go("chkAutostart") # GUI translations self.window.set_title(_("Update Manager Preferences")) self.btnSaveMirrors.set_label(_("Save mirrors")) self.btnCheckMirrorsSpeed.set_label(_("Check mirrors speed")) self.btnRemoveBlackList.set_label(_("Remove")) self.btnAddBlackList.set_label(_("Blacklist")) self.lblMirrors.set_label(_("Repository mirrors")) self.lblGeneral.set_label(_("General")) go("lblHideMaintenance").set_label(_("Hide maintenance")) go("lblBlacklist").set_label(_("Blacklisted packages")) go("lblMirrorsText").set_label(_("Select the fastest repository")) go("lblBlacklistText").set_label(_("Blacklisted packages")) go("lblAvailableText").set_label(_("Available packages")) go("lblGlobalSettings").set_label(_("Global settings")) # Initiate the treeview handler and connect the custom toggle event with on_tvMirrors_toggle self.tvMirrorsHandler = TreeViewHandler(self.tvMirrors) self.tvMirrorsHandler.connect('checkbox-toggled', self.on_tvMirrors_toggle) self.tvBlacklistHandler = TreeViewHandler(self.tvBlacklist) self.tvAvailableHandler = TreeViewHandler(self.tvAvailable) # Initialize self.ec = ExecCmd(loggerObject=self.log) self.queue = Queue() self.excludeMirrors = ['security', 'community'] self.activeMirrors = self.umglobal.getMirrorData( excludeMirrors=self.excludeMirrors) self.deadMirrors = self.umglobal.getMirrorData(getDeadMirrors=True) self.mirrors = self.getMirrors() self.threads = {} self.blacklist = [] self.available = [] self.fillGeneralSettings() self.fillTreeViewMirrors() self.fillTreeViewBlackList() self.fillTreeViewAvailable() # Connect the signals and show the window self.builder.connect_signals(self) self.window.show()
def __init__(self, distribution, loggerObject): self.distribution = distribution.lower() self.log = loggerObject self.ec = ExecCmd(self.log)
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/sambashare/sambashare.glade')) go = self.builder.get_object self.window = go('sambashareWindow') self.windowAdd = go('sambashareWindowAdd') self.lblTitle = go('lblTitle') self.tvShares = go('tvShares') self.btnAdd = go('btnAdd') self.btnRemove = go('btnRemove') self.txtShareDetails = go('txtShareDetails') self.lblName = go('lblName') self.lblPath = go('lblPath') self.lblComment = go('lblComment') self.lblPublic = go('lblPublic') self.lblReadOnly = go('lblReadOnly') self.txtName = go('txtName') self.txtPath = go('txtPath') self.txtComment = go('txtComment') self.chkPublic = go('chkPublic') self.chkReadOnly = go('chkReadOnly') self.btnOk = go('btnOk') self.btnCancel = go('btnCancel') # Translations self.window.set_title(_("Samba share")) self.windowAdd.set_title(_("Create samba share")) self.lblTitle.set_text(self.window.get_title()) self.lblName.set_text(_("Name")) self.lblPath.set_text(_("Path")) self.lblComment.set_text(_("Comment")) self.lblReadOnly.set_text(_("Read only")) self.lblPublic.set_text(_("Public")) # Init self.ec = ExecCmd() self.us = UserShare() self.shareName = None self.sharePath = None self.startAddNow = False # Fill treeview with shares self.tvHandler = TreeViewHandler(self.tvShares) self.refreshShares() # Command arguments args = sys.argv[1:] for arg in args: if "/" in arg: self.sharePath = arg self.startAddNow = True else: self.shareName = arg # Connect the signals and show the window self.builder.connect_signals(self) self.window.show_all() if self.startAddNow: self.on_btnAdd_clicked(None)
def getInstalledThemes(): cmd = '/usr/sbin/plymouth-set-default-theme --list' ec = ExecCmd(log) instThemes = ec.run(cmd, False) return instThemes
#import io import fnmatch import urllib.request, urllib.error, urllib.parse import gettext from os.path import join, exists, abspath from datetime import datetime from execcmd import ExecCmd from gi.repository import Gtk except Exception as detail: print(detail) exit(1) packageStatus = ['installed', 'notinstalled', 'uninstallable'] # Execute command object ec = ExecCmd() # i18n: http://docs.python.org/2/library/gettext.html #t = gettext.translation("solydxk-conky", "/usr/share/locale") #_ = t.lgettext # General ================================================ def locate(pattern, root=os.curdir, locateDirsOnly=False): '''Locate all files matching supplied filename pattern in and below supplied root directory.''' for path, dirs, files in os.walk(abspath(root)): if locateDirsOnly: obj = dirs else:
def __init__(self, log=None): self.log = log self.ec = ExecCmd()