def post(self,request): dictData=request.data #print dictData try: hostIdValue=dictData['id'].encode('utf-8') hostSecretValue=dictData['secret'].encode('utf-8') # save the data to database SystemSettings.setHostId(hostIdValue) SystemSettings.setHostSecret(hostSecretValue) except Exception : return Response(rejectStatus) return Response(successStatus)
def get(self,request): hostId=SystemSettings.getHostId() hostSecret=SystemSettings.getHostSecret() print hostId,hostSecret #the hostId and hostSecret my be empty because it was not set if ((hostId=="") or (hostSecret=="")): return Response(rejectStatus) statusDict={} bandwagonHostService=BandwagonHostService(id=hostId,key=hostSecret) #print bandwagonHostService.getBasicInformation() statusDict['basic_information']=json.loads(bandwagonHostService.getBasicInformation()) statusDict['service_information']=json.loads(bandwagonHostService.getServiceInformation()) statusDict['available_os']=json.loads(bandwagonHostService.getAvailableOS()) return Response(statusDict)
def update(self, secs=None): clock_format = SystemSettings.get_clock_format() location_time = self.get_location_time(secs) if clock_format == '12h': t = location_time.strftime("%I:%M %p") else: t = location_time.strftime("%H:%M") if t.startswith("0"): t = t[1:] if not t == self._last_time \ or not self.sunrise == self._last_sunrise \ or not self.sunset == self._last_sunset: is_light = self.get_is_light(location_time) if is_light: img = os.path.join(Dirs.get_image_dir(), "cities", "day.png") else: img = os.path.join(Dirs.get_image_dir(), "cities", "night.png") day = self.get_day(secs) if day == "Today": self.drawing.render(t, img, is_light) else: self.drawing.render(t, img, is_light, day) if self.path and self.list_store: self.list_store[self.path][1] = self.drawing.pixbuf if self.standalone: self.standalone.update(img, t, self.sunrise, self.sunset) self._last_time = t
def _on_slider_format_value(self, scale, value): #TODO: Sync this code with DigitalClock (and pull code into utils.py where necessary) clock_format = SystemSettings.get_clock_format() value_time = self.get_time() tomorrow = date.today() + timedelta(days=1) if clock_format == "12h": if value_time.date() >= tomorrow: time_str = value_time.strftime("%I:%M %p tomorrow") else: time_str = value_time.strftime("%I:%M %p") else: if value_time.date() >= tomorrow: time_str = value_time.strftime("%H:%M tomorrow") else: time_str = value_time.strftime("%H:%M") if time_str.startswith("0"): time_str = time_str[1:] return time_str
def update(self, img, text, sunrise, sunset): size = 72000 # FIXME: (self.get_allocation().height / 300) * 72000 self.time_label.set_markup( "<span size='%i' color='dimgray'><b>%s</b></span>" % (size, text)) clock_format = SystemSettings.get_clock_format() if clock_format != self.clock_format or \ sunrise != self.sunrise or sunset != self.sunset: self.sunrise = sunrise self.sunset = sunset if clock_format == "12h": sunrise_str = sunrise.strftime("%I:%M %p") sunset_str = sunset.strftime("%I:%M %p") else: sunrise_str = sunrise.strftime("%H:%M") sunset_str = sunset.strftime("%H:%M") if sunrise_str.startswith("0"): sunrise_str = sunrise_str[1:] if sunset_str.startswith("0"): sunset_str = sunset_str[1:] self.sunrise_time_label.set_markup( "<span size ='large'>%s</span>" % sunrise_str) self.sunset_time_label.set_markup( "<span size ='large'>%s</span>" % sunset_str) self.clock_format = clock_format
def get_time_as_string(self): if SystemSettings.get_clock_format() == "12h": return self.time.strftime("%I:%M %p") else: return self.time.strftime("%H:%M")
def __init__(self, parent, alarm=None): if alarm: Gtk.Dialog.__init__(self, _("Edit Alarm"), parent) else: Gtk.Dialog.__init__(self, _("New Alarm"), parent) self.set_border_width(6) self.parent = parent self.set_transient_for(parent) self.set_modal(True) self.day_buttons = [] content_area = self.get_content_area() self.add_buttons(Gtk.STOCK_CANCEL, 0, Gtk.STOCK_SAVE, 1) self.cf = SystemSettings.get_clock_format() grid = Gtk.Grid() grid.set_row_spacing(9) grid.set_column_spacing(6) grid.set_border_width(6) content_area.pack_start(grid, True, True, 0) if alarm: if self.cf == "12h": h = int(alarm.time.strftime("%I")) p = alarm.time.strftime("%p") else: h = alarm.hour p = None m = alarm.minute name = alarm.name days = alarm.days else: t = time.localtime() h = t.tm_hour m = t.tm_min p = time.strftime("%p", t) name = _("New Alarm") days = [] # Translators: "Time" in this context is the time an alarm # is set to go off (days, hours, minutes etc.) label = Gtk.Label(_("Time")) label.set_alignment(1.0, 0.5) grid.attach(label, 0, 0, 1, 1) self.hourselect = Gtk.SpinButton() self.hourselect.set_numeric(True) self.hourselect.set_increments(1.0, 1.0) self.hourselect.set_wrap(True) grid.attach(self.hourselect, 1, 0, 1, 1) label = Gtk.Label(": ") label.set_alignment(0.5, 0.5) grid.attach(label, 2, 0, 1, 1) self.minuteselect = Gtk.SpinButton() self.minuteselect.set_numeric(True) self.minuteselect.set_increments(1.0, 1.0) self.minuteselect.set_wrap(True) self.minuteselect.connect("output", self._show_leading_zeros) self.minuteselect.set_range(0.0, 59.0) self.minuteselect.set_value(m) grid.attach(self.minuteselect, 3, 0, 1, 1) if self.cf == "12h": self.ampm = Gtk.ComboBoxText() self.ampm.append_text("AM") self.ampm.append_text("PM") if p == "PM": h = h - 12 self.ampm.set_active(1) else: self.ampm.set_active(0) grid.attach(self.ampm, 4, 0, 1, 1) self.hourselect.set_range(1.0, 12.0) self.hourselect.set_value(h) gridcols = 5 else: self.hourselect.set_range(0.0, 23.0) self.hourselect.set_value(h) gridcols = 4 label = Gtk.Label(_("Name")) label.set_alignment(1.0, 0.5) grid.attach(label, 0, 1, 1, 1) self.entry = Gtk.Entry() self.entry.set_text(name) self.entry.set_editable(True) grid.attach(self.entry, 1, 1, gridcols - 1, 1) label = Gtk.Label(_("Repeat Every")) label.set_alignment(1.0, 0.5) grid.attach(label, 0, 2, 1, 1) # create a box and put repeat days in it box = Gtk.Box(True, 0) box.get_style_context().add_class("linked") for i in range(7): day_num = (LocalizedWeekdays.first_weekday() + i) % 7 day_name = LocalizedWeekdays.get_abbr(day_num) btn = Gtk.ToggleButton(label=day_name) btn.data = day_num if btn.data in days: btn.set_active(True) box.pack_start(btn, True, True, 0) self.day_buttons.append(btn) grid.attach(box, 1, 2, gridcols - 1, 1)