Commits

Guido Draheim committed aa7833f

generate chnannels.conf subset upon activate

Comments (0)

Files changed (2)

src/dvbcronrecording/channels.py

         data = {}
         data['message'] = message
         data['title'] = translate('Channel List')
-        data['adapterlist'] = self._adapter_list(req)
+        data['adapterlist'] = self.adapter_list(req)
         data["adapter"] = req.args.get("adapter", "0")
         data['new_datalist'] = newchannel_list
         data["_pagenum"] = req.args.get("_pagenum", "0")
         data = {}
         data['message'] = "" 
         data['title'] = translate('channels.conf text') + adapter
-        data['adapterlist'] = self._adapter_list(req)
+        data['adapterlist'] = self.adapter_list(req)
         data["adapter"] = adapter
         data['text'] = "\n".join(conf)
         data["rows"] = len(conf)
     """
       Returns list of the adapter settings
     """
-    def _adapter_list(self, req, defaults = [ 0 ]):
+    def adapter_list(self, req, defaults = [ 0 ]):
         return tuning_adapter_list(self.env, defaults)
     
 

src/dvbcronrecording/core.py

 RECORDING_CRON = "recording.cron"
 RECORDING_UPDATE_CRON = "recording-update.cron"
 RECORDING_UPDATE_CHANGE_CRON = "recording-update-change.cron"
+RECORDING_CHANNELSCONF = "channels%(adapter)s.conf"
 
 CHANNELSCONF = "~/.szap/{adapter}/channels.conf"
 
             crontab_reload = self.crontabreloadline()
             crontab_change = self.crontabchangeline()
             crontab_list = list(crontab_lines)
+            written_messages = []
+            for adapter in self.adapter_list(req):
+                filename = self.cron_channelsconf_filename(adapter)
+                conf = self.channelsconf_for_adapter(adapter)
+                if conf:
+                    written = self.writefile(req, filename, conf)
+                    written_messages += [ written ]
             a = self.writefile(req, self.cronfilename(), list(crontab_list))
             b = self.writefile(req, self.makefilename(), list(makefile_list))
             c = self.writefile(req, self.cron_update_filename(), [ crontab_reload ])
             e = translate("cron.will.be.updated.every")+(" %s" % self.cronminutes_string())
             if self.crondirectly:
                 e = self.writefile(req, self.cron_target_filename(), list(crontab_list))
-            data['messages'] = [ a, b, c, d, e ]
+            data['messages'] = written_messages + [ a, b, c, d, e ]
             data['cronlines'] = crontab_list # + [ " ============= "] + makefile_list
             data['_'] = translate
             add_stylesheet(req, PACKAGE+'/css/recordinglist.css')
             return []
         channels = DvbCronRecordingChannelsPlugin(self.env)
         return channels.channelname_to_channelconflist(req, channelname)
+    def adapter_list(self, req):
+        if DvbCronRecordingChannelsPlugin is None:
+            return [ 0 ]
+        channels = DvbCronRecordingChannelsPlugin(self.env)
+        return channels.adapter_list(req)
+    def channelsconf_for_adapter(self, adapter):
+        if DvbCronRecordingChannelsPlugin is None:
+            return [ 0 ]
+        channels = DvbCronRecordingChannelsPlugin(self.env)
+        return channels.channelsconf_for_adapter(adapter)
+
 
     """ 
         This is doing the actual computations
                 if ":" in adapter:
                     adapter, frontend = adapter.split(":",1)
                 if not channel: channel = item.channelname
-                channelsconf = self.channelsconf_filename(adapter)
+                channelsconf = self.cron_channelsconf_filename(adapter)
                 format = "%Y%m%d-"+ustr(adapter)+"%a-%H%M"
                 prefix = self.intodir+"/"
                 cmd = [ u"gnutv -adapter %(adapter)s -frontend %(frontend)s" ]
         return os.path.join(self.vardir, RECORDING_UPDATE_CRON)
     def cron_update_change_filename(self):
         return os.path.join(self.vardir, RECORDING_UPDATE_CHANGE_CRON)
+    def cron_channelsconf_filename(self, adapter):
+        if not adapter or adapter == "0": adapter = ""
+        return os.path.join(self.vardir, RECORDING_CHANNELSCONF % { "adapter" : str(adapter)})
     def cronminutes_string(self):
         cronminutes = ",".join([ item.strip() 
             for item in self.cronminutes if item.strip() ])