enigma2: small bugfix (fixed elektro plugin crash)
[openembedded.git] / recipes / enigma2 / enigma2 / 0002-Harddisk.py-initialize-is_sleeping-in-__init__.patch
1 From bc21b4914845747336fa85724ba79ff96a223c43 Mon Sep 17 00:00:00 2001
2 From: ghost <andreas.monzner@dream-property.net>
3 Date: Sat, 11 Feb 2012 12:18:53 +0100
4 Subject: [PATCH] Harddisk.py: initialize is_sleeping in __init__
5
6 ---
7  usr/lib/enigma2/python/Components/Harddisk.py |    5 +++--
8  1 files changed, 3 insertions(+), 2 deletions(-)
9
10 diff --git a/usr/lib/enigma2/python/Components/Harddisk.py b/usr/lib/enigma2/python/Components/Harddisk.py
11 index 5b77f10..7690519 100644
12 --- a/usr/lib/enigma2/python/Components/Harddisk.py
13 +++ b/usr/lib/enigma2/python/Components/Harddisk.py
14 @@ -33,6 +33,7 @@ class Harddisk:
15                 else:
16                         print "Unable to determine structure of /dev"
17  
18 +               self.is_sleeping = False
19                 self.max_idle_time = 0
20                 self.idle_running = False
21                 self.timer = None
22 @@ -414,7 +415,6 @@ class Harddisk:
23         def startIdle(self):
24                 self.last_access = time.time()
25                 self.last_stat = 0
26 -               self.is_sleeping = False
27                 from enigma import eTimer
28  
29                 # disable HDD standby timer
30 @@ -422,6 +422,7 @@ class Harddisk:
31                         Console().ePopen(("sdparm", "sdparm", "--set=SCT=0", self.disk_path))
32                 else:
33                         Console().ePopen(("hdparm", "hdparm", "-S0", self.disk_path))
34 +
35                 self.timer = eTimer()
36                 self.timer.callback.append(self.runIdle)
37                 self.idle_running = True
38 @@ -451,13 +452,13 @@ class Harddisk:
39                 print "[IDLE]", idle_time, self.max_idle_time, self.is_sleeping
40                 if idle_time >= self.max_idle_time and not self.is_sleeping:
41                         self.setSleep()
42 -                       self.is_sleeping = True
43  
44         def setSleep(self):
45                 if self.bus() == "External":
46                         Console().ePopen(("sdparm", "sdparm", "--command=stop", self.disk_path))
47                 else:
48                         Console().ePopen(("hdparm", "hdparm", "-y", self.disk_path))
49 +               self.is_sleeping = True
50  
51         def setIdleTime(self, idle):
52                 self.max_idle_time = idle
53 -- 
54 1.7.9
55