eServiceReference, iRecordableService, quitMainloop
from Components.config import config
+from Components.UsageConfig import defaultMoviePath
from Components.TimerSanityCheck import TimerSanityCheck
from Screens.MessageBox import MessageBox
if config.recording.ascii_filenames.value:
filename = ASCIItranslit.legacyEncode(filename)
- if self.dirname and not Directories.fileExists(self.dirname, 'w'):
- self.dirnameHadToFallback = True
- self.Filename = Directories.getRecordingFilename(filename, None)
+ if not self.dirname or not Directories.fileExists(self.dirname, 'w'):
+ if self.dirname:
+ self.dirnameHadToFallback = True
+ dirname = defaultMoviePath()
else:
- self.Filename = Directories.getRecordingFilename(filename, self.dirname)
+ dirname = self.dirname
+ self.Filename = Directories.getRecordingFilename(filename, dirname)
self.log(0, "Filename calculated as: '%s'" % self.Filename)
#begin_date + " - " + service_name + description)
<item level="1" text="Device Setup..." entryID="device_setup"><screen module="NetworkSetup" screen="NetworkAdapterSelection"/></item>
<item level="1" text="Nameserver Setup..." entryID="dns_setup"><screen module="NetworkSetup" screen="NameserverSetup"/></item>
</menu>-->
- <item level="2" text="Timeshift path..." entryId="timeshift_path"><screen module="LocationBox" screen="TimeshiftLocationBox" /></item>
+ <item level="2" text="Recording paths..." entryId="RecordPaths"><screen module="RecordPaths" screen="RecordPathsSettings" /></item>
</menu>
<item weight="10" level="1" text="Common Interface" entryID="ci_setup" requires="CommonInterface"><screen module="Ci" screen="CiSelection" /></item>
<item weight="15" level="0" text="Parental control" entryID="parental_setup"><screen module="ParentalControlSetup" screen="ParentalControlSetup" /></item>
from MenuList import MenuList
from Components.Harddisk import harddiskmanager
-from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
+from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename, fileExists
from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, \
eServiceReference, eServiceCenter, gFont
directories.sort()
files.sort()
else:
- if os_path.exists(directory):
- files = listdir(directory)
+ if fileExists(directory):
+ try:
+ files = listdir(directory)
+ except:
+ files = []
files.sort()
tmpfiles = files[:]
for x in tmpfiles:
directories.sort()
files.sort()
else:
- if os_path.exists(directory):
- files = listdir(directory)
+ if fileExists(directory):
+ try:
+ files = listdir(directory)
+ except:
+ files = []
files.sort()
tmpfiles = files[:]
for x in tmpfiles:
# any access has been made to the disc. If there has been no access over a specifed time,
# we set the hdd into standby.
def readStats(self):
- l = readFile("/sys/block/%s/stat" % self.device)
+ try:
+ l = open("/sys/block/%s/stat" % self.device).read()
+ except IOError:
+ return -1,-1
(nr_read, _, _, _, nr_write) = l.split()[:5]
return int(nr_read), int(nr_write)
l = sum(stats)
print "sum", l, "prev_sum", self.last_stat
- if l != self.last_stat: # access
+ if l != self.last_stat and l >= 0: # access
print "hdd was accessed since previous check!"
self.last_stat = l
self.last_access = t
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 SystemInfo import SystemInfo
import os
("standard", _("standard")), ("swap", _("swap PiP and main picture")),
("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
+ config.usage.default_path = ConfigText(default = resolveFilename(SCOPE_HDD))
+ config.usage.timer_path = ConfigText(default = "<default>")
+ config.usage.instantrec_path = ConfigText(default = "<default>")
+ config.usage.timeshift_path = ConfigText(default = "/media/hdd/")
config.usage.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
- config.usage.timeshift_path = ConfigText(default = "/media/hdd")
config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
def TunerTypePriorityOrderChanged(configElement):
setTunerTypePriorityOrder(int(configElement.value))
- config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged)
+ config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged, immediate_feedback=False)
def setHDDStandby(configElement):
for hdd in harddiskmanager.HDDList():
hdd[1].setIdleTime(int(configElement.value))
- config.usage.hdd_standby.addNotifier(setHDDStandby)
+ config.usage.hdd_standby.addNotifier(setHDDStandby, immediate_feedback=False)
def set12VOutput(configElement):
if configElement.value == "on":
Misc_Options.getInstance().set_12V_output(1)
elif configElement.value == "off":
Misc_Options.getInstance().set_12V_output(0)
- config.usage.output_12V.addNotifier(set12VOutput)
+ config.usage.output_12V.addNotifier(set12VOutput, immediate_feedback=False)
SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
defval = str(x)
break
sel.setChoices(map(str, choices), defval)
+
+def preferredPath(path):
+ if config.usage.setup_level.index < 2 or path == "<default>":
+ return None # config.usage.default_path.value, but delay lookup until usage
+ elif path == "<current>":
+ return config.movielist.last_videodir.value
+ elif path == "<timer>":
+ return config.movielist.last_timer_videodir.value
+ else:
+ return path
+
+def preferredTimerPath():
+ return preferredPath(config.usage.timer_path.value)
+
+def preferredInstantRecordPath():
+ return preferredPath(config.usage.instantrec_path.value)
+
+def defaultMoviePath():
+ return config.usage.default_path.value
+
from enigma import getPrevAsciiCode
from Tools.NumericalTextInput import NumericalTextInput
-from Tools.Directories import resolveFilename, SCOPE_CONFIG
+from Tools.Directories import resolveFilename, SCOPE_CONFIG, fileExists
from Components.Harddisk import harddiskmanager
from copy import copy as copy_copy
from os import path as os_path
self.default = default
self.locations = []
self.mountpoints = []
- harddiskmanager.on_partition_list_change.append(self.mountpointsChanged)
self.value = default[:]
def setValue(self, value):
locations = [[x, None, False, False] for x in tmp]
self.refreshMountpoints()
for x in locations:
- if os_path.exists(x[0]):
+ if fileExists(x[0]):
x[1] = self.getMountpoint(x[0])
x[2] = True
self.locations = locations
return False
return self.tostring([x[0] for x in locations]) != sv
- def mountpointsChanged(self, action, dev):
- print "Mounts changed: ", action, dev
- mp = dev.mountpoint+"/"
- if action == "add":
- self.addedMount(mp)
- elif action == "remove":
- self.removedMount(mp)
- self.refreshMountpoints()
-
def addedMount(self, mp):
for x in self.locations:
if x[1] == mp:
x[2] = True
- elif x[1] == None and os_path.exists(x[0]):
+ elif x[1] == None and fileExists(x[0]):
x[1] = self.getMountpoint(x[0])
x[2] = True
x[2] = False
def refreshMountpoints(self):
- self.mountpoints = [p.mountpoint + "/" for p in harddiskmanager.getMountedPartitions() if p.mountpoint != "/"]
+ self.mountpoints = [p.mountpoint for p in harddiskmanager.getMountedPartitions() if p.mountpoint != "/"]
self.mountpoints.sort(key = lambda x: -len(x))
def checkChangedMountpoints(self):
from Components.EpgList import EPGList, EPG_TYPE_SINGLE, EPG_TYPE_SIMILAR, EPG_TYPE_MULTI
from Components.ActionMap import ActionMap
from Components.TimerSanityCheck import TimerSanityCheck
+from Components.UsageConfig import preferredTimerPath
from Components.Sources.ServiceEvent import ServiceEvent
from Components.Sources.Event import Event
from Screens.TimerEdit import TimerSanityConflict
self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
break
else:
- newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
+ newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(event))
self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
def finishedAdd(self, answer):
from Components.Label import Label
from Components.ScrollLabel import ScrollLabel
from Components.TimerList import TimerList
+from Components.UsageConfig import preferredTimerPath
from enigma import eEPGCache, eTimer, eServiceReference
from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT
from TimerEntry import TimerEntry
self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
break
else:
- newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, *parseEvent(self.event))
+ newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event))
self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
def finishedAdd(self, answer):
return
if answer in ("quit", "quitanddeleteconfirmed"):
- config.movielist.last_videodir.cancel()
self.close()
elif answer == "movielist":
ref = self.session.nav.getCurrentlyPlayingServiceReference()
from Components.Sources.Boolean import Boolean
from Components.config import config, ConfigBoolean, ConfigClock
from Components.SystemInfo import SystemInfo
+from Components.UsageConfig import preferredInstantRecordPath, defaultMoviePath
from EpgSelection import EPGSelection
from Plugins.Plugin import PluginDescriptor
from ServiceReference import ServiceReference
from Tools import Notifications
-from Tools.Directories import SCOPE_HDD, resolveFilename, fileExists
+from Tools.Directories import fileExists
from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
iPlayableService, eServiceReference, eEPGCache
if isinstance(serviceref, eServiceReference):
serviceref = ServiceReference(serviceref)
- recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = config.movielist.last_videodir.value)
+ recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = preferredInstantRecordPath())
recording.dontSave = True
if event is None or limitEvent == False:
self.session.nav.RecordTimer.timeChanged(entry)
def instantRecord(self):
- dir = config.movielist.last_videodir.value
- if not fileExists(dir, 'w'):
- dir = resolveFilename(SCOPE_HDD)
+ dir = preferredInstantRecordPath()
+ if not dir or not fileExists(dir, 'w'):
+ dir = defaultMoviePath()
try:
stat = os_stat(dir)
except:
else:
self["filelist"].refresh()
self.removeBookmark(name, True)
+ val = self.realBookmarks and self.realBookmarks.value
+ if val and name in val:
+ val.remove(name)
+ self.realBookmarks.value = val
+ self.realBookmarks.save()
def up(self):
self[self.currList].up()
from Components.Pixmap import Pixmap
from Components.Label import Label
from Components.PluginComponent import plugins
-from Components.config import config, ConfigSubsection, ConfigText, ConfigInteger, ConfigLocations
+from Components.config import config, ConfigSubsection, ConfigText, ConfigInteger, ConfigLocations, ConfigSet
from Components.Sources.ServiceEvent import ServiceEvent
+from Components.UsageConfig import defaultMoviePath
from Plugins.Plugin import PluginDescriptor
config.movielist.videodirs = ConfigLocations(default=[resolveFilename(SCOPE_HDD)])
config.movielist.first_tags = ConfigText(default="")
config.movielist.second_tags = ConfigText(default="")
+config.movielist.last_selected_tags = ConfigSet([], default=[])
def setPreferredTagEditor(te):
HelpableScreen.__init__(self)
self.tags = [ ]
- self.selected_tags = None
+ if selectedmovie:
+ self.selected_tags = config.movielist.last_selected_tags.value
+ else:
+ self.selected_tags = None
self.selected_tags_ele = None
self.movemode = False
self["DescriptionBorder"] = Pixmap()
self["DescriptionBorder"].hide()
- if not pathExists(config.movielist.last_videodir.value):
- config.movielist.last_videodir.value = resolveFilename(SCOPE_HDD)
+ if not fileExists(config.movielist.last_videodir.value):
+ config.movielist.last_videodir.value = defaultMoviePath()
config.movielist.last_videodir.save()
self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + config.movielist.last_videodir.value)
self.close(None)
def saveconfig(self):
+ config.movielist.last_selected_tags.value = self.selected_tags
config.movielist.moviesort.save()
config.movielist.listtype.save()
config.movielist.description.save()
self["list"].setSortType(type)
def reloadList(self, sel = None, home = False):
- if not pathExists(config.movielist.last_videodir.value):
- path = resolveFilename(SCOPE_HDD)
+ if not fileExists(config.movielist.last_videodir.value):
+ path = defaultMoviePath()
config.movielist.last_videodir.value = path
config.movielist.last_videodir.save()
self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + path)
def gotFilename(self, res):
if res is not None and res is not config.movielist.last_videodir.value:
- if pathExists(res):
+ if fileExists(res):
config.movielist.last_videodir.value = res
config.movielist.last_videodir.save()
self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + res)
def showTagsN(self, tagele):
if not self.tags:
self.showTagWarning()
- elif not tagele or self.selected_tags_ele == tagele or not tagele.value in self.tags:
+ elif not tagele or tagele.value in self.selected_tags or not tagele.value in self.tags:
self.showTagsMenu(tagele)
else:
self.selected_tags_ele = tagele
from Components.MenuList import MenuList
from Components.TimerList import TimerList
from Components.TimerSanityCheck import TimerSanityCheck
+from Components.UsageConfig import preferredTimerPath
from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT
from Screen import Screen
from Screens.ChoiceBox import ChoiceBox
else:
data = parseEvent(event, description = False)
- self.addTimer(RecordTimerEntry(serviceref, checkOldTimers = True, dirname = config.movielist.last_timer_videodir.value, *data))
+ self.addTimer(RecordTimerEntry(serviceref, checkOldTimers = True, dirname = preferredTimerPath(), *data))
def addTimer(self, timer):
self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
from Components.Button import Button
from Components.Label import Label
from Components.Pixmap import Pixmap
+from Components.UsageConfig import defaultMoviePath
from Screens.MovieSelection import getPreferredTagEditor
from Screens.LocationBox import MovieLocationBox
from Screens.ChoiceBox import ChoiceBox
from RecordTimer import AFTEREVENT
-from Tools.Directories import resolveFilename, SCOPE_HDD
from enigma import eEPGCache
from time import localtime, mktime, time, strftime
from datetime import datetime
self.timerentry_starttime = ConfigClock(default = self.timer.begin)
self.timerentry_endtime = ConfigClock(default = self.timer.end)
- default = self.timer.dirname or resolveFilename(SCOPE_HDD)
+ default = self.timer.dirname or defaultMoviePath()
tmp = config.movielist.videodirs.value
if default not in tmp:
tmp.append(default)
self.timer.service_ref = self.timerentry_service_ref
self.timer.tags = self.timerentry_tags
- self.timer.dirname = self.timerentry_dirname.value
- config.movielist.last_timer_videodir.value = self.timer.dirname
- config.movielist.last_timer_videodir.save()
+ if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath():
+ self.timer.dirname = self.timerentry_dirname.value
+ config.movielist.last_timer_videodir.value = self.timer.dirname
+ config.movielist.last_timer_videodir.save()
if self.timerentry_type.value == "once":
self.timer.begin, self.timer.end = self.getBeginEnd()