Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Интернет » Web-программирование » Язык программирования Python (Питон, Пайтон)

Модерирует : Cheery

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

Язык программирования Python (Питон, Пайтон)
 ОтветГолосаПроценты
первый раз слышу8
1.37%
слыхал, но ничего сказать про него немогу142
24.40%
изучал, но меня от него не прёт25
4.30%
изучаю и скоро на него перейду258
44.33%
скрипты пишу в основном на нём94
16.15%
пишу только на нём47
8.08%
я из комманды разработчиков Python'а8
1.37%
Гости не могут голосовать, зарегистрируйтесть!Всего Голосов: 582
SharkyEXE

Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору


Код:
 
#  
from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Components.Button import Button
from Components.ActionMap import ActionMap
from Components.ConfigList import ConfigListScreen
from Components.config import config, ConfigDateTime, ConfigClock, getConfigListEntry
import enigma
from enigma import eTimer, iServiceInformation
from datetime import datetime
import gettext
import os
import time
import sys
 
def _(txt):
    t = gettext.gettext(txt)
    return t
 
 
def Plugins(**kwargs):
    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)]
 
 
def main(session, servicereference = None, **kwargs):
    try:
        session.open(SetClockMain)
    except:
        print '[SetClock] Pluginexecution failed'
 
 
def autostart(reason, **kwargs):
    pass
 
 
class AutoCorrTime(Screen):
    skin = '<screen position="100,100" size="280,300" title="SetClock" > </screen>'
 
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session
        if time.localtime().tm_year == 2000:
            self.limit = 0
            self.cursorTimer = eTimer()
            self.cursorTimer_conn = self.cursorTimer.timeout.connect(self.timer)
            self.cursorTimer.start(75, False)
 
    def timer(self):
        if time.localtime().tm_year > 2000:
            refstr = dtt = 'n/a'
            try:
                service = self.session.nav.getCurrentService()
                if service:
                    info = service.info()
                    if info:
                        refstr = info.getInfoString(iServiceInformation.sServiceref)
            except:
                refstr = 'ref error'
 
            if refstr == '1:0:1:1:65:64:3840000:0:0:0:':
                tc = time.time() - 13882
                dtt = datetime.fromtimestamp(tc).strftime('%Y%m%d%H%M')
                enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
                try:
                    os.system('/bin/date -s %s' % dtt)
                except:
                    pass
 
                self.cursorTimer.stop()
        self.limit = self.limit + 1
        if self.limit > 800:
            self.cursorTimer.stop()
 
 
class SetClockMain(ConfigListScreen, Screen):
    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>'
 
    def __init__(self, session, args = 0):
        self.skin = SetClockMain.skin
        self.session = session
        Screen.__init__(self, session)
        self.list = []
        self.date_en = ConfigDateTime(default=time.time(), formatstring='%d.%m.%Y')
        self.entryDate = getConfigListEntry(_('Date'), self.date_en)
        self.time_en = ConfigClock(default=time.time())
        self.entryTime = getConfigListEntry(_('Time'), self.time_en)
        self.list.append(self.entryDate)
        self.list.append(self.entryTime)
        self['key_red'] = Button(_('Cancel'))
        self['key_green'] = Button(_('SET!'))
        ConfigListScreen.__init__(self, self.list, session=session)
        self['setupActions'] = ActionMap(['SetupActions', 'ColorActions'], {'red': self.cancel,
         'green': self.set,
         'save': self.set,
         'cancel': self.cancel,
         'ok': self.set}, -2)
        self['config'].list = self.list
 
    def set(self, dtt = 0):
        d = time.localtime(self.date_en.value)
        dtt = '%d%02d%02d%02d%02d' % (d.tm_year,
         d.tm_mon,
         d.tm_mday,
         self.time_en.value[0],
         self.time_en.value[1])
        enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
        try:
            os.system('/bin/date -s %s' % dtt)
        except:
            pass
 
        self.close()
        print '[SetClock] SET! ** %s' % time.strftime('%X %x (%Y) %Z')
 
    def cancel(self):
        self.close()
 
 


Всего записей: 354 | Зарегистр. 25-01-2009 | Отправлено: 22:26 17-06-2018 | Исправлено: SharkyEXE, 12:38 12-08-2018
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Интернет » Web-программирование » Язык программирования Python (Питон, Пайтон)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru