Author: duncan
Date: Fri Mar 21 12:58:43 2008
New Revision: 10557
Log:
Merged changes from rel-1
Modified:
branches/rel-1-7/freevo/src/evdev.py
branches/rel-1-7/freevo/src/menu.py
branches/rel-1-7/freevo/src/plugins/alsamixer2.py
branches/rel-1-7/freevo/src/plugins/audioscrobbler.py
branches/rel-1-7/freevo/src/plugins/autoshutdown.py
branches/rel-1-7/freevo/src/plugins/cd_burn.py
branches/rel-1-7/freevo/src/plugins/ossmixer.py
branches/rel-1-7/freevo/src/plugins/remind.py
branches/rel-1-7/freevo/src/plugins/shutdown.py
branches/rel-1-7/freevo/src/rc.py
Modified: branches/rel-1-7/freevo/src/evdev.py
==============================================================================
--- branches/rel-1-7/freevo/src/evdev.py (original)
+++ branches/rel-1-7/freevo/src/evdev.py Fri Mar 21 12:58:43 2008
@@ -34,6 +34,8 @@
from fcntl import ioctl
import struct
+import config
+
_types = {}
_events = {}
@@ -72,10 +74,13 @@
def _IO(type,nr):
return _IOC(_IOC_NONE,(type),(nr),0)
+
def _IOR(type,nr,size):
return _IOC(_IOC_READ,(type),(nr),(size))
+
def _IOW(type,nr,size):
return _IOC(_IOC_WRITE,(type),(nr),(size))
+
def _IOWR(type,nr,size):
return _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(size))
@@ -83,18 +88,25 @@
EVIOCGVERSION = _IOR('E', 0x01, 4) # get driver version
EVIOCGID = _IOR('E', 0x02, 8) # get device ID
-def EVIOCGNAME(len): return _IOR('E', 0x06, len) # get device name
-def EVIOCGPHYS(len): return _IOR('E', 0x07, len) # get physical location
-def EVIOCGUNIQ(len): return _IOR('E', 0x08, len) # get unique identifier
-
-def EVIOCGBIT(ev,len):return _IOR('E', 0x20 + ev, len) # get event bits
-def EVIOCGABS(abs): return _IOR('E', 0x40 + abs, 20) # get abs value/limits
-def EVIOCSABS(abs): return _IOW('E', 0xc0 + abs, 20) # set abs value/limits
+def EVIOCGNAME(len):
+ return _IOR('E', 0x06, len) # get device name
+def EVIOCGPHYS(len):
+ return _IOR('E', 0x07, len) # get physical location
+def EVIOCGUNIQ(len):
+ return _IOR('E', 0x08, len) # get unique identifier
+
+def EVIOCGBIT(ev,len):
+ return _IOR('E', 0x20 + ev, len) # get event bits
+def EVIOCGABS(abs):
+ return _IOR('E', 0x40 + abs, 20) # get abs value/limits
+def EVIOCSABS(abs):
+ return _IOW('E', 0xc0 + abs, 20) # set abs value/limits
class evdev:
def __init__(self, dev, blocking = False):
- '''
- '''
+ """
+ """
+ _debug_('evdev.__init__(dev, blocking = False)', 2)
self._fd = None
if blocking:
self._fd = os.open(dev, os.O_RDONLY)
@@ -103,86 +115,92 @@
self.get_events()
def __del__(self):
- '''
- '''
+ """
+ """
+ _debug_('__del__()', 2)
self.close()
def close(self):
- '''
- '''
+ """
+ """
+ _debug_('close()', 2)
if self._fd is not None:
os.close(self._fd)
self._fd = None
def print_info(self):
- '''
- '''
- print "Input driver version %d.%d.%d" % self.get_version()
+ """
+ """
+ _debug_('print_info()', 2)
+ print 'Input driver version %d.%d.%d' % self.get_version()
devid = self.get_id()
- print "Device ID: bus %s vendor 0x%04x product 0x%04x version 0x%04x"
% \
- (devid["bus"], devid["vendor"], devid["product"], devid["version"])
-
+ print 'Device ID: bus %(bus)s vendor 0x%(vendor)04x product
0x%(product)04x version 0x%(version)04x' % devid
print 'Device name: "' + self.get_name() + '"'
print 'Device location: "' + self.get_location() + '"'
def print_events(self):
- '''
- '''
- print "Supported events:"
+ """
+ """
+ _debug_('print_events()', 2)
+ print 'Supported events:'
keys = self._events.keys()
keys.sort()
for key in keys:
- print " Event type %s (%d):" % (_types[key], key)
+ print ' Event type %s (%d):' % (_types[key], key)
self._events[key].sort()
for event in self._events[key]:
try:
- print " Event %s (%d)" % (_events[key][event],
event)
+ print ' Event %s (%d)' % (_events[key][event],
event)
except KeyError:
- print " Event ??? (%d)" % event
+ print ' Event ??? (%d)' % event
def get_version(self):
- '''
- '''
- buf = ioctl(self._fd, EVIOCGVERSION, " ")
- l, = struct.unpack("I", buf)
+ """
+ """
+ _debug_('get_version()', 2)
+ buf = ioctl(self._fd, EVIOCGVERSION, ' ')
+ l, = struct.unpack('I', buf)
return (l >> 16, (l >> 8) & 0xff, l & 0xff)
def get_id(self):
- '''
- '''
- buf = ioctl(self._fd, EVIOCGID, " " * 8)
- bus, vendor, product, version = struct.unpack("HHHH", buf)
- return { "bus":_buses[bus], "vendor":vendor,
- "product":product, "version":version }
+ """
+ """
+ _debug_('get_id()', 2)
+ buf = ioctl(self._fd, EVIOCGID, ' ' * 8)
+ bus, vendor, product, version = struct.unpack('HHHH', buf)
+ return { 'bus':_buses[bus], 'vendor':vendor, 'product':product,
'version':version }
def get_name(self):
- '''
- '''
- buf = ioctl(self._fd, EVIOCGNAME(1024), " " * 1024)
- null = buf.find("\0")
+ """
+ """
+ _debug_('get_name()', 2)
+ buf = ioctl(self._fd, EVIOCGNAME(1024), ' ' * 1024)
+ null = buf.find('\0')
return buf[:null]
def get_location(self):
- '''
- '''
- buf = ioctl(self._fd, EVIOCGPHYS(1024), " " * 1024)
- null = buf.find("\0")
+ """
+ """
+ _debug_('get_location()', 2)
+ buf = ioctl(self._fd, EVIOCGPHYS(1024), ' ' * 1024)
+ null = buf.find('\0')
return buf[:null]
def get_events(self):
- '''
- '''
+ """
+ """
+ _debug_('get_events()', 2)
keys = _types.keys()
keys.sort()
# We need one bit per type, rounded up to even 4 bytes
l = ((keys[-1] + 7) / 8 + 3) & ~0x3
- buf = ioctl(self._fd, EVIOCGBIT(0, l), " " * l)
- array = struct.unpack("I" * (l/4), buf)
+ buf = ioctl(self._fd, EVIOCGBIT(0, l), ' ' * l)
+ array = struct.unpack('I' * (l/4), buf)
self._events = {}
@@ -199,11 +217,11 @@
sl = ((subkeys[-1] + 7) / 8 + 3) & ~0x3
try:
- buf = ioctl(self._fd, EVIOCGBIT(i, sl), " " * sl)
+ buf = ioctl(self._fd, EVIOCGBIT(i, sl), ' ' * sl)
except IOError:
# No events for a type results in Errno 22 (EINVAL)
break
- subarray = struct.unpack("I" * (sl/4), buf)
+ subarray = struct.unpack('I' * (sl/4), buf)
for j in xrange(sl * 8):
if not subarray[j / 32] & (1 << j % 32):
@@ -212,8 +230,9 @@
self._events[i].append(j)
def has_event(self, test_event):
- '''
- '''
+ """
+ """
+ _debug_('has_event(test_event)', 2)
for type in self._events.keys():
for event in self._events[type]:
if _events[type][event] == test_event:
@@ -221,28 +240,30 @@
return False
def read(self):
- '''
- '''
+ """
+ """
try:
- buf = os.read(self._fd, struct.calcsize("LLHHi"))
+ buf = os.read(self._fd, struct.calcsize('LLHHi'))
except OSError, (errno, str):
if errno == 11:
return None
raise
- sec, usec, type, code, value = struct.unpack("LLHHi", buf)
+ sec, usec, type, code, value = struct.unpack('LLHHi', buf)
return (float(sec) + float(usec)/1000000.0, _types[type],
_events[type][code], value)
-if __name__ == "__main__":
+if __name__ == '__main__':
def _convert_value(s):
- if s.startswith("0x"):
+ _debug_('_convert_value(s)', 2)
+ if s.startswith('0x'):
return int(s, 16)
return int(s, 10)
def parse_input_h(path):
+ _debug_('parse_input_h(path)', 2)
global _types, _events, _ids, _buses
f = file(path)
@@ -254,40 +275,40 @@
buses = {}
for line in f.readlines():
- m = re.search("#define
(?P<name>EV_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)", line)
+ m = re.search('#define
(?P<name>EV_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)', line)
if m:
- if m.group("name") != "EV_VERSION":
- types[_convert_value(m.group("value"))] = m.group("name")
+ if m.group('name') != 'EV_VERSION':
+ types[_convert_value(m.group('value'))] = m.group('name')
continue
- m = re.search("#define
(?P<name>ID_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)", line)
+ m = re.search('#define
(?P<name>ID_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)', line)
if m:
- ids[_convert_value(m.group("value"))] = m.group("name")
+ ids[_convert_value(m.group('value'))] = m.group('name')
continue
- m = re.search("#define
(?P<name>BUS_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)", line)
+ m = re.search('#define
(?P<name>BUS_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)', line)
if m:
- buses[_convert_value(m.group("value"))] = m.group("name")
+ buses[_convert_value(m.group('value'))] = m.group('name')
continue
- m = re.search("#define
(?P<name>(?P<type>[A-Za-z0-9]+)_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)",
line)
+ m = re.search('#define
(?P<name>(?P<type>[A-Za-z0-9]+)_[A-Za-z0-9_]+)\s+(?P<value>(0x)?[0-9A-Fa-f]+)',
line)
if m:
- t = m.group("type")
+ t = m.group('type')
# The naming is a bit off in input.h
- if t == "BTN":
- t = "KEY"
+ if t == 'BTN':
+ t = 'KEY'
for k in types.keys():
- if types[k] == "EV_" + t:
+ if types[k] == 'EV_' + t:
break
else:
- raise Exception("Invalid type: %s" % m.group("type"))
+ raise Exception('Invalid type: %s' % m.group('type'))
if not events.has_key(k):
events[k] = {}
- events[k][_convert_value(m.group("value"))] = m.group("name")
+ events[k][_convert_value(m.group('value'))] = m.group('name')
_types = types
_events = events
@@ -296,53 +317,54 @@
_buses = buses
def _print_tables():
- print "_types = {"
+ _debug_('_print_tables()', 2)
+ print '_types = {'
keys = _types.keys()
keys.sort()
for key in keys:
- print " %2d:%s," % (key, repr(_types[key]))
+ print ' %2d:%s,' % (key, repr(_types[key]))
- print " }"
+ print ' }'
- print ""
+ print ''
- print "_events = {"
+ print '_events = {'
keys = _events.keys()
keys.sort()
for key in keys:
- print " %2d:{ # %s" % (key, _types[key])
+ print ' %2d:{ # %s' % (key, _types[key])
subkeys = _events[key].keys()
for subkey in subkeys:
- print " %3d:%s," % (subkey, repr(_events[key][subkey]))
+ print ' %3d:%s,' % (subkey, repr(_events[key][subkey]))
- print " },"
+ print ' },'
- print " }"
+ print ' }'
- print ""
+ print ''
- print "_ids = {"
+ print '_ids = {'
keys = _ids.keys()
keys.sort()
for key in keys:
- print " %2d:%s," % (key, repr(_ids[key]))
+ print ' %2d:%s,' % (key, repr(_ids[key]))
- print " }"
+ print ' }'
- print ""
+ print ''
- print "_buses = {"
+ print '_buses = {'
keys = _buses.keys()
keys.sort()
for key in keys:
- print " %2d:%s," % (key, repr(_buses[key]))
+ print ' %2d:%s,' % (key, repr(_buses[key]))
- print " }"
+ print ' }'
# Main starts here
e = evdev(sys.argv[1], True)
Modified: branches/rel-1-7/freevo/src/menu.py
==============================================================================
--- branches/rel-1-7/freevo/src/menu.py (original)
+++ branches/rel-1-7/freevo/src/menu.py Fri Mar 21 12:58:43 2008
@@ -88,7 +88,7 @@
"""
call the default acion
"""
- if self.function:
+ if self.function and callable(self.function):
self.function(arg=self.arg, menuw=menuw)
Modified: branches/rel-1-7/freevo/src/plugins/alsamixer2.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/alsamixer2.py (original)
+++ branches/rel-1-7/freevo/src/plugins/alsamixer2.py Fri Mar 21 12:58:43 2008
@@ -173,6 +173,7 @@
if self.mute_ctrl is None:
self.mute_ctrl = self.main_ctrl
+
def config(self):
"""
Config is called automatically. For default settings run:
@@ -184,6 +185,7 @@
('ALSAMIXER2_CTRLS', [('PCM', 'default', 50, 0, 100)], 'Alsa mixer
control list'),
]
+
def eventhandler(self, event=None, menuw=None, arg=None):
"""
Event handler to handle VOLUME and MUTE events
@@ -207,10 +209,12 @@
return False
+
def getVolume(self):
""" Get the volume level of a control """
return self.main_ctrl.getvolume()[0]
+
def setVolume(self, val=0):
""" Set the volume level of a control (default 0) """
if val < self.main_ctrl_min:
@@ -219,20 +223,29 @@
val = self.main_ctrl_max
self.main_ctrl.setvolume(val)
+
def incVolume(self, step=5):
""" Increase the volume level by the step (default 5) """
self.setVolume(self.getVolume() + step)
return self.getVolume()
+
def decVolume(self, step=5):
""" Decrease the volume level by the step (default 5) """
self.setVolume(self.getVolume() - step)
return self.getVolume()
+
def getMute(self):
""" Get the muting of a control """
return self.mute_ctrl.getmute()[0]
+
def setMute(self, val=0):
""" Set the muting of a control (default 0) """
self.mute_ctrl.setmute(val)
+
+
+ def reset(self):
+ """ Resets the audio to defaults """
+ pass
Modified: branches/rel-1-7/freevo/src/plugins/audioscrobbler.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/audioscrobbler.py (original)
+++ branches/rel-1-7/freevo/src/plugins/audioscrobbler.py Fri Mar 21
12:58:43 2008
@@ -127,7 +127,7 @@
else:
print "AudioScrobbler plugin: Didn't find submit url, retrying"
self.failed_retries += 1
- return # If we didn't get this we ass-ume that their server is
down and try to re-login
+ return # If we didn't get this we assume that their server is down
and try to re-login
self.challenge_reply = md5.md5( md5.md5(self.PASSWORD).hexdigest() +
self.challenge ).hexdigest()
Modified: branches/rel-1-7/freevo/src/plugins/autoshutdown.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/autoshutdown.py (original)
+++ branches/rel-1-7/freevo/src/plugins/autoshutdown.py Fri Mar 21 12:58:43 2008
@@ -45,24 +45,24 @@
import tv.record_client as record_client
-# Exception handling classes
-class ExInternalError : pass
-class ExNoRecordServer(Exception) : pass
+class ExInternalError: pass
+
+class ExNoRecordServer(Exception): pass
class ExRecordServerRemote(Exception): pass
-class ExNoDefaultWakeup(Exception) : pass
+class ExNoDefaultWakeup(Exception): pass
-class ExIndexNotAvailable(Exception) : pass
+class ExIndexNotAvailable(Exception): pass
-class ExNoWakeupNeeded(Exception) : pass
+class ExNoWakeupNeeded(Exception): pass
-class ExNextWakeupSoon(Exception) : pass
+class ExNextWakeupSoon(Exception): pass
-class ExProcessRunning(Exception) : pass
+class ExProcessRunning(Exception): pass
-class ExRecordingInProgress(Exception) : pass
+class ExRecordingInProgress(Exception): pass
class PluginInterface(plugin.MainMenuPlugin):
@@ -80,7 +80,7 @@
| plugin.activate('autoshutdown',level=90)
Configuration:
- | SHUTDOWN_SYS_ENABLE = 1
+ | SYS_SHUTDOWN_ENABLE = 1
| AUTOSHUTDOWN_METHOD = 'acpi|nvram'
| AUTOSHUTDOWN_WAKEUP_CMD = PATH/TO/THE/WAKEUP_SCRIPT
| AUTOSHUTDOWN_DEFAULT_WAKEUP_TIME = "13:00"
@@ -123,7 +123,7 @@
def config(self):
return [
- ('SHUTDOWN_SYS_ENABLE', 1, 'System shutdown enabled'),
+ ('SYS_SHUTDOWN_ENABLE', 1, 'System shutdown enabled'),
('AUTOSHUTDOWN_METHOD', 'acpi', 'acpi or nvram'),
('AUTOSHUTDOWN_WAKEUP_CMD', None, 'path to the wakeup script'),
('AUTOSHUTDOWN_DEFAULT_WAKEUP_TIME', '13:00', 'Daily wake up
time'),
@@ -136,18 +136,14 @@
return [ ShutdownMenuItem(parent) ]
-# ***************************************************************
-# CLASS ShutdownMenuItem
-# ***************************************************************
+
class ShutdownMenuItem(Item):
def __init__(self, parent=None):
_debug_('ShutdownMenuItem.__init__(parent=%r)' % (parent,), 2)
Item.__init__(self, parent, skin_type='shutdown')
self.idletimer = plugin.getbyname('autoshutdowntimer')
- # -----------------------------------------------------------
- # TEXT FORMATTING
- # -----------------------------------------------------------
+
def message_check(self, wakeup=False):
_debug_('message_check(wakeup=%r)' % (wakeup,), 2)
try:
@@ -176,28 +172,22 @@
return msg
- # -----------------------------------------------------------
- # ACTIONS
- # -----------------------------------------------------------
def actions(self):
_debug_('actions()', 2)
- if (self.idletimer.ispaused()):
+ if self.idletimer.ispaused():
itemname = _('Resume automatic shutdown')
else:
itemname = _('Pause automatic shutdown')
items = [
- (self.confirm_shutdown_wakeup, _('Shutdown and wakeup') ),
- (self.confirm_toggle_timer, itemname ),
- (self.confirm_restart_system, _('Restart system') ),
- (self.confirm_shutdown_system, _('Shutdown system') ),
- (self.confirm_shutdown_freevo, _('Shutdown freevo') ),
+ (self.confirm_shutdown_wakeup, _('Shutdown and wakeup')),
+ (self.confirm_toggle_timer, itemname),
+ (self.confirm_restart_system, _('Restart system')),
+ (self.confirm_shutdown_system, _('Shutdown system')),
+ (self.confirm_shutdown_freevo, _('Shutdown freevo')),
]
return items
- # -----------------------------------------------------------
- # CONFIRMATION
- # -----------------------------------------------------------
def confirm_shutdown_wakeup(self, arg=None, menuw=None):
_debug_('confirm_shutdown_wakeup(arg=%r, menuw=%r)' % (arg, menuw), 2)
if config.AUTOSHUTDOWN_CONFIRM:
@@ -259,9 +249,6 @@
self.shutdown_freevo(arg, menuw)
- # -----------------------------------------------------------
- # ACTIONS
- # -----------------------------------------------------------
def shutdown_wakeup(self, arg=None, menuw=None):
_debug_('shutdown_wakeup(arg=%r, menuw=%r)' % (arg, menuw), 2)
shutdown_action(action=Shutdown.SHUTDOWN_WAKEUP)
@@ -302,9 +289,7 @@
shutdown_action(action=Shutdown.SHUTDOWN_FREEVO)
-# ***************************************************************
-# CLASS autoshutdowntimer
-# ***************************************************************
+
class autoshutdowntimer(plugin.DaemonPlugin):
"""
Plugin to shutdown Freevo automatically with a timer
@@ -417,12 +402,10 @@
_debug_("idle for %d seconds, %d minutes remaining" % (tdif,
trem), 2)
-# ***************************************************************
-# CLASS SHUTDOWN
-# ***************************************************************
+
class Shutdown:
- SHUTDOWN_WAKEUP, RESTART_SYSTEM, SHUTDOWN_SYSTEM, SHUTDOWN_FREEVO, IGNORE
= range(5)
+ SHUTDOWN_WAKEUP, RESTART_SYSTEM, SHUTDOWN_SYSTEM, SHUTDOWN_FREEVO, IGNORE
= range(5)
# ***************************************************************
@@ -457,15 +440,13 @@
return True
-# -----------------------------------------------------------
-# get_next_wakeup
-# Calculate the next wakeup time in seconds UTC
-# -----------------------------------------------------------
-# Input: None
-# Result: UTC time of next wakeup
-# Raises: ExNoWakeupNeeded if no wakeup needed
-# -----------------------------------------------------------
def get_next_wakeup():
+ """
+ Calculate the next wakeup time in seconds UTC
+
+ @returns: UTC time of next wakeup
+ @raises ExNoWakeupNeeded: if no wakeup needed
+ """
_debug_('get_next_wakeup()', 2)
scheduled_utc_s = 0
default_utc_s = 0
@@ -510,15 +491,12 @@
return wakeup
-# -----------------------------------------------------------
-# shutdown_action
-# schedules a wakeup and shuts down
-# -----------------------------------------------------------
-# Input: action (type Shutdown)
-# Result: -
-# Raises: -
-# -----------------------------------------------------------
def shutdown_action(action=None):
+ """
+ schedules a wakeup and shuts down
+
+ @param action: (type Shutdown)
+ """
_debug_('shutdown_action(action=%r)' % (action,), 2)
if (action == Shutdown.SHUTDOWN_WAKEUP):
_debug_("shutdown wakeup")
@@ -526,14 +504,14 @@
if (action == Shutdown.RESTART_SYSTEM):
_debug_("restart system")
__cleanup_freevo()
- __syscall(config.RESTART_SYS_CMD, config.AUTOSHUTDOWN_PRETEND)
+ __syscall(config.SYS_RESTART_CMD, config.AUTOSHUTDOWN_PRETEND)
# wait until the system halts/reboots
while 1:
time.sleep(1)
elif (action == Shutdown.SHUTDOWN_SYSTEM):
_debug_("shutdown system")
__cleanup_freevo()
- __syscall(config.SHUTDOWN_SYS_CMD, config.AUTOSHUTDOWN_PRETEND)
+ __syscall(config.SYS_SHUTDOWN_CMD, config.AUTOSHUTDOWN_PRETEND)
# wait until the system halts/reboots
while 1:
time.sleep(1)
@@ -551,15 +529,13 @@
# ***************************************************************
# PRIVATE HELPER FUNTIONS
# ***************************************************************
-# -----------------------------------------------------------
-# __schedule_wakeup
-# Schedules a wakeup in the bios
-# -----------------------------------------------------------
-# Input: -
-# Result: next action (shutdown or reboot)
-# Raises: -
-# -----------------------------------------------------------
+
def __schedule_wakeup_and_shutdown():
+ """
+ Schedules a wakeup in the bios
+
+ @returns: next action (shutdown or reboot)
+ """
_debug_('__schedule_wakeup_and_shutdown()', 2)
try:
wakeup_utc_s = get_next_wakeup()
@@ -570,7 +546,6 @@
else:
next_action = Shutdown.IGNORE
else:
-
# wake up a little earlier because of the time the booting takes
# 180 s = 3 min should be enough
wakeup_utc_s = wakeup_utc_s - 180
@@ -586,7 +561,7 @@
cmd = "%s %s --settime %d" % (config.AUTOSHUTDOWN_WAKEUP_CMD, \
config.AUTOSHUTDOWN_NVRAM_OPT, int(wakeup_utc_s))
ec = __syscall(cmd)
- if ec != 256 and ec != 0 :
+ if ec != 256 and ec != 0:
_debug_("Wakeup-command command '%s' failed!" % cmd, DERROR)
raise ExInternalError
elif ec == 256 or config.AUTOSHUTDOWN_BIOS_NEEDS_REBOOT:
@@ -618,14 +593,10 @@
def __cleanup_freevo():
- _debug_('__cleanup_freevo()', 2)
"""
- # Performs necessary actions for freevo shutdown
- # -----------------------------------------------------------
- # Input: -
- # Result: -
- # Raises: -
+ Performs necessary actions for freevo shutdown
"""
+ _debug_('__cleanup_freevo()', 2)
import osd
import plugin
import rc
@@ -657,14 +628,12 @@
osd.clearscreen(color=osd.COL_BLACK)
osd.shutdown()
-# -----------------------------------------------------------
-# __is_recordserver_remote
-# See if the recordserver is on this local machine
-# -----------------------------------------------------------
-# Input: None
-# Result: True/False
-# -----------------------------------------------------------
def __is_recordserver_remote():
+ """
+ See if the recordserver is on this local machine
+
+ @returns: True/False
+ """
_debug_('__is_recordserver_remote()', 2)
if len(glob.glob('/var/run/recordserver*.pid'))>0:
return False
@@ -674,6 +643,7 @@
return True
+updatedFavoritesSchedule = False
def __get_scheduled_recording(index):
"""
Get the start time of a recording from the reordserver
@@ -688,7 +658,12 @@
if __is_recordserver_remote():
raise ExRecordServerRemote
try:
- (result, schedule) = record_client.updateFavoritesSchedule()
+ # updateFavoritesScheduleNow is very expensive
+ if hasattr(config, 'AUTOSHUTDOWN_UPDATE_FAVORITES') and
config.AUTOSHUTDOWN_UPDATE_FAVORITES:
+ global updatedFavoritesSchedule
+ if not updatedFavoritesSchedule:
+ updatedFavoritesSchedule = True
+ record_client.updateFavoritesSchedule()
(result, schedule) = record_client.getScheduledRecordings()
except:
raise ExNoRecordServer
@@ -696,46 +671,30 @@
scheduled_programs = []
if result > 0:
proglist = schedule.getProgramList().values()
- if ((index + 1) > len(proglist) ):
+ if (index + 1) > len(proglist):
raise ExIndexNotAvailable
else:
f = lambda a, b: cmp(a.start, b.start)
proglist.sort(f)
wakeup = proglist[index].start
- _debug_("Scheduled recording %d at %s is %s" % (index, \
- time.ctime(wakeup), proglist[index]))
+ _debug_("Scheduled recording %d at %s is %s" % (index,
time.ctime(wakeup), proglist[index]))
else:
raise ExIndexNotAvailable
# we must take in consideration the TV_RECORD_PADDING_PRE here,
# otherwise we are to late for the recording
-
- # try if the user configured some paddings
- try:
- pre_padding = config.TV_RECORD_PADDING_PRE
- except:
- pre_padding = 0
- try:
- padding = config.TV_RECORD_PADDING
- except:
- padding = 0
- # take the longer padding
- if pre_padding < padding:
- pre_padding = padding
# and substract it from the next wakeup time
- wakeup = wakeup - pre_padding
+ wakeup -= config.TV_RECORD_PADDING_PRE
return wakeup
-# -----------------------------------------------------------
-# __get_next_default_wakeup
-# Calculate the next default wakeup time in seconds UTC
-# -----------------------------------------------------------
-# Input: None
-# Result: UTC time of next default wakeup
-# Raises: ExNoDefaultWakeup if default wakeup not available
-# -----------------------------------------------------------
def __get_next_default_wakeup():
+ """
+ Calculate the next default wakeup time in seconds UTC
+
+ @returns: UTC time of next default wakeup
+ @raises ExNoDefaultWakeup: if default wakeup not available
+ """
_debug_('__get_next_default_wakeup()', 2)
if not config.AUTOSHUTDOWN_DEFAULT_WAKEUP_TIME:
raise ExNoDefaultWakeup
@@ -767,15 +726,12 @@
return wakeup
-# -----------------------------------------------------------
-# __check_processes
-# checks if important processes are running
-# -----------------------------------------------------------
-# Input: None
-# Result: True/False
-# Raises: -
-# -----------------------------------------------------------
def __check_processes():
+ """
+ checks if important processes are running
+
+ @returns: True/False
+ """
_debug_('__check_processes()', 2)
if not config.AUTOSHUTDOWN_PROCESS_LIST:
return False
@@ -792,15 +748,14 @@
return False
-# -----------------------------------------------------------
-# __syscall
-# Calls system command and logs it
-# -----------------------------------------------------------
-# Input: cmd, pretend
-# Result: -
-# Raises: -
-# -----------------------------------------------------------
def __syscall(cmd, pretend=False):
+ """
+ Calls system command and logs it
+
+ @param cmd: command to run
+ @param pretend: pretend to run the command
+ @returns: result from the system command
+ """
_debug_('__syscall(cmd=%r, pretend=%r)' % (cmd, pretend), 2)
result = 0
if pretend:
Modified: branches/rel-1-7/freevo/src/plugins/cd_burn.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/cd_burn.py (original)
+++ branches/rel-1-7/freevo/src/plugins/cd_burn.py Fri Mar 21 12:58:43 2008
@@ -830,7 +830,7 @@
except Exception, e:
print 'fill_menu:', e
pass
-
+
if item.type == 'playlist':
#playlist burn
_debug_('Playlist item has media : %s ' % item.media)
Modified: branches/rel-1-7/freevo/src/plugins/ossmixer.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/ossmixer.py (original)
+++ branches/rel-1-7/freevo/src/plugins/ossmixer.py Fri Mar 21 12:58:43 2008
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# ossmixer.py - The mixer interface for freevo.
+# The oss mixer interface for freevo.
# -----------------------------------------------------------------------
# $Id$
#
Modified: branches/rel-1-7/freevo/src/plugins/remind.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/remind.py (original)
+++ branches/rel-1-7/freevo/src/plugins/remind.py Fri Mar 21 12:58:43 2008
@@ -1,10 +1,12 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# remind.py - a simple plugin show reminders, or the output of a command
+# A simple plugin show reminders, or the output of a command
# -----------------------------------------------------------------------
-# activate:
-# plugin.activate('reminders', level=45)
-# REMINDERS = [ ("cmd", "name", <wrap 0|N >, "string") ]
+# $Id$
+#
+# Notes:
+# Todo:
+#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
Modified: branches/rel-1-7/freevo/src/plugins/shutdown.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/shutdown.py (original)
+++ branches/rel-1-7/freevo/src/plugins/shutdown.py Fri Mar 21 12:58:43 2008
@@ -82,9 +82,9 @@
osd.shutdown()
if argshutdown and not argrestart:
- os.system(config.SHUTDOWN_SYS_CMD)
+ os.system(config.SYS_SHUTDOWN_CMD)
elif argrestart and not argshutdown:
- os.system(config.RESTART_SYS_CMD)
+ os.system(config.SYS_RESTART_CMD)
# let freevo be killed by init, looks nicer for mga
while 1:
time.sleep(1)
@@ -131,7 +131,7 @@
"""
return a list of actions for this item
"""
- if config.SHUTDOWN_CONFIRM:
+ if config.SYS_SHUTDOWN_CONFIRM:
items = [ (self.confirm_freevo, _('Shutdown Freevo') ),
(self.confirm_system, _('Shutdown system') ),
(self.confirm_system_restart, _('Restart system') ) ]
@@ -139,7 +139,7 @@
items = [ (self.shutdown_freevo, _('Shutdown Freevo') ),
(self.shutdown_system, _('Shutdown system') ),
(self.shutdown_system_restart, _('Restart system') )
]
- if config.SHUTDOWN_SYS_ENABLE:
+ if config.SYS_SHUTDOWN_ENABLE:
items = [ items[1], items[0], items[2] ]
return items
@@ -152,7 +152,7 @@
self.menuw = menuw
what = _('Do you really want to shut down Freevo?')
ConfirmBox(text=what, handler=self.shutdown_freevo,
- default_choice=config.SHUTDOWN_CONFIRM-1).show()
+ default_choice=config.SYS_SHUTDOWN_CONFIRM-1).show()
def confirm_system(self, arg=None, menuw=None):
@@ -162,7 +162,7 @@
self.menuw = menuw
what = _('Do you really want to shut down the system?')
ConfirmBox(text=what, handler=self.shutdown_system,
- default_choice=config.SHUTDOWN_CONFIRM-1).show()
+ default_choice=config.SYS_SHUTDOWN_CONFIRM-1).show()
def confirm_system_restart(self, arg=None, menuw=None):
@@ -172,7 +172,8 @@
self.menuw = menuw
what = _('Do you really want to restart the system?')
ConfirmBox(text=what, handler=self.shutdown_system_restart,
- default_choice=config.SHUTDOWN_CONFIRM-1).show()
+ default_choice=config.SYS_SHUTDOWN_CONFIRM-1).show()
+
def shutdown_freevo(self, arg=None, menuw=None):
"""
@@ -187,6 +188,7 @@
"""
shutdown(menuw=menuw, argshutdown=True, argrestart=False)
+
def shutdown_system_restart(self, arg=None, menuw=None):
"""
restart the complete system
@@ -195,12 +197,6 @@
-
-
-#
-# the plugins defined here
-#
-
class PluginInterface(MainMenuPlugin):
"""
Plugin to shutdown Freevo from the main menu
Modified: branches/rel-1-7/freevo/src/rc.py
==============================================================================
--- branches/rel-1-7/freevo/src/rc.py (original)
+++ branches/rel-1-7/freevo/src/rc.py Fri Mar 21 12:58:43 2008
@@ -300,7 +300,7 @@
"""
init the network event handler
"""
- _debug_('TcpNetwork.__init__()', 1)
+ _debug_('TcpNetwork.__init__()', 2)
self.port = config.REMOTE_CONTROL_TCP_PORT
self.host = config.REMOTE_CONTROL_TCP_HOST
self.sock = self.socket.socket(self.socket.AF_INET,
self.socket.SOCK_STREAM)
@@ -356,7 +356,7 @@
"""
init the network event handler
"""
- _debug_('Network.__init__()', 1)
+ _debug_('Network.__init__()', 2)
import socket
self.port = config.REMOTE_CONTROL_PORT
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -458,7 +458,7 @@
Class to transform input keys or buttons into events. This class
also handles the complete event queue (post_event)
"""
- def __init__(self, use_pylirc=1, use_netremote=1):
+ def __init__(self, use_pylirc=1, use_netremote=1, use_evdev=1):
self.inputs = []
if use_pylirc:
@@ -473,18 +473,17 @@
except:
pass
- try:
- self.inputs.append(Evdev())
- except:
- pass
+ if use_evdev:
+ try:
+ self.inputs.append(Evdev())
+ except:
+ pass
- if use_netremote and config.ENABLE_NETWORK_REMOTE and \
- config.REMOTE_CONTROL_PORT:
+ if use_netremote and config.ENABLE_NETWORK_REMOTE and
config.REMOTE_CONTROL_PORT:
self.inputs.append(Network())
if use_netremote and config.ENABLE_TCP_NETWORK_REMOTE and \
- config.REMOTE_CONTROL_TCP_PORT and \
- config.REMOTE_CONTROL_TCP_HOST:
+ config.REMOTE_CONTROL_TCP_PORT and
config.REMOTE_CONTROL_TCP_HOST:
self.inputs.append(TcpNetwork())
self.app = None
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog