From e1e6aacdd3e8d8694bd79b668f7f122ad9db1b0c Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Thu, 21 Oct 2010 21:51:51 +0000 Subject: Applied new-hotplug.patch from OE --- lib/python/Components/Harddisk.py | 140 ++++++++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 52 deletions(-) (limited to 'lib/python/Components') diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 7f837565..0f1a8fca 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -15,17 +15,17 @@ def readFile(filename): file.close() return data -class Harddisk: - DEVTYPE_UDEV = 0 - DEVTYPE_DEVFS = 1 +DEVTYPE_UDEV = 0 +DEVTYPE_DEVFS = 1 +class Harddisk: def __init__(self, device): self.device = device if access("/dev/.udev", 0): - self.type = self.DEVTYPE_UDEV + self.type = DEVTYPE_UDEV elif access("/dev/.devfsd", 0): - self.type = self.DEVTYPE_DEVFS + self.type = DEVTYPE_DEVFS else: print "Unable to determine structure of /dev" @@ -37,11 +37,11 @@ class Harddisk: self.disk_path = '' self.phys_path = path.realpath(self.sysfsPath('device')) - if self.type == self.DEVTYPE_UDEV: + if self.type == DEVTYPE_UDEV: self.dev_path = '/dev/' + self.device self.disk_path = self.dev_path - elif self.type == self.DEVTYPE_DEVFS: + elif self.type == DEVTYPE_DEVFS: tmp = readFile(self.sysfsPath('dev')).split(':') s_major = int(tmp[0]) s_minor = int(tmp[1]) @@ -64,9 +64,9 @@ class Harddisk: return self.device < ob.device def partitionPath(self, n): - if self.type == self.DEVTYPE_UDEV: + if self.type == DEVTYPE_UDEV: return self.dev_path + n - elif self.type == self.DEVTYPE_DEVFS: + elif self.type == DEVTYPE_DEVFS: return self.dev_path + '/part' + n def sysfsPath(self, filename): @@ -79,9 +79,9 @@ class Harddisk: def bus(self): # CF (7025 specific) - if self.type == self.DEVTYPE_UDEV: + if self.type == DEVTYPE_UDEV: ide_cf = False # FIXME - elif self.type == self.DEVTYPE_DEVFS: + elif self.type == DEVTYPE_DEVFS: ide_cf = self.device[:2] == "hd" and "host0" not in self.dev_path internal = "pci" in self.phys_path @@ -142,7 +142,7 @@ class Harddisk: def numPartitions(self): numPart = -1 - if self.type == self.DEVTYPE_UDEV: + if self.type == DEVTYPE_UDEV: try: devdir = listdir('/dev') except OSError: @@ -151,7 +151,7 @@ class Harddisk: if filename.startswith(self.device): numPart += 1 - elif self.type == self.DEVTYPE_DEVFS: + elif self.type == DEVTYPE_DEVFS: try: idedir = listdir(self.dev_path) except OSError: @@ -413,24 +413,38 @@ class Partition: return True return False -DEVICEDB = \ +DEVICEDB_SR = \ {"dm8000": { - # dm8000: - "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": "Front USB Slot", - "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0": "Back, upper USB Slot", - "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0": "Back, lower USB Slot", - "/devices/platform/brcm-ehci-1.1/usb2/2-1/2-1:1.0/host1/target1:0:0/1:0:0:0": "DVD Drive", + "/devices/pci0000:01/0000:01:00.0/host0/target0:0:0/0:0:0:0": _("DVD Drive"), + "/devices/pci0000:01/0000:01:00.0/host1/target1:0:0/1:0:0:0": _("DVD Drive"), + "/devices/platform/brcm-ehci-1.1/usb2/2-1/2-1:1.0/host3/target3:0:0/3:0:0:0": _("DVD Drive"), + }, + "dm800": + { + }, + "dm7025": + { + } + } + +DEVICEDB = \ + {"dm8000": + { + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": _("Front USB Slot"), + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0": _("Back, upper USB Slot"), + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0": _("Back, lower USB Slot"), + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": _("Front USB Slot"), + "/devices/platform/brcm-ehci-1.1/usb2/2-1/2-1:1.0/": _("Internal USB Slot"), + "/devices/platform/brcm-ohci-1.1/usb4/4-1/4-1:1.0/": _("Internal USB Slot"), }, "dm800": { - # dm800: "/devices/platform/brcm-ehci.0/usb1/1-2/1-2:1.0": "Upper USB Slot", "/devices/platform/brcm-ehci.0/usb1/1-1/1-1:1.0": "Lower USB Slot", }, "dm7025": { - # dm7025: "/devices/pci0000:00/0000:00:14.1/ide1/1.0": "CF Card Slot", #hdc "/devices/pci0000:00/0000:00:14.1/ide0/0.0": "Internal Harddisk" } @@ -441,6 +455,7 @@ class HarddiskManager: self.hdd = [ ] self.cd = "" self.partitions = [ ] + self.devices_scanned_on_init = [ ] self.on_partition_list_change = CList() @@ -508,24 +523,23 @@ class HarddiskManager: def enumerateBlockDevices(self): print "enumerating block devices..." for blockdev in listdir("/sys/block"): - error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(blockdev) - print "found block device '%s':" % blockdev, - if error: - print "error querying properties" - elif blacklisted: - print "blacklisted" - elif not medium_found: - print "no medium" - else: - print "ok, removable=%s, cdrom=%s, partitions=%s, device=%s" % (removable, is_cdrom, partitions, blockdev) - - self.addHotplugPartition(blockdev) - for part in partitions: - self.addHotplugPartition(part) + error, blacklisted, removable, is_cdrom, partitions, medium_found = self.addHotplugPartition(blockdev) + if not error and not blacklisted: + if medium_found: + for part in partitions: + self.addHotplugPartition(part) + self.devices_scanned_on_init.append((blockdev, removable, is_cdrom, medium_found)) def getAutofsMountpoint(self, device): return "/autofs/%s/" % (device) + def is_hard_mounted(self, device): + mounts = file('/proc/mounts').read().split('\n') + for x in mounts: + if x.find('/autofs') == -1 and x.find(device) != -1: + return True + return False + def addHotplugPartition(self, device, physdev = None): if not physdev: dev, part = self.splitDeviceName(device) @@ -535,22 +549,36 @@ class HarddiskManager: physdev = dev print "couldn't determine blockdev physdev for device", device - # device is the device name, without /dev - # physdev is the physical device path, which we (might) use to determine the userfriendly name - description = self.getUserfriendlyDeviceName(device, physdev) + error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(device) + print "found block device '%s':" % device, - p = Partition(mountpoint = self.getAutofsMountpoint(device), description = description, force_mounted = True, device = device) - self.partitions.append(p) - self.on_partition_list_change("add", p) + if blacklisted: + print "blacklisted" + else: + if error: + print "error querying properties" + elif not medium_found: + print "no medium" + else: + print "ok, removable=%s, cdrom=%s, partitions=%s" % (removable, is_cdrom, partitions) + + l = len(device) + if l: + # see if this is a harddrive + if not device[l-1].isdigit() and not removable and not is_cdrom: + self.hdd.append(Harddisk(device)) + self.hdd.sort() + SystemInfo["Harddisk"] = len(self.hdd) > 0 + + if (not removable or medium_found) and not self.is_hard_mounted(device): + # device is the device name, without /dev + # physdev is the physical device path, which we (might) use to determine the userfriendly name + description = self.getUserfriendlyDeviceName(device, physdev) + p = Partition(mountpoint = self.getAutofsMountpoint(device), description = description, force_mounted = True, device = device) + self.partitions.append(p) + self.on_partition_list_change("add", p) - # see if this is a harddrive - l = len(device) - if l and not device[l-1].isdigit(): - error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(device) - if not blacklisted and not removable and not is_cdrom and medium_found: - self.hdd.append(Harddisk(device)) - self.hdd.sort() - SystemInfo["Harddisk"] = len(self.hdd) > 0 + return error, blacklisted, removable, is_cdrom, partitions, medium_found def removeHotplugPartition(self, device): mountpoint = self.getAutofsMountpoint(device) @@ -608,15 +636,23 @@ class HarddiskManager: def getUserfriendlyDeviceName(self, dev, phys): dev, part = self.splitDeviceName(dev) description = "External Storage %s" % dev + have_model_descr = False try: description = readFile("/sys" + phys + "/model") + have_model_descr = True except IOError, s: print "couldn't read model: ", s from Tools.HardwareInfo import HardwareInfo - for physdevprefix, pdescription in DEVICEDB.get(HardwareInfo().device_name,{}).items(): + if dev.find('sr') == 0 and dev[2].isdigit(): + devicedb = DEVICEDB_SR + else: + devicedb = DEVICEDB + for physdevprefix, pdescription in devicedb.get(HardwareInfo().device_name,{}).items(): if phys.startswith(physdevprefix): - description = pdescription - + if have_model_descr: + description = pdescription + ' - ' + description + else: + description = pdescription # not wholedisk and not partition 1 if part and part != 1: description += " (Partition %d)" % part -- cgit v1.2.3 From 879d60c88e24c2c3f2aab9dff73192c901f63f31 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Thu, 28 Oct 2010 20:29:01 +0200 Subject: use eEnv::resolve() / eEnv.resolve() --- lib/base/encoding.cpp | 7 +++--- lib/dvb/db.cpp | 15 ++++++------ lib/dvb/scan.cpp | 6 +++-- lib/python/Components/NimManager.py | 4 ++-- lib/python/Components/Renderer/Picon.py | 4 ++-- lib/python/Components/UsageConfig.py | 4 ++-- .../CommonInterfaceAssignment/plugin.py | 6 ++--- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 6 ++--- .../Plugins/SystemPlugins/SkinSelector/plugin.py | 3 ++- .../SystemPlugins/SoftwareManager/BackupRestore.py | 4 ++-- .../SystemPlugins/SoftwareManager/ImageWizard.py | 3 ++- .../SystemPlugins/SoftwareManager/plugin.py | 6 ++--- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 4 ++-- lib/python/Screens/ChannelSelection.py | 4 ++-- lib/python/Screens/Setup.py | 3 ++- lib/python/Screens/Wizard.py | 4 ++-- lib/python/Tools/Directories.py | 27 +++++++++++----------- main/bsod.cpp | 16 +++++-------- main/enigma-gdi.cpp | 3 ++- main/enigma-gui.cpp | 2 +- main/enigma.cpp | 17 ++++++++------ 21 files changed, 78 insertions(+), 70 deletions(-) (limited to 'lib/python/Components') diff --git a/lib/base/encoding.cpp b/lib/base/encoding.cpp index 8b4b592b..361acce5 100644 --- a/lib/base/encoding.cpp +++ b/lib/base/encoding.cpp @@ -2,6 +2,7 @@ #include #include #include +#include eDVBTextEncodingHandler encodingHandler; // the one and only instance @@ -17,8 +18,8 @@ inline char toupper(char c) eDVBTextEncodingHandler::eDVBTextEncodingHandler() { - const char * file=DATADIR "/enigma2/encoding.conf"; - FILE *f = fopen(file, "rt"); + std::string file = eEnv::resolve("${datadir}/enigma2/encoding.conf"); + FILE *f = fopen(file.c_str(), "rt"); if (f) { char *line = (char*) malloc(256); @@ -61,7 +62,7 @@ eDVBTextEncodingHandler::eDVBTextEncodingHandler() free(line); } else - eDebug("[eDVBTextEncodingHandler] couldn't open %s !", file); + eDebug("[eDVBTextEncodingHandler] couldn't open %s !", file.c_str()); } void eDVBTextEncodingHandler::getTransponderDefaultMapping(int tsidonid, int &table) diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index 38be6359..522035eb 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,7 @@ RESULT eBouquet::moveService(const eServiceReference &ref, unsigned int pos) RESULT eBouquet::flushChanges() { - FILE *f=fopen((CONFIGDIR"/enigma2/"+m_filename).c_str(), "w"); + FILE *f=fopen(eEnv::resolve("${sysconfdir}/enigma2/" + m_filename).c_str(), "w"); if (!f) return -1; if ( fprintf(f, "#NAME %s\r\n", m_bouquet_name.c_str()) < 0 ) @@ -280,7 +281,7 @@ DEFINE_REF(eDVBDB); void eDVBDB::reloadServicelist() { - loadServicelist(CONFIGDIR"/enigma2/lamedb"); + loadServicelist(eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()); } void eDVBDB::parseServiceData(ePtr s, std::string str) @@ -324,14 +325,14 @@ void eDVBDB::loadServicelist(const char *file) { eDebug("---- opening lame channel db"); FILE *f=fopen(file, "rt"); - if (!f && strcmp(file, CONFIGDIR"/enigma2/lamedb") == 0) + if (!f && strcmp(file, eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()) == 0) { struct stat s; if ( !stat("lamedb", &s) ) { - if ( !stat(CONFIGDIR"/enigma2", &s) ) + if ( !stat(eEnv::resolve("${sysconfdir}/enigma2").c_str(), &s) ) { - rename("lamedb", CONFIGDIR"/enigma2/lamedb" ); + rename("lamedb", eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()); reloadServicelist(); } } @@ -594,7 +595,7 @@ void eDVBDB::saveServicelist(const char *file) void eDVBDB::saveServicelist() { - saveServicelist(CONFIGDIR"/enigma2/lamedb"); + saveServicelist(eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()); } void eDVBDB::loadBouquet(const char *path) @@ -618,7 +619,7 @@ void eDVBDB::loadBouquet(const char *path) std::list &list = bouquet.m_services; list.clear(); - std::string p = CONFIGDIR"/enigma2/"; + std::string p = eEnv::resolve("${sysconfdir}/enigma2/"); p+=path; eDebug("loading bouquet... %s", p.c_str()); FILE *fp=fopen(p.c_str(), "rt"); diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index b37aa714..d559614c 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,8 @@ eDVBScan::eDVBScan(iDVBChannel *channel, bool usePAT, bool debug) if (m_channel->getDemux(m_demux)) SCAN_eDebug("scan: failed to allocate demux!"); m_channel->connectStateChange(slot(*this, &eDVBScan::stateChange), m_stateChanged_connection); - FILE *f = fopen("/etc/enigma2/scan_tp_valid_check.py", "r"); + std::string filename = eEnv::resolve("${sysconfdir}/scan_tp_valid_check.py"); + FILE *f = fopen(filename.c_str(), "r"); if (f) { char code[16384]; @@ -37,7 +39,7 @@ eDVBScan::eDVBScan(iDVBChannel *channel, bool usePAT, bool debug) if (rd) { code[rd]=0; - m_additional_tsid_onid_check_func = Py_CompileString(code, "/etc/enigma2/scan_tp_valid_check.py", Py_file_input); + m_additional_tsid_onid_check_func = Py_CompileString(code, filename.c_str(), Py_file_input); } fclose(f); } diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 73031861..d8a7c5c2 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -10,7 +10,7 @@ from enigma import eDVBSatelliteEquipmentControl as secClass, \ eDVBSatelliteDiseqcParameters as diseqcParam, \ eDVBSatelliteSwitchParameters as switchParam, \ eDVBSatelliteRotorParameters as rotorParam, \ - eDVBResourceManager, eDVBDB + eDVBResourceManager, eDVBDB, eEnv from time import localtime, mktime from datetime import datetime @@ -1082,7 +1082,7 @@ def InitNimManager(nimmgr): unicablelnbproducts = {} unicablematrixproducts = {} - doc = xml.etree.cElementTree.parse("/usr/share/enigma2/unicable.xml") + doc = xml.etree.cElementTree.parse(eEnv.resolve("${datadir}/enigma2/unicable.xml")) root = doc.getroot() entry = root.find("lnb") diff --git a/lib/python/Components/Renderer/Picon.py b/lib/python/Components/Renderer/Picon.py index 5ae43ed8..51dc09a5 100644 --- a/lib/python/Components/Renderer/Picon.py +++ b/lib/python/Components/Renderer/Picon.py @@ -2,11 +2,11 @@ ## Picon renderer by Gruffy .. some speedups by Ghost ## from Renderer import Renderer -from enigma import ePixmap +from enigma import ePixmap, eEnv from Tools.Directories import fileExists, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, resolveFilename class Picon(Renderer): - searchPaths = ('/usr/share/enigma2/%s/', + searchPaths = (eEnv.resolve('${datadir}/enigma2/%s/'), '/media/cf/%s/', '/media/usb/%s/') diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index b86c1a13..8ea9aa6a 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -1,7 +1,7 @@ from Components.Harddisk import harddiskmanager from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigLocations from Tools.Directories import resolveFilename, SCOPE_HDD -from enigma import Misc_Options, setTunerTypePriorityOrder; +from enigma import Misc_Options, setTunerTypePriorityOrder, eEnv; from SystemInfo import SystemInfo import os @@ -94,7 +94,7 @@ def InitUsageConfig(): SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output() - config.usage.keymap = ConfigText(default = "/usr/share/enigma2/keymap.xml") + config.usage.keymap = ConfigText(default = eEnv.resolve("${datadir}/enigma2/keymap.xml")) config.seek = ConfigSubsection() config.seek.selfdefined_13 = ConfigNumber(default=15) diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py index 2c0edf53..52296c66 100755 --- a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py +++ b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py @@ -12,7 +12,7 @@ from ServiceReference import ServiceReference from Plugins.Plugin import PluginDescriptor from xml.etree.cElementTree import parse as ci_parse from Tools.XMLTools import elementsWithTag, mergeText, stringToXML -from enigma import eDVBCI_UI, eDVBCIInterfaces +from enigma import eDVBCI_UI, eDVBCIInterfaces, eEnv from os import system, path as os_path @@ -115,7 +115,7 @@ class CIconfigMenu(Screen): Screen.__init__(self, session) self.ci_slot=ci_slot - self.filename="/etc/enigma2/ci"+str(self.ci_slot)+".xml" + self.filename = eEnv.resolve("${sysconfdir}/enigma2/ci") + str(self.ci_slot) + ".xml" self["key_red"] = StaticText(_("Delete")) self["key_green"] = StaticText(_("add Service")) @@ -567,7 +567,7 @@ def activate_all(session): return Len > 0 and definitions[Len-1].text or default for ci in range(NUM_CI): - filename="/etc/enigma2/ci"+str(ci)+".xml" + filename = eEnv.resolve("${sysconfdir}/enigma2/ci") + str(ci) + ".xml" if not os_path.exists(filename): print "[CI_Activate_Config_CI%d] no config file found" %ci diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index ba96c071..3504d4cb 100755 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -14,7 +14,7 @@ from Screens.TaskView import JobView from Tools.Directories import fileExists from Tools.HardwareInfo import HardwareInfo from os import system -from enigma import eConsoleAppContainer, quitMainloop +from enigma import eConsoleAppContainer, quitMainloop, eEnv from Components.About import about class md5Postcondition(Condition): @@ -51,7 +51,7 @@ class md5verify(Task): class writeNAND(Task): def __init__(self, job, param, box): Task.__init__(self,job, ("Writing image file to NAND Flash")) - self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/writenfi-mipsel-2.6.18-r1") + self.setTool(eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/NFIFlash/writenfi-mipsel-2.6.18-r1")) if box == "dm7025": self.end = 256 elif box[:5] == "dm800": @@ -226,4 +226,4 @@ class NFIFlash(Screen): if self.job.status == self.job.FINISHED: self["status"].text = ("rebooting...") from os import system - system("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/kill_e2_reboot.sh") + system(eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/NFIFlash/kill_e2_reboot.sh")) diff --git a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py index 997b9571..30cbb6b6 100755 --- a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py @@ -12,12 +12,13 @@ from Plugins.Plugin import PluginDescriptor from Components.config import config from Tools.Directories import resolveFilename, SCOPE_PLUGINS from os import path, walk +from enigma import eEnv class SkinSelector(Screen): # for i18n: # _("Choose your Skin") skinlist = [] - root = "/usr/share/enigma2/" + root = eEnv.resolve("${datadir}/enigma2/") def __init__(self, session, args = None): diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index 7bd7d7a2..01649bb3 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -11,7 +11,7 @@ from Components.config import config from Components.ConfigList import ConfigList,ConfigListScreen from Components.FileList import MultiFileSelectList from Plugins.Plugin import PluginDescriptor -from enigma import eTimer +from enigma import eTimer, eEnv from Tools.Directories import * from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK from time import gmtime, strftime, localtime @@ -20,7 +20,7 @@ from datetime import date config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) -config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) def getBackupPath(): backuppath = config.plugins.configurationbackup.backuplocation.value diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py index 1797e4fe..32d7140a 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py @@ -9,13 +9,14 @@ from Plugins.Plugin import PluginDescriptor from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK +from enigma import eEnv from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigBoolean from Components.Harddisk import harddiskmanager config.misc.firstrun = ConfigBoolean(default = True) config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) -config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) backupfile = "enigma2settingsbackup.tar.gz" diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 707663a0..e1f3e1de 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -28,7 +28,7 @@ from Components.Network import iNetwork from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR from Tools.LoadPixmap import LoadPixmap from Tools.NumericalTextInput import NumericalTextInput -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad, eRCInput, getPrevAsciiCode +from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad, eRCInput, getPrevAsciiCode, eEnv from cPickle import dump, load from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK from time import time, gmtime, strftime, localtime @@ -43,7 +43,7 @@ from SoftwareTools import iSoftwareTools config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) -config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) config.plugins.SoftwareManager = ConfigSubsection() config.plugins.SoftwareManager.overwriteConfigFiles = ConfigSelection( @@ -1684,7 +1684,7 @@ class PacketManager(Screen, NumericalTextInput): self.cmdList = [] self.cachelist = [] self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs) - self.cache_file = '/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache' #Path to cache directory + self.cache_file = eEnv.resolve('${libdir}/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache') #Path to cache directory self.oktext = _("\nAfter pressing OK, please wait!") self.unwanted_extensions = ('-dbg', '-dev', '-doc', 'busybox') self.opkgAvail = fileExists('/usr/bin/opkg') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 28ee363e..a13c7975 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -1,4 +1,4 @@ -from enigma import eTimer, eTPM +from enigma import eTimer, eTPM, eEnv from Screens.Screen import Screen from Components.ActionMap import ActionMap, NumberActionMap from Components.Pixmap import Pixmap,MultiPixmap @@ -18,7 +18,7 @@ from Tools.HardwareInfo import HardwareInfo from Wlan import Wlan, wpaSupplicant, iStatus import sha -plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan" +plugin_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/WirelessLan") list = [] list.append("WEP") diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 34316f01..c07e3495 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -8,7 +8,7 @@ from Components.MenuList import MenuList from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase profile("ChannelSelection.py 1") from EpgSelection import EPGSelection -from enigma import eServiceReference, eEPGCache, eServiceCenter, eRCInput, eTimer, eDVBDB, iPlayableService, iServiceInformation, getPrevAsciiCode +from enigma import eServiceReference, eEPGCache, eServiceCenter, eRCInput, eTimer, eDVBDB, iPlayableService, iServiceInformation, getPrevAsciiCode, eEnv from Components.config import config, ConfigSubsection, ConfigText from Tools.NumericalTextInput import NumericalTextInput profile("ChannelSelection.py 2") @@ -544,7 +544,7 @@ class ChannelSelectionEdit: refstr = refstr[pos+14:] pos = refstr.find('"') if pos != -1: - filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2 + filename = eEnv.resolve('${sysconfdir}/enigma2/') + refstr[:pos] self.removeCurrentService() try: if filename is not None: diff --git a/lib/python/Screens/Setup.py b/lib/python/Screens/Setup.py index e9c3c680..61e6fdd7 100755 --- a/lib/python/Screens/Setup.py +++ b/lib/python/Screens/Setup.py @@ -4,6 +4,7 @@ from Components.config import config, ConfigNothing from Components.SystemInfo import SystemInfo from Components.ConfigList import ConfigListScreen from Components.Sources.StaticText import StaticText +from enigma import eEnv import xml.etree.cElementTree @@ -14,7 +15,7 @@ try: setupfile = file('data/setup.xml', 'r') except: # if not found in the current path, we use the global datadir-path - setupfile = file('/usr/share/enigma2/setup.xml', 'r') + setupfile = file(eEnv.resolve('${datadir}/enigma2/setup.xml'), 'r') setupdom = xml.etree.cElementTree.parse(setupfile) setupfile.close() diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index a752d31c..61e1d5ef 100755 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -10,7 +10,7 @@ from Components.ActionMap import NumberActionMap from Components.MenuList import MenuList from Components.ConfigList import ConfigList from Components.Sources.List import List -from enigma import eTimer +from enigma import eTimer, eEnv from xml.sax import make_parser from xml.sax.handler import ContentHandler @@ -178,7 +178,7 @@ class Wizard(Screen): parser.setContentHandler(wizardHandler) for xmlfile in self.xmlfile: if xmlfile[0] != '/': - parser.parse('/usr/share/enigma2/' + xmlfile) + parser.parse(eEnv.resolve('${datadir}/enigma2/') + xmlfile) else: parser.parse(xmlfile) diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index 8ed2c8a4..518db49d 100755 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -3,6 +3,7 @@ from os import path as os_path, mkdir, rmdir, system, walk, stat as os_stat, listdir, readlink, makedirs, error as os_error, symlink, access, F_OK, R_OK, W_OK from stat import S_IMODE from re import compile +from enigma import eEnv try: from os import chmod @@ -39,26 +40,26 @@ PATH_CREATE = 0 PATH_DONTCREATE = 1 PATH_FALLBACK = 2 defaultPaths = { - SCOPE_TRANSPONDERDATA: ("/etc/", PATH_DONTCREATE), - SCOPE_SYSETC: ("/etc/", PATH_DONTCREATE), - SCOPE_FONTS: ("/usr/share/fonts/", PATH_DONTCREATE), - SCOPE_CONFIG: ("/etc/enigma2/", PATH_CREATE), - SCOPE_PLUGINS: ("/usr/lib/enigma2/python/Plugins/", PATH_CREATE), + SCOPE_TRANSPONDERDATA: (eEnv.resolve("${sysconfdir}/"), PATH_DONTCREATE), + SCOPE_SYSETC: (eEnv.resolve("${sysconfdir}/"), PATH_DONTCREATE), + SCOPE_FONTS: (eEnv.resolve("${datadir}/fonts/"), PATH_DONTCREATE), + SCOPE_CONFIG: (eEnv.resolve("${sysconfdir}/enigma2/"), PATH_CREATE), + SCOPE_PLUGINS: (eEnv.resolve("${libdir}/enigma2/python/Plugins/"), PATH_CREATE), - SCOPE_LANGUAGE: ("/usr/share/enigma2/po/", PATH_DONTCREATE), + SCOPE_LANGUAGE: (eEnv.resolve("${datadir}/enigma2/po/"), PATH_DONTCREATE), - SCOPE_SKIN: ("/usr/share/enigma2/", PATH_DONTCREATE), - SCOPE_SKIN_IMAGE: ("/usr/share/enigma2/", PATH_DONTCREATE), + SCOPE_SKIN: (eEnv.resolve("${datadir}/enigma2/"), PATH_DONTCREATE), + SCOPE_SKIN_IMAGE: (eEnv.resolve("${datadir}/enigma2/"), PATH_DONTCREATE), SCOPE_HDD: ("/hdd/movie/", PATH_DONTCREATE), SCOPE_MEDIA: ("/media/", PATH_DONTCREATE), - SCOPE_PLAYLIST: ("/etc/enigma2/playlist/", PATH_CREATE), + SCOPE_PLAYLIST: (eEnv.resolve("${sysconfdir}/enigma2/playlist/"), PATH_CREATE), SCOPE_USERETC: ("", PATH_DONTCREATE), # user home directory - SCOPE_DEFAULTDIR: ("/usr/share/enigma2/defaults/", PATH_CREATE), + SCOPE_DEFAULTDIR: (eEnv.resolve("${datadir}/enigma2/defaults/"), PATH_CREATE), SCOPE_DEFAULTPARTITION: ("/dev/mtdblock/6", PATH_DONTCREATE), - SCOPE_DEFAULTPARTITIONMOUNTDIR: ("/usr/share/enigma2/dealer", PATH_CREATE), - SCOPE_METADIR: ("/usr/share/meta", PATH_CREATE), + SCOPE_DEFAULTPARTITIONMOUNTDIR: (eEnv.resolve("${datadir}/enigma2/dealer"), PATH_CREATE), + SCOPE_METADIR: (eEnv.resolve("${datadir}/meta"), PATH_CREATE), } FILE_COPY = 0 # copy files from fallback dir to the basedir @@ -67,7 +68,7 @@ PATH_COPY = 2 # copy the complete fallback dir to the basedir PATH_MOVE = 3 # move the fallback dir to the basedir (can be used for changes in paths) fallbackPaths = { SCOPE_CONFIG: [("/home/root/", FILE_MOVE), - ("/usr/share/enigma2/defaults/", FILE_COPY)], + (eEnv.resolve("${datadir}/enigma2/defaults/"), FILE_COPY)], SCOPE_HDD: [("/hdd/movies", PATH_MOVE)] } diff --git a/main/bsod.cpp b/main/bsod.cpp index 68b5d571..c0362832 100755 --- a/main/bsod.cpp +++ b/main/bsod.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -65,7 +66,7 @@ static void addToLogbuffer(int level, const std::string &log) static std::string getConfigFileValue(const char *entry) { - std::string configfile = "/etc/enigma2/settings"; + std::string configfile = eEnv::resolve("${sysconfdir}/enigma2/settings"); std::string configvalue; if (entry) { @@ -140,8 +141,8 @@ static std::string getFileContent(const char *file) return filecontent; } -static std::string execCommand(char* cmd) { - FILE* pipe = popen(cmd, "r"); +static std::string execCommand(std::string cmd) { + FILE* pipe = popen(cmd.c_str(), "r"); if (!pipe) return "Error"; char buffer[STDBUFFER_SIZE]; @@ -156,11 +157,6 @@ static std::string execCommand(char* cmd) { return result; } -extern std::string execCommand(); -extern std::string getConfigFileValue(); -extern std::string getFileContent(); -extern std::string getLogBuffer(); - #define INFOFILE "/maintainer.info" void bsodFatal(const char *component) @@ -274,7 +270,7 @@ void bsodFatal(const char *component) dreamboxca[strlen(dreamboxca)-1] = 0; fprintf(f, "\t\t\n\t\t\n\t\t\n", dreamboxca); } - std::string settings = getFileContent("/etc/enigma2/settings"); + std::string settings = getFileContent(eEnv::resolve("${sysconfdir}/enigma2/settings").c_str()); if (settings != "Error") { fprintf(f, "\t\t\n\t\t\n\t\t\n", settings.c_str()); @@ -336,7 +332,7 @@ void bsodFatal(const char *component) fprintf(f, "\t\n"); std::string buffer = getLogBuffer(); fprintf(f, "\t\t\n\t\t\n\t\t\n", buffer.c_str()); - std::string pythonmd5 = execCommand("find /usr/lib/enigma2/python/ -name \"*.py\" | xargs md5sum"); + std::string pythonmd5 = execCommand("find " + eEnv::resolve("${libdir}/enigma2/python/") + " -name \"*.py\" | xargs md5sum"); fprintf(f, "\t\t\n\t\t\n\t\t\n", pythonmd5.c_str()); fprintf(f, "\t\n"); diff --git a/main/enigma-gdi.cpp b/main/enigma-gdi.cpp index 144e2d3a..328fba44 100644 --- a/main/enigma-gdi.cpp +++ b/main/enigma-gdi.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ int main() pal[a | 0x10] = (0x111111 * a) | 0xFF; p.setPalette(pal, 0, 256); - fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Regular", 100); + fontRenderClass::getInstance()->AddFont(eEnv::resolve("${datadir}/fonts/arial.ttf"), "Regular", 100); p.resetClip(gRegion(eRect(0, 0, 720, 576))); diff --git a/main/enigma-gui.cpp b/main/enigma-gui.cpp index e53fccab..2ba61067 100644 --- a/main/enigma-gui.cpp +++ b/main/enigma-gui.cpp @@ -67,7 +67,7 @@ int main() pal[a | 0x10] = (0x111111 * a) | 0xFF; p.setPalette(pal, 0, 256); - fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Regular", 100); + fontRenderClass::getInstance()->AddFont(eEnv::resolve("${datadir}/fonts/arial.ttf"), "Regular", 100); eWidgetDesktop dsk(eSize(720, 576)); dsk.setDC(my_dc); diff --git a/main/enigma.cpp b/main/enigma.cpp index b3364679..882af996 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -136,7 +137,7 @@ int main(int argc, char **argv) gst_init(&argc, &argv); // set pythonpath if unset - setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0); + setenv("PYTHONPATH", eEnv::resolve("${libdir}/enigma2/python").c_str(), 0); printf("PYTHONPATH: %s\n", getenv("PYTHONPATH")); bsodLogInit(); @@ -186,7 +187,7 @@ int main(int argc, char **argv) dsk_lcd.setDC(my_lcd_dc); ePtr m_pm; - loadPNG(m_pm, DATADIR "/enigma2/skin_default/pal.png"); + loadPNG(m_pm, eEnv::resolve("${datadir}/enigma2/skin_default/pal.png").c_str()); if (!m_pm) { eFatal("pal.png not found!"); @@ -209,14 +210,16 @@ int main(int argc, char **argv) ePtr wait[MAX_SPINNER]; for (i=0; i Date: Wed, 3 Nov 2010 19:29:10 +0100 Subject: install keymaps --- configure.ac | 1 + data/Makefile.am | 2 +- data/keymaps/Makefile.am | 6 ++++++ data/keymaps/dream-de.info | 2 ++ data/keymaps/dream-de.kmap | Bin 0 -> 2823 bytes data/keymaps/eng.info | 2 ++ data/keymaps/eng.kmap | Bin 0 -> 2823 bytes lib/python/Components/Keyboard.py | 7 ++++--- 8 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 data/keymaps/Makefile.am create mode 100644 data/keymaps/dream-de.info create mode 100644 data/keymaps/dream-de.kmap create mode 100644 data/keymaps/eng.info create mode 100644 data/keymaps/eng.kmap (limited to 'lib/python/Components') diff --git a/configure.ac b/configure.ac index 1f83b0f7..5b3082ec 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,7 @@ data/defaults/Dream/Makefile data/defaults/Dream/hdbouquets/Makefile data/defaults/Dream/sdbouquets/Makefile data/extensions/Makefile +data/keymaps/Makefile data/skin_default/Makefile data/skin_default/menu/Makefile data/skin_default/icons/Makefile diff --git a/data/Makefile.am b/data/Makefile.am index 1ed9444b..0eaa082d 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = countries fonts defaults extensions skin_default +SUBDIRS = countries fonts defaults extensions keymaps skin_default dist_pkgdata_DATA = \ defaultsatlists.xml \ diff --git a/data/keymaps/Makefile.am b/data/keymaps/Makefile.am new file mode 100644 index 00000000..8499d992 --- /dev/null +++ b/data/keymaps/Makefile.am @@ -0,0 +1,6 @@ +keymapsdir = $(datadir)/keymaps +keymaps_DATA = \ + dream-de.info \ + dream-de.kmap \ + eng.info \ + eng.kmap diff --git a/data/keymaps/dream-de.info b/data/keymaps/dream-de.info new file mode 100644 index 00000000..d7f5b074 --- /dev/null +++ b/data/keymaps/dream-de.info @@ -0,0 +1,2 @@ +kmap=dream-de.kmap +name=Dreambox Keyboard Deutsch diff --git a/data/keymaps/dream-de.kmap b/data/keymaps/dream-de.kmap new file mode 100644 index 00000000..693317a7 Binary files /dev/null and b/data/keymaps/dream-de.kmap differ diff --git a/data/keymaps/eng.info b/data/keymaps/eng.info new file mode 100644 index 00000000..d73372c6 --- /dev/null +++ b/data/keymaps/eng.info @@ -0,0 +1,2 @@ +kmap=eng.kmap +name=Keyboard English diff --git a/data/keymaps/eng.kmap b/data/keymaps/eng.kmap new file mode 100644 index 00000000..15a722f1 Binary files /dev/null and b/data/keymaps/eng.kmap differ diff --git a/lib/python/Components/Keyboard.py b/lib/python/Components/Keyboard.py index 820d1036..b026cd56 100755 --- a/lib/python/Components/Keyboard.py +++ b/lib/python/Components/Keyboard.py @@ -1,6 +1,7 @@ from Components.Console import Console from os import listdir as os_listdir, path as os_path from re import compile as re_compile +from enigma import eEnv class Keyboard: def __init__(self): @@ -8,9 +9,9 @@ class Keyboard: self.readKeyboardMapFiles() def readKeyboardMapFiles(self): - for keymapfile in os_listdir('/usr/share/keymaps/'): + for keymapfile in os_listdir(eEnv.resolve('${datadir}/keymaps/')): if (keymapfile.endswith(".info")): - f = open('/usr/share/keymaps/' + keymapfile) + f = open(eEnv.resolve('${datadir}/keymaps/') + keymapfile) mapfile = None mapname = None for line in f: @@ -32,7 +33,7 @@ class Keyboard: try: keymap = self.keyboardmaps[index] print "Activating keymap:",keymap[1] - keymappath = '/usr/share/keymaps/' + keymap[0] + keymappath = eEnv.resolve('${datadir}/keymaps/') + keymap[0] if os_path.exists(keymappath): Console().ePopen(("loadkmap < " + str(keymappath))) except: -- cgit v1.2.3