示例#1
0
def InitTimeZones():
	tz = geolocation.get("timezone", None)
	proxy = geolocation.get("proxy", False)
	if tz is None or proxy is True:
		area = DEFAULT_AREA
		zone = timezones.getTimezoneDefault(area=area)
		if proxy:
			msg = " - proxy in use"
		else:
			msg = ""
		print "[Timezones] Geolocation not available%s!  (area='%s', zone='%s')" % (msg, area, zone)
	elif DEFAULT_AREA == "Classic":
		area = "Classic"
		zone = tz
		print "[Timezones] Classic mode with geolocation tz='%s'.  (area='%s', zone='%s')" % (tz, area, zone)
	else:
		area, zone = tz.split("/", 1)
		print "[Timezones] Modern mode with geolocation tz='%s'.  (area='%s', zone='%s')" % (tz, area, zone)
	config.timezone = ConfigSubsection()
	config.timezone.area = ConfigSelection(default=area, choices=timezones.getTimezoneAreaList())
	config.timezone.val = ConfigSelection(default=timezones.getTimezoneDefault(), choices=timezones.getTimezoneList())
	if not config.timezone.area.value and config.timezone.val.value.find("/") == -1:
		config.timezone.area.value = "Generic"
	try:
		tzLink = path.realpath("/etc/localtime")[20:]
		msgs = []
		if config.timezone.area.value == "Classic":
			if config.timezone.val.value != tzLink:
				msgs.append("time zone '%s' != '%s'" % (config.timezone.val.value, tzLink))
		else:
			tzSplit = tzLink.find("/")
			if tzSplit == -1:
				tzArea = "Generic"
				tzVal = tzLink
			else:
				tzArea = tzLink[:tzSplit]
				tzVal = tzLink[tzSplit + 1:]
			if config.timezone.area.value != tzArea:
				msgs.append("area '%s' != '%s'" % (config.timezone.area.value, tzArea))
			if config.timezone.val.value != tzVal:
				msgs.append("zone '%s' != '%s'" % (config.timezone.val.value, tzVal))
		if len(msgs):
			print "[Timezones] Warning: Enigma2 time zone does not match system time zone (%s), setting system to Enigma2 time zone!" % ",".join(msgs)
	except (IOError, OSError):
		pass

	def timezoneAreaChoices(configElement):
		choices = timezones.getTimezoneList(area=configElement.value)
		config.timezone.val.setChoices(choices=choices, default=timezones.getTimezoneDefault(area=configElement.value, choices=choices))
		if config.timezone.val.saved_value and config.timezone.val.saved_value in [x[0] for x in choices]:
			config.timezone.val.value = config.timezone.val.saved_value

	def timezoneNotifier(configElement):
		timezones.activateTimezone(configElement.value, config.timezone.area.value)

	config.timezone.area.addNotifier(timezoneAreaChoices, initial_call=False, immediate_feedback=True)
	config.timezone.val.addNotifier(timezoneNotifier, initial_call=True, immediate_feedback=True)
	config.timezone.val.callNotifiersOnSaveAndCancel = True
示例#2
0
def InitTimeZones():
	tz = geolocation.get("timezone", None)
	if tz is None:
		area = DEFAULT_AREA
		zone = timezones.getTimezoneDefault(area=area)
		print "[Timezones] Geolocation not available!  (area='%s', zone='%s')" % (area, zone)
	elif DEFAULT_AREA == "Classic":
		area = "Classic"
		zone = tz
		print "[Timezones] Classic mode with geolocation tz='%s', area='%s', zone='%s'." % (tz, area, zone)
	else:
		area, zone = tz.split("/", 1)
		print "[Timezones] Modern mode with geolocation tz='%s', area='%s', zone='%s'." % (tz, area, zone)
	config.timezone = ConfigSubsection()
	config.timezone.area = ConfigSelection(default=area, choices=timezones.getTimezoneAreaList())
	config.timezone.val = ConfigSelection(default=timezones.getTimezoneDefault(), choices=timezones.getTimezoneList())
	if not config.timezone.area.saved_value:
		config.timezone.area.value = area
	if not config.timezone.val.saved_value:
		config.timezone.val.value = zone
	config.timezone.save()

	def timezoneAreaChoices(configElement):
		choices = timezones.getTimezoneList(area=configElement.value)
		config.timezone.val.setChoices(choices=choices, default=timezones.getTimezoneDefault(area=configElement.value, choices=choices))
		if config.timezone.val.saved_value and config.timezone.val.saved_value in [x[0] for x in choices]:
			config.timezone.val.value = config.timezone.val.saved_value

	def timezoneNotifier(configElement):
		timezones.activateTimezone(configElement.value, config.timezone.area.value)

	config.timezone.area.addNotifier(timezoneAreaChoices, initial_call=False, immediate_feedback=True)
	config.timezone.val.addNotifier(timezoneNotifier, initial_call=True, immediate_feedback=True)
	config.timezone.val.callNotifiersOnSaveAndCancel = True
示例#3
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self.setTitle(_("Geolocation"))

		GeolocationText = _("Geolocation information") + "\n"

		GeolocationText += "\n"

		try:
			continent = geolocation.get("continent", None)
			if continent is not None:
				GeolocationText +=  _("Continent: ") + continent + "\n"

			country = geolocation.get("country", None)
			if country is not None:
				GeolocationText +=  _("Country: ") + country + "\n"

			state = geolocation.get("regionName", None)
			if state is not None:
				GeolocationText +=  _("State: ") + state + "\n"

			city = geolocation.get("city", None)
			if city is not None:
				GeolocationText +=  _("City: ") + city + "\n"

			GeolocationText += "\n"

			timezone = geolocation.get("timezone", None)
			if timezone is not None:
				GeolocationText +=  _("Timezone: ") + timezone + "\n"

			currency = geolocation.get("currency", None)
			if currency is not None:
				GeolocationText +=  _("Currency: ") + currency + "\n"

			GeolocationText += "\n"

			latitude = geolocation.get("lat", None)
			if str(float(latitude)) is not None:
				GeolocationText +=  _("Latitude: ") + str(float(latitude)) + "\n"

			longitude = geolocation.get("lon", None)
			if str(float(longitude)) is not None:
				GeolocationText +=  _("Longitude: ") + str(float(longitude)) + "\n"
			self["AboutScrollLabel"] = ScrollLabel(GeolocationText)
		except Exception as e:
			self["AboutScrollLabel"] = ScrollLabel(_("Requires internet connection"))

		self["key_red"] = Button(_("Close"))

		self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
			{
				"cancel": self.close,
				"ok": self.close,
				"up": self["AboutScrollLabel"].pageUp,
				"down": self["AboutScrollLabel"].pageDown
			})
示例#4
0
	def createscreen(self):
		self.AboutText = ""
		self.iface = "eth0"
		eth0 = about.getIfConfig('eth0')
		if 'addr' in eth0:
			self.AboutText += _("IP:") + "\t" + eth0['addr'] + "\n"
			if 'netmask' in eth0:
				self.AboutText += _("Netmask:") + "\t" + eth0['netmask'] + "\n"
			if 'hwaddr' in eth0:
				self.AboutText += _("MAC:") + "\t" + eth0['hwaddr'] + "\n"
			self.iface = 'eth0'

		eth1 = about.getIfConfig('eth1')
		if 'addr' in eth1:
			self.AboutText += _("IP:") + "\t" + eth1['addr'] + "\n"
			if 'netmask' in eth1:
				self.AboutText += _("Netmask:") + "\t" + eth1['netmask'] + "\n"
			if 'hwaddr' in eth1:
				self.AboutText += _("MAC:") + "\t" + eth1['hwaddr'] + "\n"
			self.iface = 'eth1'

		ra0 = about.getIfConfig('ra0')
		if 'addr' in ra0:
			self.AboutText += _("IP:") + "\t" + ra0['addr'] + "\n"
			if 'netmask' in ra0:
				self.AboutText += _("Netmask:") + "\t" + ra0['netmask'] + "\n"
			if 'hwaddr' in ra0:
				self.AboutText += _("MAC:") + "\t" + ra0['hwaddr'] + "\n"
			self.iface = 'ra0'

		wlan0 = about.getIfConfig('wlan0')
		if 'addr' in wlan0:
			self.AboutText += _("IP:") + "\t" + wlan0['addr'] + "\n"
			if 'netmask' in wlan0:
				self.AboutText += _("Netmask:") + "\t" + wlan0['netmask'] + "\n"
			if 'hwaddr' in wlan0:
				self.AboutText += _("MAC:") + "\t" + wlan0['hwaddr'] + "\n"
			self.iface = 'wlan0'

		wlan3 = about.getIfConfig('wlan3')
		if 'addr' in wlan3:
			self.AboutText += _("IP:") + "\t" + wlan3['addr'] + "\n"
			if 'netmask' in wlan3:
				self.AboutText += _("Netmask:") + "\t" + wlan3['netmask'] + "\n"
			if 'hwaddr' in wlan3:
				self.AboutText += _("MAC:") + "\t" + wlan3['hwaddr'] + "\n"
			self.iface = 'wlan3'

		rx_bytes, tx_bytes = about.getIfTransferredData(self.iface)
		self.AboutText += "\n"
		self.AboutText += _("Bytes received:") + "\t" + rx_bytes + "\n"
		self.AboutText += _("Bytes sent:") + "\t" + tx_bytes + "\n"

		isp = geolocation.get("isp", None)
		isporg = geolocation.get("org", None)
		self.AboutText += "\n"
		if isp is not None:
			if isporg is not None:
				self.AboutText += _("ISP: ") + isp + " " + "(" + isporg + ")" + "\n"
			else:
				self.AboutText += _("ISP: ") + isp + "\n"

		mobile = geolocation.get("mobile", False)
		if mobile is not False:
			self.AboutText += _("Mobile: ") + _("Yes") + "\n"
		else:
			self.AboutText += _("Mobile: ") + _("No") + "\n"

		proxy = geolocation.get("proxy", False)
		if proxy is not False:
			self.AboutText += _("Proxy: ") + _("Yes") + "\n"
		else:
			self.AboutText += _("Proxy: ") + _("No") + "\n"

		publicip = geolocation.get("query", None)
		if str(publicip) != "":
			self.AboutText +=  _("Public IP: ") + str(publicip) + "\n"

		self.AboutText += "\n"

		self.console = Console()
		self.console.ePopen('ethtool %s' % self.iface, self.SpeedFinished)