3 from Components.Sources.Source import Source
4 from Components.Sources.Source import Source
5 from Components.Sources.ServiceList import ServiceList
6 from enigma import eServiceReference
9 from time import strftime, localtime, time
11 class WAPfunctions( Source):
24 def __init__(self, session,func = LISTTIME):
27 self.session = session
28 self.result = ["unknown command (%s)" % self.func]
30 def handleCommand(self,cmd):
31 print "WAPfunctions: handleCommand", cmd
32 if self.func is self.LISTTIME:
33 self.result = self.fillListTime(cmd)
34 elif self.func is self.REPEATED:
35 self.result = self.fillRepeated(cmd)
36 elif self.func is self.SERVICELIST:
37 self.result = self.serviceList(cmd)
38 elif self.func is self.OPTIONLIST:
39 self.result = self.fillOptionList(cmd)
40 elif self.func is self.FILLVALUE:
41 self.result = self.fillValue(cmd)
42 elif self.func is self.DELETEOLD:
43 self.result = self.deleteOldSaved(cmd)
45 self.result = ["unknown command cmd(%s) self.func(%s)" % (cmd, self.func)]
47 def fillListTime(self,param):
48 print "fillListTime",param
55 timePlusTwo = timeNow + 7200
57 if param.has_key('begin'):
58 begin = param['begin'] or 0
63 if param.has_key('end'):
64 end = param['end'] or 0
71 t["sday"]=strftime("%d", localtime(timeNow))
72 t["smonth"]=strftime("%m", localtime(timeNow))
73 t["syear"]=strftime("%Y", localtime(timeNow))
74 t["smin"]=strftime("%M", localtime(timeNow))
75 t["shour"]=strftime("%H", localtime(timeNow))
77 t["eday"]=strftime("%d", localtime(timePlusTwo))
78 t["emonth"]=strftime("%m", localtime(timePlusTwo))
79 t["eyear"]=strftime("%Y", localtime(timePlusTwo))
80 t["emin"]=strftime("%M", localtime(timePlusTwo))
81 t["ehour"]=strftime("%H", localtime(timePlusTwo))
89 cutKey = sub("^[es]", "", key, 1)
94 elif cutKey == "hour":
100 elif cutKey == "month":
107 if param[key] == "now" or param[key] == "end" or param[key] == "begin":
110 input = param[key] or 0
112 #print cutKey,param[key],input
114 self.result = self.fillOptionListAny(input,start,end)
117 def fillOptionListAny(self,input,start,end):
119 for i in range(start,end+1,1):
124 returnList1.append(j)
125 returnList1.append(i)
127 returnList1.append("selected")
129 returnList1.append("")
130 returnList.append(returnList1)
133 def fillRepeated(self,param):
134 print "fillRepeated",param
135 repeated = param or 0
136 repeated = int(repeated)
144 mo = ["mo", 1, "Mo "]#"Monday"]
145 tu = ["tu", 2, "Tu "]#"Tuesday"]
146 we = ["we", 4, "We "]#"Wednesday"]
147 th = ["th", 8, "Th "]#"Thursday"]
148 fr = ["fr", 16, "Fr "]#"Friday"]
149 sa = ["sa", 32, "Sa "]#"Saturday"]
150 su = ["su", 64, "Su "]#"Sunday"]
151 mf = ["mf", 31, "Mo-Fr"]
152 ms = ["ms", 127, "Mo-Su"]
155 repeated = repeated - 127
161 repeated = repeated - 64
167 repeated = repeated - 32
173 repeated = repeated - 31
179 repeated = repeated - 16
185 repeated = repeated - 8
191 repeated = repeated - 4
197 repeated = repeated - 2
203 repeated = repeated - 1
209 returnList.append(mo)
210 returnList.append(tu)
211 returnList.append(we)
212 returnList.append(th)
213 returnList.append(fr)
214 returnList.append(sa)
215 returnList.append(su)
216 returnList.append(mf)
217 returnList.append(ms)
221 def serviceList(self,param):
222 print "serviceList: ",param
223 sRef = str(param["sRef"])
224 bouquet = str(param["bouquet"])
229 bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'
230 ref = eServiceReference(bouquet)
231 self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
232 self.servicelist.setRoot(ref)
233 for (ref2, name) in self.servicelist.getServicesAsList():
234 print "ref2: (",ref2, ") name: (",name,")"
236 returnListPart.append(name)
237 returnListPart.append(ref2)
238 if ref2 == str(sRef):
239 returnListPart.append("selected")
242 returnListPart.append("")
243 returnList.append(returnListPart)
245 if sRefFound == 0 and sRef != '':
246 returnListPart = ["Inserted", sRef, "selected"]
247 returnList.append(returnListPart)
251 def getServiceList(self, ref):
252 self.servicelist.root = ref
254 def fillOptionList(self,param):
256 print "fillOptionList",param
258 if param.has_key("justplay"):
259 number = param["justplay"] or 0
262 returnList.append(["Record",0,""])
263 returnList.append(["Zap",1,"selected"])
265 returnList.append(["Record",0,"selected"])
266 returnList.append(["Zap",1,""])
267 elif param.has_key("afterevent"):
268 number = param["afterevent"] or 0
271 returnList.append(["Nothing",0,""])
272 returnList.append(["Standby",1,""])
273 returnList.append(["Deepstandby/Shutdown",2,""])
274 returnList.append(["Auto",3,"selected"])
276 returnList.append(["Nothing",0,""])
277 returnList.append(["Standby",1,""])
278 returnList.append(["Deepstandby/Shutdown",2,"selected"])
279 returnList.append(["Auto",3,""])
281 returnList.append(["Nothing",0,""])
282 returnList.append(["Standby",1,"selected"])
283 returnList.append(["Deepstandby/Shutdown",2,""])
284 returnList.append(["Auto",3,""])
286 returnList.append(["Nothing",0,"selected"])
287 returnList.append(["Standby",1,""])
288 returnList.append(["Deepstandby/Shutdown",2,""])
289 returnList.append(["Auto",3,""])
293 def deleteOldSaved(self,param):
294 print "deleteOldSaved",param
296 returnList.append(["deleteOldOnSave",param["deleteOldOnSave"],""])
297 returnList.append(["command",param["command"],""])
298 if int(param["deleteOldOnSave"]) == 1:
299 returnList.append(["channelOld",param["sRef"],""])
300 returnList.append(["beginOld",param["begin"],""])
301 returnList.append(["endOld",param["end"],""])
305 def fillValue(self,param):
306 print "fillValue: ",param
307 return [["",param,""]]
310 (result,text) = self.result
313 def filterXML(self, item):
314 item = item.replace("&", "&").replace("<", "<").replace('"', '"').replace(">", ">")
320 text = property(getText)
321 list = property(getList)