def show_scratchpad(qtile): ''' Cycle through any current scratchpad windows on the current screen. ''' scratchpad = qtile.groupMap.get('scratchpad') if scratchpad is None: notify(( 'You are attempting to use scratchpads without a `scratchpad`' ' group being defined! Define one in your config and restart' ' qtile to enable scratchpads.' )) for w in list(qtile.currentGroup.windows): if not hasattr(w, 'on_scratchpad'): # Ensure that we don't get an attribute error w.on_scratchpad = False if w.on_scratchpad: w.togroup('scratchpad') if scratchpad.focusHistory: # We have at least one scratchpad window to display so show that last # one to be focused. This will cause us to cycle through all scratchpad # windows in reverse order. last_window = scratchpad.focusHistory[-1] last_window.togroup(qtile.currentGroup.name)
def form_valid(self, form): """If the form is valid, save the associated models""" form.instance.author = self.request.user if form.cleaned_data['bbsitter']: subject = "%s vous propose de réaliser un babysitting sur bbsitting sharing by Echos Kids"%self.request.user.get_full_name() notify(self.request, form.instance, subject, 'bbsitter_invite', form.cleaned_data['bbsitter']) return super(CreateView, self).form_valid(form)
def new_message(self, conversation): if not settings.get_notify_on_messagerecieve() or self.skype.skype_presence == Skype4Py.cusDoNotDisturb: return #conversation.skypereturn.Chat.Type == Skype4Py.chatTypeMultiChat and conversation.display_name = conversation.skypereturn.Chat.Topic or conversation.display_name name = conversation.skypereturn.Sender.DisplayName or conversation.skypereturn.Sender.FullName or conversation.skypereturn.Sender.Handle if len(conversation.skypereturn.Chat.Members) > 2: group_chat_title = unicode(name + " ► " + conversation.display_name) else: group_chat_title = unicode(conversation.display_name) icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(conversation.skypereturn.Sender.Handle) if avatar.filename: icon = avatar.filename else: icon = "/usr/share/skype-wrapper/icons/skype-wrapper-48.svg" if helpers.haveUnity(): unitylauncher.count(len(self.indicators) + self.skype.incomingfilecount) unitylauncher.createUnreadMessageQuickList(self.skype.unread_conversations, self.show_conversation_quicklist) unitylauncher.redrawQuicklist() unitylauncher.count(len(self.indicators) + self.skype.incomingfilecount) helpers.notify(group_chat_title, conversation.skypereturn.Body, icon, group_chat_title, False, False, conversation.skypereturn.Chat.Topic)
def to_scratchpad(window): ''' Mark the current window as a scratchpad. This resises it, sets it to floating and moves it to the hidden `scratchpad` group. ''' try: window.togroup('scratchpad') window.on_scratchpad = True except Exception as e: # No `scratchpad` group notify(( 'You are attempting to use scratchpads without a `scratchpad`' ' group being defined! Define one in your config and restart' ' qtile to enable scratchpads.' )) window.floating = True screen = window.group.screen window.tweak_float( x=int(screen.width / 10), y=int(screen.height / 10), w=int(screen.width / 1.2), h=int(screen.height / 1.2), )
def check_stock_changes(): products = get_product_list() if len(products) > 0: driver = webdriver.Chrome() for product in products: try: if bool(product["skip"]) == False: send_email = False driver.get(product["url"]) sleep(2) found = driver.find_elements_by_css_selector( product["lookfor"]) if len(found) > 0 and bool(product["notifyiffound"]) == True: send_email = True elif len(found) == 0 and bool( product["notifyiffound"]) == False: send_email = True else: print('Out of stock') if send_email and helpers.must_notify(product["url"]): helpers.notify(product["url"]) except Exception as e: print(e) driver.close() driver.quit()
def request_gps_permission(self): '''Get the user's permission to access gps''' if platform == "android": request_permissions([Permission.ACCESS_FINE_LOCATION], callback=self.locate_with_gps) else: notify(title="GPS Needed", message="This device does not have a gps")
def get(self, request, pk, booking_pk): booking = Booking.objects.get(pk=booking_pk) # check the bbsitting id and author if booking.bbsitting.pk != int(pk) or booking.bbsitting.author != request.user: raise Http404 booking.validated = True booking.save() notify(request, booking, "book_validated") return super(ValidateView, self).get(request, booking=booking)
def set_qibla_direction(self): '''Set the qibla direction from current position''' if self.app.location_data_present(): self.location_text = self.app.settings["location"] qibla_direction = self.app.prayer_times.get_qibla() self.needle_angle = (360 - qibla_direction) % 360 self.title = f"Qibla ({self.needle_angle}°)" else: notify(title="Location Needed", message="Location is needed to get qibla direction")
def locate_with_gps(self, perm_names, perms): '''Select a location with gps''' if perms[0]: gps.start(1000, 1) self.timeout_event = Clock.schedule_once( lambda _: self.gps_timeout(), 60) self.loading_popup.open() else: notify(title="Location Permission", message="Permission is needed to get location")
def CallStatus(self, call, status): global active_player, player_paused, volume_level if status == "RINGING": if settings.get_control_music_player() and active_player == "unknown" and player_paused == False: controlMusicPlayer() if settings.get_restore_volume(): SaveRestore_Volume() self.call_ringing = self.call_ringing + 1 self.calls[call.PartnerHandle] = call else: self.call_ringing = self.call_ringing - 1 #if status == "INPROGRESS":LOCALHOLD if (status == "MISSED" or status == "FINISHED" or status == "REFUSED" or status == "CANCELLED") and call.PartnerHandle in self.calls: if settings.get_restore_volume(): SaveRestore_Volume() volume_level = "unknown" if settings.get_control_music_player(): controlMusicPlayer() active_player = "unknown" player_paused = False del self.calls[call.PartnerHandle] if helper.isUnityRunning(): unitylauncher.createCallsQuickList(self.calls, self.cb_call_action) unitylauncher.redrawQuicklist() # wiggle the launcher if self.call_ringing > 0 and not self.calls_ringing_started: if helpers.isUnityRunning(): unitylauncher.urgent() GObject.timeout_add(1000, self.calls_ringing) icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(call.PartnerHandle) if avatar.filename: icon = avatar.filename else: icon = wrapperPath + "/icons/skype-wrapper-48.svg" partner = call.PartnerDisplayName or call.PartnerHandle notification = "" if status == "RINGING" and (call.Type == "INCOMING_P2P" or call.Type == "INCOMING_PSTN"): notification = "* Incoming call"; if status == "INPROGRESS": notification = "* Call started"; if status == "MISSED": notification = "* Missed call"; if status == "FINISHED": notification = "* Call ended"; if status == "REMOTEHOLD": notification = "* Call put on hold"; if notification: helpers.notify(partner, notification, icon, "call://"+call.PartnerHandle, True, True)
def CallStatus(self, call, status): global active_player, player_paused, volume_level if status == "RINGING": if settings.get_control_music_player() and active_player == "unknown" and player_paused == False: controlMusicPlayer() if settings.get_restore_volume(): SaveRestore_Volume() self.call_ringing = self.call_ringing + 1 self.calls[call.PartnerHandle] = call else: self.call_ringing = self.call_ringing - 1 #if status == "INPROGRESS":LOCALHOLD if (status == "MISSED" or status == "FINISHED" or status == "REFUSED" or status == "CANCELLED") and call.PartnerHandle in self.calls: if settings.get_restore_volume(): SaveRestore_Volume() volume_level = "unknown" if settings.get_control_music_player(): controlMusicPlayer() active_player = "unknown" player_paused = False del self.calls[call.PartnerHandle] unitylauncher.createCallsQuickList(self.calls, self.cb_call_action) unitylauncher.redrawQuicklist() # wiggle the launcher if self.call_ringing > 0 and not self.calls_ringing_started: unitylauncher.urgent() GObject.timeout_add(1000, self.calls_ringing) icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(call.PartnerHandle) if avatar.filename: icon = avatar.filename else: icon = "/usr/share/skype-wrapper/icons/skype-wrapper-48.svg" partner = call.PartnerDisplayName or call.PartnerHandle notification = "" if status == "RINGING" and (call.Type == "INCOMING_P2P" or call.Type == "INCOMING_PSTN"): notification = "* Incoming call"; if status == "INPROGRESS": notification = "* Call started"; if status == "MISSED": notification = "* Missed call"; if status == "FINISHED": notification = "* Call ended"; if status == "REMOTEHOLD": notification = "* Call put on hold"; if notification: helpers.notify(partner, notification, icon, "call://"+call.PartnerHandle, True, True)
def create_prayers_data(self): '''Create the prayer times data and schedule the upgrade event''' if self.app.location_data_present(): self.update_prayer_times() self.update_clock_event = Clock.schedule_interval( lambda _: self.update_prayer_labels(), 30) self.location.text = self.app.settings["location"] else: notify(title="Location Needed", message="Location is needed to calculate the prayer times")
def get(self, request, pk): bbsitting = BBSitting.objects.get(pk=pk) already_requested = False if bbsitting.author==request.user: return HttpResponseForbidden() try: booking = Booking.objects.create(bbsitting=bbsitting, parent=request.user) subject = "Demande de participation au bbsitting" notify(request, booking, subject, 'book_request', bbsitting.author.email) except IntegrityError: already_requested = True return super(BookView, self).get(request, recipient=bbsitting.author.get_full_name(), already_requested=already_requested)
def get(self, request, pk): bbsitting = BBSitting.objects.get(pk=pk) already_requested = False if bbsitting.author == request.user: HttpResponseForbidden try: booking = Booking.objects.create(bbsitting=bbsitting, parent=request.user) notify(request, booking, "book_request", bbsitting.author.email) except IntegrityError: already_requested = True return super(BookView, self).get( request, recipient=bbsitting.author.get_full_name(), already_requested=already_requested )
def user_online_status(self, user, online_text): name = user.DisplayName or user.FullName or user.Handle log("User "+name+" "+online_text, INFO) if not settings.get_notify_on_useronlinestatuschange() or self.skype.skype_presence == Skype4Py.cusDoNotDisturb or user.Handle == 'echo123': return icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(user.Handle) if avatar.filename: icon = avatar.filename else: icon = "/usr/share/skype-wrapper/icons/skype-wrapper-48.svg" helpers.notify(name, online_text, icon, "online://"+user.Handle, False, False)
def file_transfer_event(self, transfer, text): if self.skype.skype_presence == Skype4Py.cusDoNotDisturb: return if str(transfer.status) == 'INCOMING' and not settings.get_notify_on_incoming_filetransfer(): return if str(transfer.status) == 'OUTGOING' and not settings.get_notify_on_outgoing_filetransfer(): return icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(transfer.partner_username) if avatar.filename: icon = avatar.filename else: icon = "/usr/share/skype-wrapper/icons/skype-wrapper-48.svg" helpers.notify("File Transfer", text, icon, "filetransfer"+transfer.partner_username, True, True)
def create_graph(self): '''Create the popup with the graph and open it''' # Validate that the graph date data is valid and present if (self.end_date.text and self.start_date.text) and \ (self.end_date.date > self.start_date.date): popup = GraphPopup() popup.create_graph(self.graph, self.get_prayer_data()) popup.open() else: if not self.start_date.text and not self.end_date.text: message = "No value for start date and end date" elif not self.start_date.text: message = "No value for start date" elif not self.end_date.text: message = "No value for end date" elif self.end_date.date <= self.start_date.date: message = "End date is not greater than the start date" notify(title="Invalid Graph Data", message=message)
def change_location(self): '''Change the location with the entered value of lattitude and longitude''' try: lat, lon = float(self.lat.text), float(self.lon.text) self.location_popup.loading_popup.open() thread = threading.Thread(target=self.get_location, args=(lat, lon)) thread.start() except ValueError: title = "Invalid Data" if not self.lat.text and not self.lon.text: message = "No values are entered" elif not self.lat.text: message = "Latitude has no value" elif not self.lon.text: message = "Longitude has no value" else: message = "One or more values cannot be converted to decimals" notify(title=title, message=message)
def CallStatus(self, call, status): if status == "RINGING": self.call_ringing = self.call_ringing + 1 self.calls[call.PartnerHandle] = call else: self.call_ringing = self.call_ringing - 1 #if status == "INPROGRESS":LOCALHOLD if (status == "MISSED" or status == "FINISHED") and call.PartnerHandle in self.calls: del self.calls[call.PartnerHandle] unitylauncher.createCallsQuickList(self.calls, self.cb_call_action) unitylauncher.redrawQuicklist() # wiggle the launcher if self.call_ringing > 0 and not self.calls_ringing_started: unitylauncher.urgent() GObject.timeout_add(1000, self.calls_ringing) icon = "" if settings.get_display_notification_avatars(): avatar = SkypeAvatar(call.PartnerHandle) if avatar.filename: icon = avatar.filename else: icon = "/usr/share/skype-wrapper/icons/skype-wrapper-48.svg" partner = call.PartnerDisplayName or call.PartnerHandle notification = "" if status == "RINGING": notification = "* Incoming call"; if status == "INPROGRESS": notification = "* Call started"; if status == "MISSED": notification = "* Missed call"; if status == "FINISHED": notification = "* Call ended"; if status == "REMOTEHOLD": notification = "* Call put on hold"; if notification: helpers.notify(partner, notification, icon, "call://"+call.PartnerHandle, True, True)
def button(): records = db.execute('select symbol, name, sum(shares) from records WHERE id_user = :id GROUP by symbol HAVING sum(shares) != 0',id=session["user_id"]) cash = db.execute("SELECT cash FROM users WHERE id = :id", id=session["user_id"]) user = db.execute("SELECT id, username, email FROM users WHERE id = :id", id=session["user_id"]) total = 0 for item in records: total = total + lookup(item['symbol'])['price'] * item['sum(shares)'] total = total + cash[0]['cash'] db.execute("INSERT INTO cash_out (id_user, username, time_stamp, total_collected) VALUES (:id_user, :username, :time_stamp, :total_collected)", id_user=user[0]['id'], username=user[0]['username'], time_stamp=datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"), total_collected=total) db.execute('DELETE FROM records WHERE id_user = :id_user', id_user=session["user_id"]) db.execute('DELETE FROM holdings WHERE id_user = :id_user', id_user=session["user_id"]) db.execute('UPDATE users SET cash = 0 WHERE id = :id;', id=session["user_id"]) notify(user[0]['username'],user[0]['email'],usd(total)) return redirect(url_for('cash_out'))
def display_notification(self, prayer): '''Display the prayer toast notification''' notify(title=prayer, message=self.prayer_times[prayer.lower()], timeout=2)
def form_valid(self, form): """If the form is valid, save the associated models""" form.instance.author = self.request.user notify(self.request, form.instance, "bbsitter_invite", form.cleaned_data["bbsitter"]) return super(CreateView, self).form_valid(form)
def gps_timeout(self): '''Cancel the gps location callback and send a toast notification informing the user''' gps.stop() notify(title="GPS Timeout", message="Check your internet connection") self.loading_popup.dismiss()