コード例 #1
0
ファイル: Timezones.py プロジェクト: rimasx/enigma2
	def activateTimezone(self, tz, tzarea):
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/plugin.pyo") and config.plugins.autotimer.autopoll.value:
			print "[Timezones] trying to stop main AutoTimer poller"
			self.autopoller.stop()
			self.ATupdate = True

		if tzarea == Timezones.gen_label:
			fulltz = tz
		else:
			fulltz = "%s/%s" % (tzarea, tz)

		tzneed = "%s/%s" % (Timezones.tzbase, fulltz)
		if not path.isfile(tzneed):
			print "[Timezones] Attempt to set timezone", fulltz, "ignored. UTC used"
			fulltz = "UTC"
			tzneed = "%s/%s" % (Timezones.tzbase, fulltz)

		print "[Timezones] setting timezone to", fulltz
		environ['TZ'] = fulltz
		try:
			unlink("/etc/localtime")
		except OSError:
			pass
		try:
			symlink(tzneed, "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/plugin.pyo") and config.plugins.autotimer.autopoll.value:
			self.startATupdate()
コード例 #2
0
ファイル: Timezones.py プロジェクト: litvcom/enigma2-obh10
    def activateTimezone(self, tz, tzarea):
        if tzarea == Timezones.gen_label:
            fulltz = tz
        else:
            fulltz = "%s/%s" % (tzarea, tz)

        tzneed = "%s/%s" % (Timezones.tzbase, fulltz)
        if not path.isfile(tzneed):
            print "[Timezones] Attempt to set timezone", fulltz, "ignored. UTC used"
            fulltz = "UTC"
            tzneed = "%s/%s" % (Timezones.tzbase, fulltz)

        print "[Timezones] setting timezone to", fulltz
        environ['TZ'] = fulltz
        try:
            unlink("/etc/localtime")
        except OSError:
            pass
        try:
            symlink(tzneed, "/etc/localtime")
        except OSError:
            pass
        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()
コード例 #3
0
	def activateTimezone(self, zone, area, runCallbacks=True):
		tz = zone if area in ("Classic", "Generic") else pathjoin(area, zone)
		file = pathjoin(TIMEZONE_DATA, tz)
		if not isfile(file):
			print("[Timezones] Error: The time zone '%s' is not available!  Using 'UTC' instead." % tz)
			tz = "UTC"
			file = pathjoin(TIMEZONE_DATA, tz)
		print("[Timezones] Setting time zone to '%s'." % tz)
		try:
			unlink("/etc/localtime")
		except (IOError, OSError) as err:
			if err.errno != ENOENT:  # No such file or directory.
				print("[Timezones] Error %d: Unlinking '/etc/localtime'!  (%s)" % (err.errno, err.strerror))
		try:
			symlink(file, "/etc/localtime")
		except (IOError, OSError) as err:
			print("[Timezones] Error %d: Linking '%s' to '/etc/localtime'!  (%s)" % (err.errno, file, err.strerror))
		fileWriteLine("/etc/timezone", "%s\n" % tz, source=MODULE_NAME)
		environ["TZ"] = ":%s" % tz
		try:
			tzset()
		except Exception:
			from enigma import e_tzset
			e_tzset()
		if exists("/proc/stb/fp/rtc_offset"):
			setRTCoffset()
		timeFormat = "%a %d-%b-%Y %H:%M:%S"
		print("[Timezones] Local time is '%s'  -  UTC time is '%s'." % (strftime(timeFormat, localtime(None)), strftime(timeFormat, gmtime(None))))
		if runCallbacks:
			for callback in self.callbacks:
				callback()
コード例 #4
0
 def activateTimezone(self, zone):
     Log.i(zone)
     environ['TZ'] = zone
     try:
         unlink("/etc/localtime")
     except OSError:
         pass
     try:
         symlink("/usr/share/zoneinfo/%s" % (zone, ), "/etc/localtime")
     except OSError:
         pass
     e_tzset()
     config.timezone.save()
コード例 #5
0
    def activateTimezone(self, tz, tzarea):
        try:
            from Plugins.Extensions.AutoTimer.plugin import autotimer, autopoller
            self.autopoller = autopoller
            self.autotimer = autotimer
            if config.plugins.autotimer.autopoll.value:
                print("[Timezones] trying to stop main AutoTimer poller")
                if autopoller is not None:
                    autopoller.stop()
                self.ATupdate = True
        except ImportError as KeyError:
            pass

        if tzarea == Timezones.gen_label:
            fulltz = tz
        else:
            fulltz = "%s/%s" % (tzarea, tz)

        tzneed = "%s/%s" % (Timezones.tzbase, fulltz)
        if not path.isfile(tzneed):
            print("[Timezones] Attempt to set timezone", fulltz,
                  "ignored. UTC used")
            fulltz = "UTC"
            tzneed = "%s/%s" % (Timezones.tzbase, fulltz)

        print("[Timezones] setting timezone to", fulltz)
        environ['TZ'] = fulltz
        try:
            unlink("/etc/localtime")
        except OSError:
            pass
        try:
            symlink(tzneed, "/etc/localtime")
        except OSError:
            pass
        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()
        try:
            from Plugins.Extensions.AutoTimer.plugin import autotimer, autopoller
            self.autopoller = autopoller
            self.autotimer = autotimer
            if config.plugins.autotimer.autopoll.value:
                self.startATupdate()
        except ImportError as KeyError:
            pass
コード例 #6
0
 def activateTimezone(self, zone, area):
     # print "[Timezones] activateTimezone DEBUG: Area='%s', Zone='%s'" % (area, zone)
     self.autotimerCheck()
     if self.autotimerAvailable and config.plugins.autotimer.autopoll.value:
         print "[Timezones] Trying to stop main AutoTimer poller."
         if self.autotimerPoller is not None:
             self.autotimerPoller.stop()
         self.autotimerUpdate = True
     tz = zone if area in ("Classic", "Generic") else path.join(area, zone)
     file = path.join(TIMEZONE_DATA, tz)
     if not path.isfile(file):
         print "[Timezones] Error: The time zone '%s' is not available!  Using 'UTC' instead." % tz
         tz = "UTC"
         file = path.join(TIMEZONE_DATA, tz)
     print "[Timezones] Setting time zone to '%s'." % tz
     try:
         unlink("/etc/localtime")
     except (IOError, OSError) as err:
         if err.errno != errno.ENOENT:  # No such file or directory
             print "[Timezones] Error %d: Unlinking '/etc/localtime'! (%s)" % (
                 err.errno, err.strerror)
     try:
         symlink(file, "/etc/localtime")
     except (IOError, OSError) as err:
         print "[Timezones] Error %d: Linking '%s' to '/etc/localtime'! (%s)" % (
             err.errno, file, err.strerror)
     try:
         with open("/etc/timezone", "w") as fd:
             fd.write("%s\n" % tz)
     except (IOError, OSError) as err:
         print "[Timezones] Error %d: Updating '/etc/timezone'! (%s)" % (
             err.errno, err.strerror)
     environ["TZ"] = ":%s" % tz
     try:
         time.tzset()
     except Exception:
         from enigma import e_tzset
         e_tzset()
     if path.exists("/proc/stb/fp/rtc_offset"):
         setRTCoffset()
     if self.autotimerAvailable and config.plugins.autotimer.autopoll.value:
         if self.autotimerUpdate:
             self.timer.stop()
         if self.autotimeQuery not in self.timer.callback:
             self.timer.callback.append(self.autotimeQuery)
         print "[Timezones] AutoTimer poller will be run in %d minutes." % AT_POLL_DELAY
         self.timer.startLongTimer(AT_POLL_DELAY * 60)
コード例 #7
0
ファイル: Timezones.py プロジェクト: henrylicious/test
 def activateTimezone(self, zone, area, runCallbacks=True):
     tz = zone if area in ("Classic", "Generic") else path.join(area, zone)
     _file = path.join(TIMEZONE_DATA, tz)
     if not path.isfile(_file):
         print(
             "[Timezones] Error: The time zone '%s' is not available!  Using 'UTC' instead."
             % tz)
         tz = "UTC"
         _file = path.join(TIMEZONE_DATA, tz)
     print("[Timezones] Setting time zone to '%s'." % tz)
     try:
         unlink("/etc/localtime")
     except (IOError, OSError) as err:
         if err.errno != errno.ENOENT:  # No such file or directory
             print(
                 "[Timezones] Error %d: Unlinking '/etc/localtime'! (%s)" %
                 (err.errno, err.strerror))
     try:
         symlink(_file, "/etc/localtime")
     except (IOError, OSError) as err:
         print(
             "[Timezones] Error %d: Linking '%s' to '/etc/localtime'! (%s)"
             % (err.errno, _file, err.strerror))
     try:
         with open("/etc/timezone", "w") as fd:
             fd.write("%s\n" % tz)
     except (IOError, OSError) as err:
         print("[Timezones] Error %d: Updating '/etc/timezone'! (%s)" %
               (err.errno, err.strerror))
     environ["TZ"] = ":%s" % tz
     try:
         time.tzset()
     except Exception:
         from enigma import e_tzset
         e_tzset()
     if path.exists("/proc/stb/fp/rtc_offset"):
         setRTCoffset()
     now = int(time())
     timeFormat = "%a %d-%b-%Y %H:%M:%S"
     print("[Timezones] Local time is '%s'  -  UTC time is '%s'." %
           (strftime(timeFormat,
                     localtime(now)), strftime(timeFormat, gmtime(now))))
     if runCallbacks:
         for method in self.callbacks:
             if method:
                 method()
コード例 #8
0
	def activateTimezone(self, index):
		if len(self.timezones) <= index:
			return

		environ['TZ'] = self.timezones[index][1]
		try:
			unlink("/etc/localtime")
		except OSError:
			pass
		try:
			symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
コード例 #9
0
ファイル: Timezones.py プロジェクト: bally12345/enigma2
	def activateTimezone(self, index):
		if len(self.timezones) <= index:
			return

		environ['TZ'] = self.timezones[index][1]
		try:
			unlink("/etc/localtime")
		except OSError:
			pass
		try:
			symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
コード例 #10
0
    def activateTimezone(self, index):
        if len(self.timezones) <= index:
            return

        environ['TZ'] = self.timezones[index][1]
        #		try:
        #			unlink(eEnv.resolve("${sysconfdir}/localtime"))
        #		except OSError:
        #			pass
        #		try:
        #			symlink(eEnv.resolve("${datarootdir}/zoneinfo/%s") %(self.timezones[index][1]), eEnv.resolve("${sysconfdir}/localtime"))
        #		except OSError:
        #			pass
        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()
コード例 #11
0
ファイル: Timezones.py プロジェクト: Caught/openpliPC
	def activateTimezone(self, index):
		if len(self.timezones) <= index:
			return
		
		environ['TZ'] = self.timezones[index][1]
		try:
			unlink(eEnv.resolve("${sysconfdir}/localtime"))
		except OSError:
			pass
		try:
			symlink(eEnv.resolve("${datarootdir}/zoneinfo/%s") %(self.timezones[index][1]), eEnv.resolve("${sysconfdir}/localtime"))
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
コード例 #12
0
ファイル: Timezones.py プロジェクト: barssaoui/openbh-enigma2
    def activateTimezone(self, tz, tzarea):
        if path.exists(
                "/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/plugin.pyo"
        ) and config.plugins.autotimer.autopoll.value:
            print "[Timezones] trying to stop main AutoTimer poller"
            self.autopoller.stop()
            self.ATupdate = True

        if tzarea == Timezones.gen_label:
            fulltz = tz
        else:
            fulltz = "%s/%s" % (tzarea, tz)

        tzneed = "%s/%s" % (Timezones.tzbase, fulltz)
        if not path.isfile(tzneed):
            print "[Timezones] Attempt to set timezone", fulltz, "ignored. UTC used"
            fulltz = "UTC"
            tzneed = "%s/%s" % (Timezones.tzbase, fulltz)

        print "[Timezones] setting timezone to", fulltz
        environ['TZ'] = fulltz
        try:
            unlink("/etc/localtime")
        except OSError:
            pass
        try:
            symlink(tzneed, "/etc/localtime")
        except OSError:
            pass
        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()

        if path.exists("/proc/stb/fp/rtc_offset"):
            setRTCoffset()

        if path.exists(
                "/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/plugin.pyo"
        ) and config.plugins.autotimer.autopoll.value:
            self.startATupdate()
コード例 #13
0
	def activateTimezone(self, index):
		if len(self.timezones) <= index:
			return

		os.environ['TZ'] = self.timezones[index][1]
		try:
			os.unlink("/etc/localtime")
		except OSError:
			pass
		try:
			os.symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
		if os.path.exists("/proc/stb/fp/rtc_offset"):
 			setRTCoffset()
コード例 #14
0
	def activateTimezone(self, index):
		if len(self.timezones) <= index:
			return
		
		environ['TZ'] = self.timezones[index][1]
		try:
			unlink("/etc/localtime")
		except OSError:
			pass
		try:
			symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()
#+++>
		import os
		from enigma import e_daylight
		if e_daylight() == False:
			try:
				os.popen("/bin/cubefpctl --setdaylight 0")
			except OSError:
				print "no memory"
		else:
			try:
				os.popen("/bin/cubefpctl --setdaylight 1")
			except OSError:
				print "no memory"
		time.sleep(1)
		try:
			os.popen("/bin/cubefpctl --setgmtoffset")
		except OSError:
			print "no memory"
		try:
			os.popen("/bin/cubefpctl --syncfptime")
		except OSError:
			print "no memory"
コード例 #15
0
    def activateTimezone(self, index):
        if len(self.timezones) <= index:
            return
        environ['TZ'] = self.timezones[index][1]
        try:
            unlink('/etc/localtime')
        except OSError:
            pass

        try:
            symlink('/usr/share/zoneinfo/%s' % self.timezones[index][1], '/etc/localtime')
        except OSError:
            pass

        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()

        if path.exists('/proc/stb/fp/rtc_offset'):
            setRTCoffset()
コード例 #16
0
ファイル: Timezones.py プロジェクト: OpenVu/e2-gui
            print "[Timezones] Attempt to set timezone", fulltz, "ignored. UTC used"
            fulltz = "UTC"
            tzneed = "%s/%s" % (Timezones.tzbase, fulltz)

        print "[Timezones] setting timezone to", fulltz
        environ['TZ'] = fulltz
        try:
            unlink("/etc/localtime")
        except OSError:
            pass
        try:
            symlink(tzneed, "/etc/localtime")
        except OSError:
            pass
        try:
            time.tzset()
        except:
            from enigma import e_tzset
            e_tzset()
        try:
            from Plugins.Extensions.AutoTimer.plugin import autotimer, autopoller
            self.autopoller = autopoller
            self.autotimer = autotimer
            if config.plugins.autotimer.autopoll.value:
                self.startATupdate()
        except ImportError, KeyError:
            pass


timezones = Timezones()
コード例 #17
0
ファイル: Timezones.py プロジェクト: sklnet/openbh-enigma2
		print "[Timezones] setting timezone to", fulltz
		environ['TZ'] = fulltz
		try:
			unlink("/etc/localtime")
		except OSError:
			pass
		try:
			symlink(tzneed, "/etc/localtime")
		except OSError:
			pass
		try:
			time.tzset()
		except:
			from enigma import e_tzset
			e_tzset()

		if path.exists("/proc/stb/fp/rtc_offset"):
			setRTCoffset()

		try:
			from Plugins.Extensions.AutoTimer.plugin import autotimer, autopoller
			self.autopoller = autopoller
			self.autotimer = autotimer
			if config.plugins.autotimer.autopoll.value:
				self.startATupdate()
		except ImportError, KeyError:
			pass

timezones = Timezones()