Esempio n. 1
0
 def test_xlated_tz(self):
     localization.os.environ["LANG"] = "en_US"
     self.assertEqual("Europe/Barcelona", localization.get_xlated_timezone("Europe/Barcelona"))
     localization.os.environ["LANG"] = "cs_CZ"
     self.assertEqual("Evropa/Praha", localization.get_xlated_timezone("Europe/Prague"))
     localization.os.environ["LANG"] = "blah"
     self.assertRaises(localization.InvalidLocaleSpec,
                       localization.get_xlated_timezone,
                       "America/New_York")
Esempio n. 2
0
 def test_xlated_tz(self):
     localization.os.environ["LANG"] = "en_US"
     assert "Europe/Barcelona" == localization.get_xlated_timezone(
         "Europe/Barcelona")
     localization.os.environ["LANG"] = "cs_CZ"
     assert "Evropa/Praha" == localization.get_xlated_timezone(
         "Europe/Prague")
     localization.os.environ["LANG"] = "blah"
     with pytest.raises(localization.InvalidLocaleSpec):
         localization.get_xlated_timezone("America/New_York")
 def status(self):
     if self.data.timezone.timezone:
         if is_valid_timezone(self.data.timezone.timezone):
             return _("%s timezone") % get_xlated_timezone(self.data.timezone.timezone)
         else:
             return _("Invalid timezone")
     elif self._tzmap.get_timezone():
         return _("%s timezone") % get_xlated_timezone(self._tzmap.get_timezone())
     else:
         return _("Nothing selected")
Esempio n. 4
0
 def status(self):
     if self.data.timezone.timezone:
         if is_valid_timezone(self.data.timezone.timezone):
             return _("%s timezone") % get_xlated_timezone(self.data.timezone.timezone)
         else:
             return _("Invalid timezone")
     else:
         location = self._tzmap.get_location()
         if location and location.get_property("zone"):
             return _("%s timezone") % get_xlated_timezone(location.get_property("zone"))
         else:
             return _("Nothing selected")
Esempio n. 5
0
 def status(self):
     if self.data.timezone.timezone:
         if timezone.is_valid_timezone(self.data.timezone.timezone):
             return _("%s timezone") % get_xlated_timezone(
                 self.data.timezone.timezone)
         else:
             return _("Invalid timezone")
     elif self._tzmap.get_timezone():
         return _("%s timezone") % get_xlated_timezone(
             self._tzmap.get_timezone())
     else:
         return _("Nothing selected")
Esempio n. 6
0
    def _initialize(self):
        for day in xrange(1, 32):
            self.add_to_store(self._daysStore, day)

        for i in xrange(1, 13):
            #a bit hacky way, but should return the translated string
            #TODO: how to handle language change? Clear and populate again?
            month = datetime.date(2000, i, 1).strftime('%B')
            self.add_to_store(self._monthsStore, month)
            self._months_nums[month] = i

        for year in xrange(1990, 2051):
            self.add_to_store(self._yearsStore, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.iterkeys())
        for region, xlated in sorted(xlated_regions, cmp=_compare_regions):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities, cmp=_compare_cities):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        if self._radioButton24h.get_active():
            self._set_amPm_part_sensitive(False)

        self._update_datetime_timer_id = None
        if is_valid_timezone(self.data.timezone.timezone):
            self._set_timezone(self.data.timezone.timezone)
        elif not flags.flags.automatedInstall:
            log.warning(
                "%s is not a valid timezone, falling back to default (%s)",
                self.data.timezone.timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self.data.timezone.timezone = DEFAULT_TZ

        if not flags.can_touch_runtime_system("modify system time and date"):
            self._set_date_time_setting_sensitive(False)

        self._config_dialog = NTPconfigDialog(self.data)
        self._config_dialog.initialize()

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                              _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)
Esempio n. 7
0
    def status(self):
        kickstart_timezone = self._timezone_module.Timezone

        if kickstart_timezone:
            if is_valid_timezone(kickstart_timezone):
                return _("%s timezone") % get_xlated_timezone(kickstart_timezone)
            else:
                return _("Invalid timezone")
        else:
            location = self._tzmap.get_location()
            if location and location.get_property("zone"):
                return _("%s timezone") % get_xlated_timezone(location.get_property("zone"))
            else:
                return _("Nothing selected")
    def _initialize(self):
        for day in xrange(1, 32):
            self.add_to_store(self._daysStore, day)

        for i in xrange(1, 13):
            #a bit hacky way, but should return the translated string
            #TODO: how to handle language change? Clear and populate again?
            month = datetime.date(2000, i, 1).strftime('%B')
            self.add_to_store(self._monthsStore, month)
            self._months_nums[month] = i

        for year in xrange(1990, 2051):
            self.add_to_store(self._yearsStore, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.iterkeys())
        for region, xlated in sorted(xlated_regions, cmp=_compare_regions):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities, cmp=_compare_cities):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        if self._radioButton24h.get_active():
            self._set_amPm_part_sensitive(False)

        self._update_datetime_timer_id = None
        if is_valid_timezone(self.data.timezone.timezone):
            self._set_timezone(self.data.timezone.timezone)
        elif not flags.flags.automatedInstall:
            log.warning("%s is not a valid timezone, falling back to default (%s)",
                        self.data.timezone.timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self.data.timezone.timezone = DEFAULT_TZ

        if not flags.can_touch_runtime_system("modify system time and date"):
            self._set_date_time_setting_sensitive(False)

        self._config_dialog = NTPconfigDialog(self.data)
        self._config_dialog.initialize()

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                             _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)
Esempio n. 9
0
    def status(self):
        kickstart_timezone = self._timezone_module.proxy.Timezone

        if kickstart_timezone:
            if is_valid_timezone(kickstart_timezone):
                return _("%s timezone") % get_xlated_timezone(kickstart_timezone)
            else:
                return _("Invalid timezone")
        else:
            location = self._tzmap.get_location()
            if location and location.get_property("zone"):
                return _("%s timezone") % get_xlated_timezone(location.get_property("zone"))
            else:
                return _("Nothing selected")
Esempio n. 10
0
    def _initialize(self):
        # a bit hacky way, but should return the translated strings
        for i in range(1, 32):
            day = datetime.date(2000, 1, i).strftime(self._day_format)
            self.add_to_store_idx(self._daysStore, i, day)

        for i in range(1, 13):
            month = datetime.date(2000, i, 1).strftime(self._month_format)
            self.add_to_store_idx(self._monthsStore, i, month)

        for i in range(1990, 2051):
            year = datetime.date(i, 1, 1).strftime(self._year_format)
            self.add_to_store_idx(self._yearsStore, i, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.keys())
        for region, xlated in sorted(
                xlated_regions, key=functools.cmp_to_key(_compare_regions)):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities,
                                   key=functools.cmp_to_key(_compare_cities)):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        self._update_datetime_timer = None
        kickstart_timezone = self._timezone_module.proxy.Timezone
        if is_valid_timezone(kickstart_timezone):
            self._set_timezone(kickstart_timezone)
        elif not flags.flags.automatedInstall:
            log.warning(
                "%s is not a valid timezone, falling back to default (%s)",
                kickstart_timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self._timezone_module.proxy.SetTimezone(DEFAULT_TZ)

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                              _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)

        # report that we are done
        self.initialize_done()
Esempio n. 11
0
    def _initialize(self):
        # a bit hacky way, but should return the translated strings
        for i in range(1, 32):
            day = datetime.date(2000, 1, i).strftime(self._day_format)
            self.add_to_store_idx(self._daysStore, i, day)

        for i in range(1, 13):
            month = datetime.date(2000, i, 1).strftime(self._month_format)
            self.add_to_store_idx(self._monthsStore, i, month)

        for i in range(1990, 2051):
            year = datetime.date(i, 1, 1).strftime(self._year_format)
            self.add_to_store_idx(self._yearsStore, i, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.keys())
        for region, xlated in sorted(xlated_regions, key=functools.cmp_to_key(_compare_regions)):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities, key=functools.cmp_to_key(_compare_cities)):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        self._update_datetime_timer = None
        kickstart_timezone = self._timezone_module.proxy.Timezone
        if is_valid_timezone(kickstart_timezone):
            self._set_timezone(kickstart_timezone)
        elif not flags.flags.automatedInstall:
            log.warning("%s is not a valid timezone, falling back to default (%s)",
                        kickstart_timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self._timezone_module.proxy.SetTimezone(DEFAULT_TZ)

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                             _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)

        # report that we are done
        self.initialize_done()