Commits

Guido Draheim committed 37cf37a

add adapter to cronname in makefile so that two recordings can start in parallel

  • Participants
  • Parent commits 69fd4e2

Comments (0)

Files changed (1)

File src/dvbcronrecording/core.py

 
 CHANNELSCONF = "~/.szap/{adapter}/channels.conf"
 
+default_adapter = u"0"
+
 from dvbcronrecording.db.session import db_cnx, commit
 from dvbcronrecording.db.schema import RecordingList #@UnresolvedImport
 
 
 class MakefileEntry: pass
 
+class AdapterList:
+    def __init__(self):
+        self._adapters = []
+    def number(self, adapter):
+        n = len(self.adapters)
+        if adapter not in self._adapters:
+            self.adapters += [ adapter ]
+        else:
+            n = self.adapters.index(adapter)
+        return n
+    def name(self, adapter):
+        return 'A' + adapter
+    def adaptername(self, item):
+        return getattr(item, "adapter", default_adapter)
+
 """
   here we are.
 """
         entries = self._recordings_list(req)
         computer = DvbCronRecordingPlanComputer(self.env)
         plan = computer.plan(entries)
+        adapterlist = AdapterList()
         for group in plan.groups():
             if not group.items: continue
             item = group.items[0]
             HH = item.newtimeMMM / 60
             MM = item.newtimeMMM % 60
+            AD = adapterlist.adaptername(item)
             if item.onlyday:
                 DD = str(item.onlyday)
                 EE = ",".join([str(month) for month in item.months ])
                 startcron = "%02d %02d %2s %2s *" % (int(MM), int(HH), DD, EE)
-                startname = "%02d.%02d.%02d.%s" % (int(HH), int(MM), item.onlyday, EE)
+                startname = "%02d.%02d.%02d.%s%s" % (int(HH), int(MM), item.onlyday, EE, AD)
             else:
                 WW = ustr(int(item.weekday)+1)
                 # WEEKDAY: tm_day Mo = 0 / -vs- / crontabs So = 0
                 startcron = "%02d %02d  *  * %s" % (int(MM), int(HH), WW)
-                startname = "%02d.%02d.%s" % (int(HH), int(MM), item.weekday)
+                startname = "%02d.%02d.%s%s" % (int(HH), int(MM), item.weekday, AD)
             lines = []
             for item in group.items:
                 newtimeMMM = item.newtimeMMM
                 if ":" in adapter:
                     adapter, frontend = adapter.split(":",1)
                 channelsconf = self.cron_channelsconf_filename(adapter)
-                format = "%Y%m%d-"+ustr(adapter)+"%a-%H%M"
+                format = "%Y%m%d-%a"+ustr(adapter)+"-%H%M"
                 prefix = self.intodir+"/"
                 cmd = [ u"gnutv -adapter %(adapter)s -frontend %(frontend)s" ]
                 cmd += [ u" -channels %(channelsconf)s" ]