Advertisement
SharkyEXE

Untitled

Sep 23rd, 2018
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.92 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from Plugins.Plugin import PluginDescriptor
  3. from Screens.Screen import Screen
  4. from Screens.MessageBox import MessageBox
  5. from Components.Button import Button
  6. from Components.ActionMap import ActionMap
  7. from Components.ConfigList import ConfigListScreen
  8. from Components.config import config, ConfigSubsection, ConfigDateTime, ConfigClock, ConfigText, getConfigListEntry, ConfigInteger, ConfigSequence, ConfigSelection
  9. import enigma
  10. from enigma import eTimer, iServiceInformation
  11. from datetime import datetime, time as dt_time
  12. from os import system
  13. import gettext
  14. import time, httplib
  15. from Screens.Console import Console
  16. import os
  17. from os import popen
  18.  
  19. config.plugins.SetClock = ConfigSubsection()
  20. config.plugins.SetClock.HostName = ConfigText(default='vniiftri.ru', fixed_size=False)
  21. #config.plugins.SetClock.NTPName01 = ConfigText(default='vniiftri2.khv.ru', fixed_size=False)
  22. #config.plugins.SetClock.NTPName02 = ConfigText(default='vniiftri.khv.ru', fixed_size=False)
  23. #config.plugins.SetClock.NTPName03 = ConfigText(default='ntp2.niiftri.irkutsk.ru', fixed_size=False)
  24. #config.plugins.SetClock.NTPName04 = ConfigText(default='ntp1.niiftri.irkutsk.ru', fixed_size=False)
  25. #config.plugins.SetClock.NTPName05 = ConfigText(default='ntp21.vniiftri.ru', fixed_size=False)
  26. #config.plugins.SetClock.NTPName06 = ConfigText(default='ntp4.vniiftri.ru', fixed_size=False)
  27. #config.plugins.SetClock.NTPName07 = ConfigText(default='ntp3.vniiftri.ru', fixed_size=False)
  28. #config.plugins.SetClock.NTPName08 = ConfigText(default='ntp1.vniiftri.ru', fixed_size=False)
  29. #config.plugins.SetClock.NTPName09 = ConfigText(default='ntp2.vniiftri.ru', fixed_size=False)
  30. config.plugins.SetClock.NTPName01 = ConfigText(default='ntp2.vniiftri.ru', fixed_size=False)
  31. config.plugins.SetClock.timeout = ConfigInteger(default = 20, limits = (0,120))
  32. config.plugins.SetClock.syncDVBtime = ConfigSelection(default = "1", choices = [("1", _("Нажмите OK"))])
  33. ver = '1.1'
  34.  
  35. #def _(txt):
  36. #t = gettext.gettext(txt)
  37. #return t
  38.  
  39.  
  40. #def Plugins(**kwargs):
  41. def Plugins(path, **kwargs):
  42. global plugin_path
  43. plugin_path = path
  44. return [PluginDescriptor(name='SetClock', description='SetClock plug-in v.' + ver + ' (c)2011 by SatCat', where=PluginDescriptor.WHERE_PLUGINMENU, icon='plugin.png', fnc=main), PluginDescriptor(name='SetClock', description='SetClock plug-in v.' + ver + '(c)2011 by SatCat', where=[PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc=autostart)]
  45.  
  46.  
  47. def main(session, servicereference = None, **kwargs):
  48. #try:
  49. session.open(SetClockMain)
  50. #except:
  51. #print '[SetClock] Pluginexecution failed'
  52.  
  53.  
  54. def autostart(reason, **kwargs):
  55. global session
  56. if reason == 0 and kwargs.has_key('session'):
  57. session = kwargs['session']
  58. session.open(AutoCorrTime)
  59.  
  60.  
  61. def get_time_str(res_time):
  62. replace_months = {
  63. 'Jan': '1',
  64. 'Feb': '2',
  65. 'Mar': '3',
  66. 'Apr': '4',
  67. 'May': '5',
  68. 'June': '6',
  69. 'Jun': '6',
  70. 'July': '7',
  71. 'Jul': '7',
  72. 'Aug': '8',
  73. 'Sept': '9',
  74. 'Sep': '9',
  75. 'Oct': '10',
  76. 'Nov': '11',
  77. 'Dec': '12'
  78. }
  79. gmts = [
  80. 'UTC',
  81. 'GMT'
  82. ]
  83. _res_time = res_time
  84. try:
  85. time_tuple = time.strptime(res_time, '%a, %d %b %Y %H:%M:%S %Z')
  86. except ValueError:
  87. for m1, m2 in replace_months.items():
  88. res_time = res_time.replace(m1, m2)
  89. for gmt in gmts:
  90. res_time = res_time.replace(gmt, '')
  91. res_time = res_time.split(', ')[1].strip()
  92. try:
  93. time_tuple = time.strptime(res_time, '%d %m %Y %H:%M:%S')
  94. #open('/usr/lib/enigma2/python/Plugins/Extensions/SetClock/log.txt', 'a').write(_res_time)
  95. except ValueError:
  96. open('/usr/lib/enigma2/python/Plugins/Extensions/SetClock/log.txt', 'a').write(_res_time)
  97. raise
  98. t = time.localtime(time.mktime(time_tuple) - time.timezone)
  99. return time.strftime('%Y%m%d%H%M.%S', t)
  100.  
  101. class AutoCorrTime(Screen):
  102. skin = '''
  103. <screen position="100,100" size="280,300" title="SetClock" >
  104. </screen>'''
  105.  
  106. def __init__(self, session):
  107. Screen.__init__(self, session)
  108. self.session = session
  109. if time.localtime().tm_year == 2000:
  110. self.limit = 0
  111. self.cursorTimer = eTimer()
  112. self.cursorTimer.callback.append(self.timer)
  113. self.cursorTimer.start(75, False)
  114.  
  115. def timer(self):
  116. if time.localtime().tm_year > 2000:
  117. refstr = dtt = 'n/a'
  118. try:
  119. service = self.session.nav.getCurrentService()
  120. if service:
  121. info = service.info()
  122. if info:
  123. refstr = info.getInfoString(iServiceInformation.sServiceref)
  124. except:
  125. refstr = 'ref error'
  126.  
  127. if refstr == '1:0:1:1:65:64:3840000:0:0:0:':
  128. tc = time.time() - 189391980
  129. dtt = datetime.fromtimestamp(tc).strftime('%Y%m%d%H%M')
  130. enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  131. try:
  132. system('/bin/date -s %s' % dtt)
  133. print '[SetClock] Set clock!'
  134. except:
  135. pass
  136.  
  137. self.cursorTimer.stop()
  138. print '[SetClock] Stop timer.'
  139. self.limit = self.limit + 1
  140. if self.limit > 1200:
  141. self.cursorTimer.stop()
  142. print '[SetClock] Stop timer (limit).'
  143.  
  144.  
  145. class SetClockMain(ConfigListScreen, Screen):
  146. skin = '''
  147. <screen position="center,200" size="640,365" title="SetClock" >
  148. <widget name="config" position="0,0" size="640,365" scrollbarMode="showOnDemand" />
  149. <widget name="key_red" position="0,325" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1"/>
  150. <ePixmap name="red" position="0,325" size="140,40" zPosition="2" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
  151. <widget name="key_green" position="140,325" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1"/>
  152. <ePixmap name="green" position="140,325" size="140,40" zPosition="2" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
  153. <widget name="key_yellow" position="280,325" size="140,40" valign="center" halign="center" zPosition="4" backgroundColor="#a08500" font="Regular;20" transparent="1"/>
  154. <ePixmap name="yellow" position="280,325" size="140,40" zPosition="2" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
  155. <widget name="key_blue" position="395,325" size="270,40" valign="center" halign="center" zPosition="4" backgroundColor="#a08500" font="Regular;20" transparent="1"/>
  156. <ePixmap name="blue" position="420,325" size="270,40" zPosition="2" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
  157. <ePixmap name="blue" position="500,325" size="140,40" zPosition="2" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
  158. </screen>'''
  159.  
  160. #def __init__(self, session, args = 0):
  161. def __init__(self, session, servicelist = None, args = None):
  162. self.servicelist = servicelist
  163. self.skin = SetClockMain.skin
  164. self.session = session
  165. Screen.__init__(self, session)
  166. self.list = []
  167. self.date_en = ConfigDate(default=time.time())
  168. self.entryDate = getConfigListEntry(_('Дата :'), self.date_en)
  169. self.time_en = ConfigClock(default=time.time())
  170. self.entryTime = getConfigListEntry(_('Время :'), self.time_en)
  171. self.list.append(self.entryDate)
  172. self.list.append(self.entryTime)
  173. self.list.append(getConfigListEntry('HTTP хост :', config.plugins.SetClock.HostName))
  174. #self.list.append(getConfigListEntry('NTP сервер № 01 :', config.plugins.SetClock.NTPName01))
  175. #self.list.append(getConfigListEntry('NTP сервер № 02 :', config.plugins.SetClock.NTPName02))
  176. #self.list.append(getConfigListEntry('NTP сервер № 03 :', config.plugins.SetClock.NTPName03))
  177. #self.list.append(getConfigListEntry('NTP сервер № 04 :', config.plugins.SetClock.NTPName04))
  178. #self.list.append(getConfigListEntry('NTP сервер № 05 :', config.plugins.SetClock.NTPName05))
  179. #self.list.append(getConfigListEntry('NTP сервер № 06 :', config.plugins.SetClock.NTPName06))
  180. #self.list.append(getConfigListEntry('NTP сервер № 07 :', config.plugins.SetClock.NTPName07))
  181. #self.list.append(getConfigListEntry('NTP сервер № 08 :', config.plugins.SetClock.NTPName08))
  182. #self.list.append(getConfigListEntry('NTP сервер № 09 :', config.plugins.SetClock.NTPName09))
  183. self.list.append(getConfigListEntry('NTP сервер № 01 :', config.plugins.SetClock.NTPName01))
  184. self.list.append(getConfigListEntry(_('NTP сервер таймаут [сек] :'), config.plugins.SetClock.timeout))
  185. #self.list.append(getConfigListEntry(_('Синхронизировать сейчас с текущего транспондера'), config.plugins.SetClock.syncDVBtime))
  186. #self.list.append(getConfigListEntry(_('Синхронизация сейчас с текущего транспондера'), config.plugins.SetClock.syncDVBtime))
  187. #self.list.append(getConfigListEntry(_('Синхронизация с транспондера :'), config.plugins.SetClock.syncDVBtime))
  188. self.list.append(getConfigListEntry(_('Синхронизация с текущего транспондера :'), config.plugins.SetClock.syncDVBtime))
  189. self['key_red'] = Button(_('Отмена'))
  190. self['key_green'] = Button(_('HTTP SET'))
  191. self['key_yellow'] = Button(_('NTP SET'))
  192. self['key_blue'] = Button(_('Установить!'))
  193. ConfigListScreen.__init__(self, self.list, session=session)
  194. self['setupActions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'red': self.exit,
  195. 'green': self.inet_set,
  196. 'yellow': self.NTP_set,
  197. #'blue': self.set,
  198. 'blue': self.keyBlue,
  199. 'cancel': self.exit,
  200. #'ok': self.pressed_ok,
  201. 'ok': self.keyGo}, -2)
  202. self['config'].list = self.list
  203. self['config'].l.setList(self.list)
  204. self["config"].onSelectionChanged.append(self.configPosition)
  205.  
  206. #def pressed_ok(self):
  207. #sel = self["config"].getCurrent() and self["config"].getCurrent()[0]
  208. #if sel == _("HTTP хост :"):
  209. #config.plugins.SetClock.HostName.save()
  210. #if sel == _("NTP сервер № 01 :"):
  211. #config.plugins.SetClock.NTPName01.save()
  212. #config.plugins.SetClock.NTPName02.save()
  213. #config.plugins.SetClock.NTPName03.save()
  214. #config.plugins.SetClock.NTPName04.save()
  215. #config.plugins.SetClock.NTPName05.save()
  216. #config.plugins.SetClock.NTPName06.save()
  217. #config.plugins.SetClock.NTPName07.save()
  218. #config.plugins.SetClock.NTPName08.save()
  219. #config.plugins.SetClock.NTPName09.save()
  220. #if sel == _("NTP сервер таймаут [сек] :"):
  221. #config.plugins.SetClock.timeout.save()
  222. #self.set()
  223. #self.close()
  224. #self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  225.  
  226. ##def pressed_ok1(self):
  227. ##config.plugins.SetClock.HostName.save()
  228. #config.plugins.SetClock.NTPName01.save()
  229. #config.plugins.SetClock.NTPName02.save()
  230. #config.plugins.SetClock.NTPName03.save()
  231. #config.plugins.SetClock.NTPName04.save()
  232. #config.plugins.SetClock.NTPName05.save()
  233. #config.plugins.SetClock.NTPName06.save()
  234. #config.plugins.SetClock.NTPName07.save()
  235. #config.plugins.SetClock.NTPName08.save()
  236. #config.plugins.SetClock.NTPName09.save()
  237. #config.plugins.SetClock.timeout.save()
  238. #self.set()
  239. #self.close()
  240. ##self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  241. #self.close()
  242. ##self.exit()
  243.  
  244. ##def pressed_ok2(self):
  245. #config.plugins.SetClock.HostName.save()
  246. ##config.plugins.SetClock.NTPName01.save()
  247. #config.plugins.SetClock.NTPName02.save()
  248. #config.plugins.SetClock.NTPName03.save()
  249. #config.plugins.SetClock.NTPName04.save()
  250. #config.plugins.SetClock.NTPName05.save()
  251. #config.plugins.SetClock.NTPName06.save()
  252. #config.plugins.SetClock.NTPName07.save()
  253. #config.plugins.SetClock.NTPName08.save()
  254. #config.plugins.SetClock.NTPName09.save()
  255. #config.plugins.SetClock.timeout.save()
  256. #self.set()
  257. #self.close()
  258. ##self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  259. #self.close()
  260. ##self.exit()
  261.  
  262. ##def pressed_ok3(self):
  263. #config.plugins.SetClock.HostName.save()
  264. #config.plugins.SetClock.NTPName01.save()
  265. #config.plugins.SetClock.NTPName02.save()
  266. #config.plugins.SetClock.NTPName03.save()
  267. #config.plugins.SetClock.NTPName04.save()
  268. #config.plugins.SetClock.NTPName05.save()
  269. #config.plugins.SetClock.NTPName06.save()
  270. #config.plugins.SetClock.NTPName07.save()
  271. #config.plugins.SetClock.NTPName08.save()
  272. #config.plugins.SetClock.NTPName09.save()
  273. ##config.plugins.SetClock.timeout.save()
  274. #self.set()
  275. #self.close()
  276. ##self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  277. #self.close()
  278. ##self.exit()
  279.  
  280. def set(self, dtt = 0):
  281. if self.date_en.value[2] >= 2038 and self.date_en.value[1] >= 1 and self.date_en.value[0] >= 19 and self.time_en.value[0] >= 6 and self.time_en.value[1] >= 14 and self.time_en.value[2] > 5:
  282. self.date_en.value[2] = 2038
  283. self.date_en.value[1] = 1
  284. self.date_en.value[0] = 19
  285. self.time_en.value[0] = 6
  286. self.time_en.value[1] = 14
  287. self.time_en.value[2] = 5
  288. dtt = '%d%02d%02d%02d%02d.%02d' % (self.date_en.value[2],
  289. self.date_en.value[1],
  290. self.date_en.value[0],
  291. self.time_en.value[0],
  292. self.time_en.value[1],
  293. self.time_en.value[2])
  294. enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  295. try:
  296. system('/bin/date -s %s' % dtt)
  297. except:
  298. pass
  299.  
  300. self.close()
  301. #print '[SetClock] SET! ** %s' % time.strftime('%X %x (%Y) %Z')
  302.  
  303. def inet_set(self):
  304. config.plugins.SetClock.HostName.save()
  305. conn = httplib.HTTPConnection(config.plugins.SetClock.HostName.value)
  306. try:
  307. conn.request('HEAD', '/favicon.ico')
  308. t_rtt = time.clock()
  309. res_time = conn.getresponse().getheader('date')
  310. except:
  311. self.session.open(MessageBox, 'Error: No server responce: ' + config.plugins.SetClock.HostName.value, MessageBox.TYPE_ERROR, timeout=3)
  312. return
  313.  
  314. enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  315.  
  316. try:
  317. system('/bin/date -s %s' % get_time_str(res_time))
  318. except:
  319. pass
  320.  
  321. self.close()
  322. #print '[SetClock] inet SET! ** %s' % time.strftime('%X %x (%Y) %Z')
  323.  
  324. #def cancel(self):
  325. #self.close()
  326.  
  327. def save(self):
  328. for x in self['config'].list:
  329. x[1].save()
  330. self.close()
  331.  
  332. def exit(self):
  333. for x in self['config'].list:
  334. x[1].cancel()
  335. self.close()
  336.  
  337. def NTP_set(self):
  338. #if (config.plugins.SetClock.NTPName01.value == "" and config.plugins.SetClock.NTPName02.value == "" and config.plugins.SetClock.NTPName03.value == "" and config.plugins.SetClock.NTPName04.value == "" and config.plugins.SetClock.NTPName05.value == "" and config.plugins.SetClock.NTPName06.value == "" and config.plugins.SetClock.NTPName07.value == "" and config.plugins.SetClock.NTPName08.value == "" and config.plugins.SetClock.NTPName09.value == ""):
  339. #self.session.open(MessageBox, _("no timeserver configured!"), MessageBox.TYPE_INFO)
  340. #else:
  341. log_file = open('/usr/lib/enigma2/python/Plugins/Extensions/SetClock/log.txt', 'a')
  342. def execute_cmd(cmd):
  343. log_file.write("Начинаю выполнять команду: %s" % cmd)
  344. fo = popen(cmd)
  345. output = fo.read()
  346. exit_code = fo.close()
  347. log_file.write("Результат выполнения команды: %s; вывод: `%s`; код-завершения: %i" % (cmd, output, 0 if exit_code is None else exit_code))
  348. return output
  349. if os.path.exists(os.path.join(plugin_path, "ntpdate")):
  350. log_file.write("Программа существует по указанному пути")
  351. #Lite_OutPut_In_Console_1_stroke
  352. #cmd = '/usr/bin/ntpdate -b -t %s %s && echo "\n"' % (config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName.value)
  353. #cmd = '%s%s %s %s && echo "\n"' % (plugin_path, "/ntpdate -b -t ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value)
  354. #cmd = '%s%s %s %s %s %s %s %s %s %s %s %s && echo "\n"' % (plugin_path, "/ntpdate -b -t ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value, config.plugins.SetClock.NTPName02.value, config.plugins.SetClock.NTPName03.value, config.plugins.SetClock.NTPName04.value, config.plugins.SetClock.NTPName05.value, config.plugins.SetClock.NTPName06.value, config.plugins.SetClock.NTPName07.value, config.plugins.SetClock.NTPName08.value, config.plugins.SetClock.NTPName09.value)
  355. #Extended_OutPut_In_Console_2_stroke
  356. #cmd = '/usr/bin/ntpdate -v -u %s %s && echo "\n"' % (config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName.value)
  357. cmd = '%s%s %s %s && echo "\n"' % (plugin_path, "/ntpdate -v -u ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value)
  358. #cmd = '%s%s %s %s %s %s %s %s %s %s %s %s && echo "\n"' % (plugin_path, "/ntpdate -v -u ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value, config.plugins.SetClock.NTPName02.value, config.plugins.SetClock.NTPName03.value, config.plugins.SetClock.NTPName04.value, config.plugins.SetClock.NTPName05.value, config.plugins.SetClock.NTPName06.value, config.plugins.SetClock.NTPName07.value, config.plugins.SetClock.NTPName08.value, config.plugins.SetClock.NTPName09.value)
  359. res = execute_cmd(cmd)
  360. if res == "":
  361. cmd = "ls -l %s%s" % (plugin_path, "/ntpdate")
  362. res = execute_cmd(cmd)
  363. if res[3]!="x":
  364. cmd = "chmod 755 %s%s" % (plugin_path, "/ntpdate")
  365. res = execute_cmd(cmd)
  366. self.session.open(MessageBox, _("ntpdate problem: attributes for 'ntpdate' have not been correct! Fixed now! Try again!\n%s" % res), MessageBox.TYPE_INFO)
  367. else:
  368. self.session.open(MessageBox, _("ntpdate problem: Internet connection ok? Time server ok?"), MessageBox.TYPE_INFO)
  369. else:
  370. self.session.open(MyConsole, _("Системное время с NTP ..."), [cmd])
  371. self.close()
  372. self.close()
  373. else:
  374. log_file.write("Программа не существует по указанному пути")
  375. self.session.open(MessageBox, _("'ntpdate' не установлен !"), MessageBox.TYPE_ERROR)
  376. log_file.close()
  377.  
  378. #self.close()
  379. #print '[SetClock] NTP SET! ** %s' % time.strftime('%X %x (%Y) %Z')
  380.  
  381. #self.close()
  382. #print '[SetClock] NTP SET! ** %s' % time.strftime('%X %x (%Y) %Z')
  383.  
  384. #def keyLeft(self):
  385. def keyGo(self):
  386. sel = self["config"].getCurrent() and self["config"].getCurrent()[0]
  387. if sel == _("Синхронизация с текущего транспондера :"):
  388. #if os.path.exists("/usr/bin/dvbdate"):
  389. if os.path.exists(os.path.join(plugin_path, "dvbdate")):
  390. #cmd = '/usr/bin/dvbdate -p -s -f && echo "\n"'
  391. cmd = '%s%s && echo "\n"' % (plugin_path, "/dvbdate -p -s -f")
  392. res = popen(cmd).read()
  393. if res == "":
  394. cmd = "ls -l %s%s" % (plugin_path, "/dvbdate")
  395. res = popen(cmd).read()
  396. if res[3]!="x":
  397. cmd = "chmod 755 %s%s" % (plugin_path, "/dvbdate")
  398. res = popen(cmd).read()
  399. self.session.open(MessageBox, _("dvbdate problem: attributes for 'dvbdate' have not been correct! Fixed now! Try again!\n%s" % res), MessageBox.TYPE_INFO)
  400. else:
  401. self.session.open(MessageBox, _("dvbdate problem: Satellite connection ok?"), MessageBox.TYPE_INFO)
  402. else:
  403. self.session.open(MyConsole, _("Системное время с DVB ..."), [cmd])
  404. self.close()
  405. self.close()
  406. else:
  407. self.session.open(MessageBox, _("'dvbdate' не установлен !"), MessageBox.TYPE_ERROR)
  408. if sel == _("Дата :"):
  409. self.set()
  410. if sel == _("Время :"):
  411. self.set()
  412. if sel == _("HTTP хост :"):
  413. #self.pressed_ok1()
  414. #self.pressed_ok()
  415. config.plugins.SetClock.HostName.save()
  416. self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  417. self.exit()
  418. #self.close()
  419. #self.close()
  420. if sel == _("NTP сервер № 01 :"):
  421. #self.pressed_ok2()
  422. #self.pressed_ok()
  423. config.plugins.SetClock.NTPName01.save()
  424. self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  425. self.exit()
  426. #self.close()
  427. #self.close()
  428. if sel == _("NTP сервер таймаут [сек] :"):
  429. #self.pressed_ok3()
  430. #self.pressed_ok()
  431. config.plugins.SetClock.timeout.save()
  432. self.session.open(MessageBox, _("Настройки сохранены !"), MessageBox.TYPE_INFO)
  433. self.exit()
  434. #self.close()
  435. #self.close()
  436. #else:
  437. #self.pressed_ok()
  438.  
  439. def configPosition(self):
  440. self["key_blue"].setText("")
  441. #idx = self["config"].getCurrent()[1]
  442. #if idx == self.ST.syncDVBtime:
  443. sel = self["config"].getCurrent() and self["config"].getCurrent()[0]
  444. #sel = self["config"].getCurrent() # Do Not Work
  445. #self["config"].getCurrent()[0] # Do Not Work
  446. #if sel == ((_("Дата")) or (_("Время"))):
  447. #self["key_blue"].setText(_("Установить!"))
  448. if sel == _("Дата :"):
  449. self["key_blue"].setText(_("Установить!"))
  450. if sel == _("Время :"):
  451. self["key_blue"].setText(_("Установить!"))
  452. #if sel == ((_("HTTP хост :")) or (_("NTP сервер № 01 :")) or (_("NTP сервер таймаут [сек] :"))):
  453. #self["key_blue"].setText(_("Сохранить"))
  454. if sel == _("HTTP хост :"):
  455. self["key_blue"].setText(_("Сохранить"))
  456. if sel == _("NTP сервер № 01 :"):
  457. self["key_blue"].setText(_("Сохранить"))
  458. if sel == _("NTP сервер таймаут [сек] :"):
  459. self["key_blue"].setText(_("Сохранить"))
  460. if sel == _("Синхронизация с текущего транспондера :"):
  461. self["key_blue"].setText(_("Выбор транспондера"))
  462. #else:
  463. #self["key_blue"].setText(_("Установить!"))
  464.  
  465. def keyBlue(self):
  466. if self["key_blue"].getText() == _("Выбор транспондера"):
  467. if self.servicelist is None:
  468. for (dlg,flag) in self.session.dialog_stack:
  469. if dlg.__class__.__name__ == "InfoBar":
  470. self.servicelist = dlg.servicelist
  471. break
  472. if not self.servicelist is None:
  473. self.session.execDialog(self.servicelist)
  474. #if self["key_blue"].getText() == _("Установить!"):
  475. #self.set()
  476. else:
  477. self.keyGo()
  478.  
  479. class MyConsole(Console):
  480. skin = '''
  481. <screen position="center,245" size="485,290" title="Command execution..." >
  482. <widget name="text" position="0,0" size="485,290" font="Regular;20" />
  483. </screen>'''
  484.  
  485. def __init__(self, session, title = "My Console...", cmdlist = None):
  486. Console.__init__(self, session, title, cmdlist)
  487.  
  488. date_limits = [(1, 31), (1, 12), (1970, 2090)]
  489. class ConfigDate(ConfigSequence):
  490. def __init__(self, default):
  491. d = time.localtime(default)
  492. ConfigSequence.__init__(self, seperator=".", limits=date_limits, default=[d.tm_mday, d.tm_mon, d.tm_year])
  493.  
  494. time_limits = [(0, 23), (0, 59), (0, 59)]
  495. class ConfigClock(ConfigSequence):
  496. def __init__(self, default):
  497. d = time.localtime(default)
  498. ConfigSequence.__init__(self, seperator=":", limits=time_limits, default=[d.tm_hour, d.tm_min, d.tm_sec])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement