RecordTimer.py: cleanup imports
[enigma2.git] / RecordTimer.py
index ee5c6cf9d8f7b674a1645199f372523696a25466..cba161e3f17496f1687a98cf6fa9e39e2b0aa63b 100644 (file)
@@ -1,25 +1,20 @@
-import time
-#from time import datetime
-from Tools import Directories, Notifications, ASCIItranslit
-
-from Components.config import config
-import timer
-import xml.etree.cElementTree
-
 from enigma import eEPGCache, getBestPlayableServiceReference, \
        eServiceReference, iRecordableService, quitMainloop
 
-from Screens.MessageBox import MessageBox
+from Components.config import config
 from Components.TimerSanityCheck import TimerSanityCheck
-import NavigationInstance
 
+from Screens.MessageBox import MessageBox
 import Screens.Standby
-
-from time import localtime
-
+from Tools import Directories, Notifications, ASCIItranslit
 from Tools.XMLTools import stringToXML
+
+import timer
+import xml.etree.cElementTree
+import NavigationInstance
 from ServiceReference import ServiceReference
 
+from time import localtime, strftime, localtime, ctime, time
 from bisect import insort
 
 # ok, for descriptions etc we have:
@@ -67,8 +62,8 @@ class RecordTimerEntry(timer.TimerEntry, object):
                        recordings = NavigationInstance.instance.getRecordings()
                        if not recordings: # no more recordings exist
                                rec_time = NavigationInstance.instance.RecordTimer.getNextRecordingTime()
-                               if rec_time > 0 and (rec_time - time.time()) < 360:
-                                       print "another recording starts in", rec_time - time.time(), "seconds... do not shutdown yet"
+                               if rec_time > 0 and (rec_time - time()) < 360:
+                                       print "another recording starts in", rec_time - time(), "seconds... do not shutdown yet"
                                else:
                                        print "no starting records in the next 360 seconds... immediate shutdown"
                                        RecordTimerEntry.shutdown() # immediate shutdown
@@ -98,8 +93,8 @@ class RecordTimerEntry(timer.TimerEntry, object):
                timer.TimerEntry.__init__(self, int(begin), int(end))
 
                if checkOldTimers == True:
-                       if self.begin < time.time() - 1209600:
-                               self.begin = int(time.time())
+                       if self.begin < time() - 1209600:
+                               self.begin = int(time())
                
                if self.end < self.begin:
                        self.end = self.begin
@@ -127,12 +122,12 @@ class RecordTimerEntry(timer.TimerEntry, object):
                self.resetState()
        
        def log(self, code, msg):
-               self.log_entries.append((int(time.time()), code, msg))
+               self.log_entries.append((int(time()), code, msg))
                print "[TIMER]", msg
 
        def calculateFilename(self):
                service_name = self.service_ref.getServiceName()
-               begin_date = time.strftime("%Y%m%d %H%M", time.localtime(self.begin))
+               begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))
                
                print "begin_date: ", begin_date
                print "service_name: ", service_name
@@ -196,7 +191,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                                # we must calc nur start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get
                                # the next start time in evEnd event handler...
                                self.do_backoff()
-                               self.start_prepare = time.time() + self.backoff
+                               self.start_prepare = time() + self.backoff
 
                                NavigationInstance.instance.stopRecordService(self.record_service)
                                self.record_service = None
@@ -270,7 +265,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                                        self.log(13, "start record returned %d" % record_res)
                                        self.do_backoff()
                                        # retry
-                                       self.begin = time.time() + self.backoff
+                                       self.begin = time() + self.backoff
                                        return False
 
                                return True
@@ -299,7 +294,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                if not self.autoincrease:
                        return False
                if entry is None:
-                       new_end =  int(time.time()) + self.autoincreasetime
+                       new_end =  int(time()) + self.autoincreasetime
                else:
                        new_end = entry.begin -30
 
@@ -312,7 +307,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                        del simulTimerList
                        new_end -= 30                           # 30 Sekunden Prepare-Zeit lassen
                del dummyentry
-               if new_end <= time.time():
+               if new_end <= time():
                        return False
                self.end = new_end
                return True
@@ -350,7 +345,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                self.backoff = 0
                
                if int(old_prepare) != int(self.start_prepare):
-                       self.log(15, "record time changed, start prepare is now: %s" % time.ctime(self.start_prepare))
+                       self.log(15, "record time changed, start prepare is now: %s" % ctime(self.start_prepare))
 
        def gotRecordEvent(self, record, event):
                # TODO: this is not working (never true), please fix. (comparing two swig wrapped ePtrs)
@@ -603,7 +598,7 @@ class RecordTimer(timer.Timer):
                file.close()
 
        def getNextZapTime(self):
-               now = time.time()
+               now = time()
                for timer in self.timer_list:
                        if not timer.justplay or timer.begin < now:
                                continue
@@ -611,7 +606,7 @@ class RecordTimer(timer.Timer):
                return -1
 
        def getNextRecordingTime(self):
-               now = time.time()
+               now = time()
                for timer in self.timer_list:
                        next_act = timer.getNextActivation()
                        if timer.justplay or next_act < now:
@@ -620,7 +615,7 @@ class RecordTimer(timer.Timer):
                return -1
 
        def isNextRecordAfterEventActionAuto(self):
-               now = time.time()
+               now = time()
                t = None
                for timer in self.timer_list:
                        if timer.justplay or timer.begin < now: