SHARE
TWEET

Untitled

SharkyEXE Jul 29th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  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, ConfigDateTime, ConfigClock, getConfigListEntry
  9. import enigma
  10. from enigma import eTimer, iServiceInformation
  11. from datetime import datetime
  12. import gettext
  13. import os
  14. import time
  15. import sys
  16.  
  17. def _(txt):
  18.     t = gettext.gettext(txt)
  19.     return t
  20.  
  21.  
  22. def Plugins(**kwargs):
  23.     return [PluginDescriptor(name='SetClock', description='SetClock plug-in (c)2009 by SatCat', where=PluginDescriptor.WHERE_PLUGINMENU, icon='plugin.png', fnc=main), PluginDescriptor(name='SetClock', description='SetClock plug-in (c)2009 by SatCat', where=[PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc=autostart)]
  24.  
  25.  
  26. def main(session, servicereference = None, **kwargs):
  27.     try:
  28.         session.open(SetClockMain)
  29.     except:
  30.         print '[SetClock] Pluginexecution failed'
  31.  
  32.  
  33. def autostart(reason, **kwargs):
  34.     pass
  35.  
  36.  
  37. class AutoCorrTime(Screen):
  38.     skin = '<screen position="100,100" size="280,300" title="SetClock" > </screen>'
  39.  
  40.     def __init__(self, session):
  41.         Screen.__init__(self, session)
  42.         self.session = session
  43.         if time.localtime().tm_year == 2000:
  44.             self.limit = 0
  45.             self.cursorTimer = eTimer()
  46.             self.cursorTimer_conn = self.cursorTimer.timeout.connect(self.timer)
  47.             self.cursorTimer.start(75, False)
  48.  
  49.     def timer(self):
  50.         if time.localtime().tm_year > 2000:
  51.             refstr = dtt = 'n/a'
  52.             try:
  53.                 service = self.session.nav.getCurrentService()
  54.                 if service:
  55.                     info = service.info()
  56.                     if info:
  57.                         refstr = info.getInfoString(iServiceInformation.sServiceref)
  58.             except:
  59.                 refstr = 'ref error'
  60.  
  61.             if refstr == '1:0:1:1:65:64:3840000:0:0:0:':
  62.                 tc = time.time() - 13882
  63.                 dtt = datetime.fromtimestamp(tc).strftime('%Y%m%d%H%M')
  64.                 enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  65.                 try:
  66.                     os.system('/bin/date -s %s' % dtt)
  67.                 except:
  68.                     pass
  69.  
  70.                 self.cursorTimer.stop()
  71.         self.limit = self.limit + 1
  72.         if self.limit > 800:
  73.             self.cursorTimer.stop()
  74.  
  75.  
  76. class SetClockMain(ConfigListScreen, Screen):
  77.     skin = '\n\t\t<screen position="center,250" size="280,150" title="SetClock Menu" >\n\t\t\t<widget name="config" position="10,10" size="260,100" scrollbarMode="showOnDemand" />\n\t\t\t<widget name="key_green" \tposition="0,110" \tsize="140,40" valign="center" halign="center" zPosition="4"  foregroundColor="white" font="Regular;18" transparent="1"/> \n\t\t\t<ePixmap name="green"  \t\tposition="0,110" \tsize="140,40" zPosition="2" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />\n\t\t\t<widget name="key_red" \t\tposition="140,110" \tsize="140,40" valign="center" halign="center" zPosition="4"  foregroundColor="white" font="Regular;18" transparent="1"/> \n\t\t\t<ePixmap name="red"  \t\tposition="140,110" \tsize="140,40" zPosition="2" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />\n\t\t</screen>'
  78.  
  79.     def __init__(self, session, args = 0):
  80.         self.skin = SetClockMain.skin
  81.         self.session = session
  82.         Screen.__init__(self, session)
  83.         self.list = []
  84.         self.date_en = ConfigDateTime(default=time.time(), formatstring='%d.%m.%Y')
  85.         self.entryDate = getConfigListEntry(_('Date'), self.date_en)
  86.         self.time_en = ConfigClock(default=time.time())
  87.         self.entryTime = getConfigListEntry(_('Time'), self.time_en)
  88.         self.list.append(self.entryDate)
  89.         self.list.append(self.entryTime)
  90.         self['key_red'] = Button(_('Cancel'))
  91.         self['key_green'] = Button(_('SET!'))
  92.         ConfigListScreen.__init__(self, self.list, session=session)
  93.         self['setupActions'] = ActionMap(['SetupActions', 'ColorActions'], {'red': self.cancel,
  94.          'green': self.set,
  95.          'save': self.set,
  96.          'cancel': self.cancel,
  97.          'ok': self.set}, -2)
  98.         self['config'].list = self.list
  99.  
  100.     def set(self, dtt = 0):
  101.         d = time.localtime(self.date_en.value)
  102.         dtt = '%d%02d%02d%02d%02d' % (d.tm_year,
  103.          d.tm_mon,
  104.          d.tm_mday,
  105.          self.time_en.value[0],
  106.          self.time_en.value[1])
  107.         enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  108.         try:
  109.             os.system('/bin/date -s %s' % dtt)
  110.         except:
  111.             pass
  112.  
  113.         self.close()
  114.         print '[SetClock] SET! ** %s' % time.strftime('%X %x (%Y) %Z')
  115.  
  116.     def cancel(self):
  117.         self.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top