Skip to content

Commit

Permalink
Use eEnv.resolve() in some places to avoid hardcoded paths.
Browse files Browse the repository at this point in the history
This is just an example, covering only few plug-ins. There are
many more hardcoded paths throughout the tree which should get
replaced, too.
  • Loading branch information
mtdcr committed Jul 29, 2011
1 parent 30b86f6 commit 57b6435
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 33 deletions.
27 changes: 15 additions & 12 deletions aihdcontroler/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from Tools.Directories import fileExists
from skin import parseColor
from os import system
from enigma import eEnv



Expand Down Expand Up @@ -85,9 +86,11 @@ def __init__(self, session):
self.release = ".release20110505"
Screen.__init__(self, session)
self.session = session
self.datei = "/usr/share/enigma2/Ai.HD/skin.xml"
self.daten = "/usr/lib/enigma2/python/Plugins/Extensions/AiHDcontroler/data/"
self.komponente = "/usr/lib/enigma2/python/Plugins/Extensions/AiHDcontroler/comp/"
self.datadir = eEnv.resolve("${datadir}")
self.libdir = eEnv.resolve("${libdir}")
self.datei = self.datadir + "/enigma2/Ai.HD/skin.xml"
self.daten = self.libdir + "/enigma2/python/Plugins/Extensions/AiHDcontroler/data/"
self.komponente = self.libdir + "/enigma2/python/Plugins/Extensions/AiHDcontroler/comp/"
list = []
list.append(getConfigListEntry(_("Infobar and window style:"), config.plugins.vhd.Style))
list.append(getConfigListEntry(_("Channel and EPG selectors style:"), config.plugins.vhd.ChannSelector))
Expand All @@ -104,15 +107,15 @@ def __init__(self, session):
def UpdateComponents(self):
if not fileExists(self.datei + self.release):
system("tar -xzvf " + self.komponente + "AiHD.tar.gz" + " -C /")
system('cp ' + self.komponente + 'vhdRendVolumeText.py /usr/lib/enigma2/python/Components/Renderer/vhdRendVolumeText.py')
system('cp ' + self.komponente + 'vhdRendChNumber.py /usr/lib/enigma2/python/Components/Renderer/vhdRendChNumber.py')
system('cp ' + self.komponente + 'vhdRendVideoSize.py /usr/lib/enigma2/python/Components/Renderer/vhdRendVideoSize.py')
system('cp ' + self.komponente + 'vhdRendMovieDirSize.py /usr/lib/enigma2/python/Components/Renderer/vhdRendMovieDirSize.py')
system('cp ' + self.komponente + 'vhdRendMaxTemp.py /usr/lib/enigma2/python/Components/Renderer/vhdRendMaxTemp.py')
system('cp ' + self.komponente + 'vhdRendNextEvent.py /usr/lib/enigma2/python/Components/Renderer/vhdRendNextEvent.py')
system('cp ' + self.komponente + 'vhdConvSmartInfo.py /usr/lib/enigma2/python/Components/Converter/vhdConvSmartInfo.py')
system('cp ' + self.komponente + 'vhdConvClockToText.py /usr/lib/enigma2/python/Components/Converter/vhdConvClockToText.py')
system('cp ' + self.komponente + 'valiRefString.py /usr/lib/enigma2/python/Components/Converter/valiRefString.py')
system('cp ' + self.komponente + 'vhdRendVolumeText.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendVolumeText.py')
system('cp ' + self.komponente + 'vhdRendChNumber.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendChNumber.py')
system('cp ' + self.komponente + 'vhdRendVideoSize.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendVideoSize.py')
system('cp ' + self.komponente + 'vhdRendMovieDirSize.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendMovieDirSize.py')
system('cp ' + self.komponente + 'vhdRendMaxTemp.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendMaxTemp.py')
system('cp ' + self.komponente + 'vhdRendNextEvent.py ' + self.libdir + '/enigma2/python/Components/Renderer/vhdRendNextEvent.py')
system('cp ' + self.komponente + 'vhdConvSmartInfo.py ' + self.libdir + '/enigma2/python/Components/Converter/vhdConvSmartInfo.py')
system('cp ' + self.komponente + 'vhdConvClockToText.py ' + self.libdir + '/enigma2/python/Components/Converter/vhdConvClockToText.py')
system('cp ' + self.komponente + 'valiRefString.py ' + self.libdir + '/enigma2/python/Components/Converter/valiRefString.py')
system("touch " + self.datei + self.release)

def save(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
config, ConfigInteger, Config, ConfigSubList, ConfigDirectory, NoSave, ConfigYesNo, ConfigSelectionNumber, ConfigSelection
from os import path as os_path, open as os_open, close as os_close, O_RDWR as os_O_RDWR, O_CREAT as os_O_CREAT
from pickle import load as pickle_load, dump as pickle_dump
from enigma import eEnv

CONFIG_FILE_VOLUME = '/usr/lib/enigma2/python/Plugins/SystemPlugins/AutomaticVolumeAdjustment/config_volume'
CONFIG_FILE_VOLUME = eEnv.resolve('${libdir}/enigma2/python/Plugins/SystemPlugins/AutomaticVolumeAdjustment/config_volume')

def getVolumeDict():
if os_path.exists(CONFIG_FILE_VOLUME):
Expand All @@ -44,7 +45,7 @@ def saveVolumeDict(dict):

class AutomaticVolumeAdjustmentConfig():
def __init__(self):
self.CONFIG_FILE = '/usr/lib/enigma2/python/Plugins/SystemPlugins/AutomaticVolumeAdjustment/config'
self.CONFIG_FILE = eEnv.resolve('${libdir}/enigma2/python/Plugins/SystemPlugins/AutomaticVolumeAdjustment/config')
# load config file
self.loadConfigFile()

Expand Down
4 changes: 2 additions & 2 deletions moviecut/src_py/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from Components.ActionMap import ActionMap
from Components.ConfigList import ConfigList, ConfigListScreen
from Components.Sources.StaticText import StaticText
from enigma import eTimer, eServiceCenter, iServiceInformation, eConsoleAppContainer
from enigma import eTimer, eServiceCenter, iServiceInformation, eConsoleAppContainer, eEnv
from os import access, chmod, X_OK

mcut_path = "/usr/lib/enigma2/python/Plugins/Extensions/MovieCut/bin/mcut"
mcut_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/MovieCut/bin/mcut")

def main(session, service, **kwargs):
# Hack to make sure it is executable
Expand Down
6 changes: 3 additions & 3 deletions orfteletext/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from Components.MenuList import MenuList
from Components.Label import Label
from Tools.Directories import fileExists
from enigma import ePicLoad, getDesktop
from enigma import ePicLoad, getDesktop, eEnv
from os import system as os_system
from Components.config import config, ConfigSubsection, ConfigText, ConfigInteger

Expand Down Expand Up @@ -125,7 +125,7 @@ def __init__(self, session):
if fileExists("/tmp/bild"):
self.whatPic = "/tmp/bild"
else:
self.whatPic = "/usr/lib/enigma2/python/Plugins/Extensions/ORFteletext/nodata.png"
self.whatPic = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/ORFteletext/nodata.png")
self.EXpicload.PictureData.get().append(self.DecodeAction)
self.onLayoutFinish.append(self.firstStart)

Expand Down Expand Up @@ -166,7 +166,7 @@ def lade2(self, hs, ns):
if fileExists("/tmp/bild"):
self.whatPic = "/tmp/bild"
else:
self.whatPic = "/usr/lib/enigma2/python/Plugins/Extensions/ORFteletext/nodata.png"
self.whatPic = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/ORFteletext/nodata.png")
self.Show_Picture()

def showMe(self):
Expand Down
4 changes: 2 additions & 2 deletions reconstructapsc/src_py/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from Screens.ChoiceBox import ChoiceBox
import Screens.Standby
from Components.ActionMap import ActionMap
from enigma import eTimer, eServiceCenter, iServiceInformation, eConsoleAppContainer
from enigma import eTimer, eServiceCenter, iServiceInformation, eConsoleAppContainer, eEnv
from os import access, chmod, X_OK

recons_path = "/usr/lib/enigma2/python/Plugins/Extensions/ReconstructApSc/bin/reconstruct_apsc"
recons_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/ReconstructApSc/bin/reconstruct_apsc")

def main(session, service, **kwargs):
# Hack to make sure it is executable
Expand Down
7 changes: 4 additions & 3 deletions serienfilm/src/MovieList.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from Components.config import config
from Tools.LoadPixmap import LoadPixmap
from Components.UsageConfig import preferredPath, defaultMoviePath
from enigma import eEnv
import copy
import os.path

Expand Down Expand Up @@ -65,9 +66,9 @@ def __init__(self, root, list_type=None, sort_type=None, show_times=None, sftitl
if root is not None:
self.reload(root)

self.pdirIcon = LoadPixmap(cached=True, path='/usr/lib/enigma2/python/Plugins/Extensions/SerienFilm/icons/folder_20.png')
self.rdirIcon = LoadPixmap(cached=True, path='/usr/lib/enigma2/python/Plugins/Extensions/SerienFilm/icons/folder_red.png')
self.fupIcon = LoadPixmap(cached=True, path='/usr/lib/enigma2/python/Plugins/Extensions/SerienFilm/icons/folderup_20.png')
self.pdirIcon = LoadPixmap(cached=True, path=eEnv.resolve('${libdir}/enigma2/python/Plugins/Extensions/SerienFilm/icons/folder_20.png'))
self.rdirIcon = LoadPixmap(cached=True, path=eEnv.resolve('${libdir}/enigma2/python/Plugins/Extensions/SerienFilm/icons/folder_red.png'))
self.fupIcon = LoadPixmap(cached=True, path=eEnv.resolve('${libdir}/enigma2/python/Plugins/Extensions/SerienFilm/icons/folderup_20.png'))
self.pdirMap = MultiContentEntryPixmapAlphaTest(pos=(0,0), size=(20,20), png=self.pdirIcon)
self.rdirMap = MultiContentEntryPixmapAlphaTest(pos=(0,0), size=(20,20), png=self.rdirIcon)
self.fupMap = MultiContentEntryPixmapAlphaTest(pos=(0,0), size=(20,20), png=self.fupIcon)
Expand Down
6 changes: 3 additions & 3 deletions vps/src_py/Vps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from enigma import eTimer, eConsoleAppContainer, getBestPlayableServiceReference, eServiceReference, eEPGCache
from enigma import eTimer, eConsoleAppContainer, getBestPlayableServiceReference, eServiceReference, eEPGCache, eEnv
from time import time, strftime, localtime
from Components.config import config
from timer import TimerEntry
Expand All @@ -12,7 +12,7 @@
from Components.TimerSanityCheck import TimerSanityCheck
import NavigationInstance

vps_exe = "/usr/lib/enigma2/python/Plugins/SystemPlugins/vps/vps"
vps_exe = eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/vps/vps")
if not access(vps_exe, X_OK):
chmod(vps_exe, 493)

Expand Down Expand Up @@ -630,4 +630,4 @@ def NextWakeup(self):

return -1

vps_timers = vps()
vps_timers = vps()
4 changes: 2 additions & 2 deletions weatherplugin/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from twisted.web.client import getPage, downloadPage
from urllib import quote
from Components.Pixmap import Pixmap
from enigma import ePicLoad
from enigma import ePicLoad, eEnv
from os import path as os_path, mkdir as os_mkdir
from Components.AVSwitch import AVSwitch
from Components.config import ConfigSubsection, ConfigSubList, ConfigInteger, config
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, session):
i += 1
del i

self.appdir = "/usr/lib/enigma2/python/Plugins/Extensions/WeatherPlugin/icons/"
self.appdir = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/WeatherPlugin/icons/")
if not os_path.exists(self.appdir):
os_mkdir(self.appdir)

Expand Down
3 changes: 2 additions & 1 deletion webbouqueteditor/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
from twisted.python import util
#
from WebChilds.WebUploadResource import WebUploadResource
from enigma import eEnv

def autostart(reason, **kwargs):
if "session" in kwargs:
session = kwargs["session"]
root = static.File("/usr/lib/enigma2/python/Plugins/Extensions/WebBouquetEditor/web-data")
root = static.File(eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/WebBouquetEditor/web-data"))
root.putChild("web", ScreenPage(session, util.sibpath(__file__, "web"), True) )
root.putChild('tmp', static.File('/tmp'))
root.putChild("uploadfile",WebUploadResource(session))
Expand Down
3 changes: 2 additions & 1 deletion webcamviewer/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enigma import ePicLoad
from enigma import loadPNG
from enigma import gFont
from enigma import eEnv
### Picturelist
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
Expand Down Expand Up @@ -64,7 +65,7 @@ def startWebcamviewer(session, **kwargs):
originalservice = session.nav.getCurrentlyPlayingServiceReference()
if config.plugins.pictureviewer.stopserviceonstart.value:
session.nav.stopService()
xmlfile = "/usr/lib/enigma2/python/Plugins/Extensions/WebcamViewer/webcam.xml"
xmlfile = eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/WebcamViewer/webcam.xml")
if os.path.isfile(xmlfile):
try:
xmlnode = xml.dom.minidom.parse(open(xmlfile))
Expand Down
4 changes: 2 additions & 2 deletions widgets/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from enigma import eTimer
from Components.Label import Label
from Components.MenuList import MenuList
from enigma import getDesktop, eSize,ePoint
from enigma import getDesktop, eSize, ePoint, eEnv
from skin import applyAllAttributes, dom_skins


Expand Down Expand Up @@ -137,7 +137,7 @@ def __init__(self, session):
self.session = session
Screen.__init__(self, session)

loadSkinReal("/usr/lib/enigma2/python/Plugins/Extensions/Widgets/skin.xml")
loadSkinReal(eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/Widgets/skin.xml"))


cfg = lookupWidgetConfig()
Expand Down

0 comments on commit 57b6435

Please sign in to comment.