def get_notifications(self, request): if not self.check_demo_optin(request): return yield Notification(text="Your IP is %s" % request.META.get("REMOTE_ADDR")) yield Notification(title="Dice", text="Your lucky number is %d" % random.randint(1, 43), kind="success") yield Notification(title="Stock Alert", text="Items X, Y, Z are running low", kind="warning") yield Notification(title="Outstanding Orders", text="10 orders have not been touched in 7 days", kind="danger")
def get_notifications(self, request): try: engines["jinja2"] except InvalidTemplateEngineError: text = """Simple Order Notifications can't send order notifications because it can't find a Jinja2 template engine. Name your Jinja2 template engine "jinja2" to resolve this.""" yield Notification(text=text)
def openfile(self): files = [('Text Document', '*.txt'), ('Word Document', '.doc')] filename = tkinter.filedialog.askopenfilename(parent=self.__root, filetypes=files, defaultextension=files) if filename is not None and filename != '': with open(filename, encoding='utf-8', mode='r') as file: data = file.read() if self.__handle_data.get_mute() == 'True': Notification('You can not speak here').start() return self.__txt.config(state=NORMAL) try: self.__txt.insert(END, data + '\n') except: self.__txt.insert( END, "Your device doesn't support this type of message" + '\n') self.__txt.yview(END) self.__txt.config(state=DISABLED) self.__client_socket.write( (self.__client_name + '01' + data).encode()) self.__my_cursor.execute( "SELECT chat FROM users WHERE name=%s ", (self.__client_name[1:], )) msg = self.__my_cursor.fetchone() if msg[0] is not None: my_chat = msg[0] message = my_chat + DATE + ' ' + str( time.strftime("%H:%M") ) + ' ' + self.__client_name[1:] + ': ' + data + '\n' message = emoji.demojize(message) self.__my_cursor.execute("UPDATE users SET chat = %s", (message, ))
def CheckAvalibility(self): start_date = self.le_start_date.text() end_date = self.le_end_date.text() start_time_1 = self.le_start_time1.text() start_time_2 = self.le_start_time2.text() end_time_1 = self.le_end_time1.text() end_time_2 = self.le_end_time2.text() if start_date != "" and end_date != "" and start_time_1 != "" and start_time_2 != "" and end_time_1 != "" and end_time_2 != "": messages = [] check_result = CheckTimeslots(start_time_1, end_time_1, start_time_2, end_time_2, self.select_job_combo.currentText()) if check_result != -1: messages.append(check_result) check_result = CheckAvailability(start_date, end_date, start_time_1, end_time_1, True, self.record_id) if check_result != -1: messages.append(check_result + " In StartTime1 + EndTime1") elif start_time_2 != "N/A" and end_time_2 != "N/A": check_result = CheckAvailability(start_date, end_date, start_time_2, end_time_2, True, self.record_id) if check_result != -1: messages.append(check_result + " In StartTime2 + EndTime2") if len(messages) != 0: message = "" for each in messages: message = message + each + ";" else: message = "No Issues with the current time slots" else: message = "Please fill in all times and dates" notification = Notification(self, message) notification.setModal(True) notification.show() notification.raise_()
def get_notifications(self, request): if is_telemetry_enabled() and is_in_grace_period() and not is_opt_out(): yield Notification( _("Statistics will be periodically sent to E-Commerce.com after 24 hours. Click here for more information."), title=_("Telemetry"), kind="info", url="E-Commerce_admin:telemetry" )
async def requestReceived(websocket, session, request): global notificationsSubscribers #Websockets endpoints if request['operation'] == 'get': #get endpoint notifications = Notification.getNotifications(session) response = convertToJson({'operation' : 'get', 'table' : 'Notifications', 'data' : notifications}) await websocket.send(response) elif request['operation'] == 'subscribe': #subscription endpoint notifications = Notification.getNotifications(session) response = convertToJson({'operation' : 'get', 'table' : 'Notifications', 'data' : notifications}) notificationsSubscribers.add(websocket) await websocket.send(response) elif request['operation'] == 'add': #add endpoint if checkArguments(request, ['title', 'message']) == False: print('Not all parameters were provided for ADD in Notifications') await websocket.send(convertToJson({'error' : 'Invalid request'})) return notification = dict_as_obj(request['data'], Notification.Notification(), ['notificationId', 'creationTime']) notification = Notification.addNotification(session, notification) response = convertToJson({'operation' : 'add', 'table' : 'Notifications', 'data' : notification}) notificationsSubscribers = set(filter(removeClosedConnection, notificationsSubscribers)) for subscriber in notificationsSubscribers: await subscriber.send(response) elif request['operation'] == 'update': #update endpoint if checkArguments(request, ['notificationId']) == False: print('Not all parameters were provided for UPDATE in Notifications') await websocket.send(convertToJson({'error' : 'Invalid request'})) return data = request['data'] notification = Notification.getNotificationsByNotificationId(session, data['notificationId'])[0] notification = dict_as_obj(data, notification) notification = Notification.updateNotification(session, notification) response = convertToJson({'operation' : 'update', 'table' : 'Notifications', 'data' : notification}) notificationsSubscribers = set(filter(removeClosedConnection, notificationsSubscribers)) for subscriber in notificationsSubscribers: await subscriber.send(response) elif request['operation'] == 'delete': #delete endpoint if checkArguments(request, ['notificationId']) == False: print('Not all parameters were provided for DELETE in Notifications') await websocket.send(convertToJson({'error' : 'Invalid request'})) return notification = Notification.deleteNotification(session, request['data']['notificationId']) response = convertToJson({'operation' : 'delete', 'table' : 'Notifications', 'data' : notification}) notificationsSubscribers = set(filter(removeClosedConnection, notificationsSubscribers)) for subscriber in notificationsSubscribers: await subscriber.send(response)
def test_notification_reverse_url(): try: set_urlconf("E-Commerce_tests.notify.notification_test_urls") n = Notification(shop=factories.get_default_shop()) kwargs = dict(viewname="test", kwargs={"arg": "yes"}) # kwargs within kwargs, oh my n.set_reverse_url(**kwargs) n.save() with pytest.raises(ValueError): n.set_reverse_url() assert n.url == reverse(**kwargs) finally: set_urlconf(None)
def entry_font_color(self): try: color = ask_string('font color', 'write a color') if color == 'available colors': Available(self.__root) return if color == 'default': color = '#FB2412' self.__e1.configure(fg=color, insertbackground=color) self.add_color_db(color, 'input_font_color') except: Notification("This color doesn't exist").start()
def root_background_color(self): try: color = ask_string('background color', 'write a color') if color == 'available colors': Available(self.__root) return if color == 'default': color = '#025E73' self.__root.configure(background=color) self.add_color_db(color, 'root_background_color') except: Notification("This color doesn't exist").start()
def get_notifications(self, request): shop = request.shop old_open_orders = Order.objects.filter( shop=shop, status__role=OrderStatusRole.INITIAL, order_date__lt=now() - timedelta(days=4) ).count() if old_open_orders: yield Notification( title=_("Outstanding Orders"), text=_("%d outstanding orders") % old_open_orders, kind="danger" )
def DeleteRecord(came_from, current_record_id, table_name): are_you_sure = ConfirmationWindow(came_from, "Are you sure you wish to delete this record? This action cannot be undone.") are_you_sure.setModal(True) are_you_sure.show() are_you_sure.raise_() decision = are_you_sure.exec_() #confirm deletion window if decision == 1: if current_record_id != -1 and current_record_id != "There Are No Records To Display": database.DeleteRecord(table_name, current_record_id) came_from.DisplayAll() else: #notify if record not selected notification = Notification(came_from, "Please select a record") notification.setModal(True) notification.show() notification.raise_()
def get_notifications(self, request): try: engine = engines["jinja2"] except KeyError: engine = None if engine and isinstance(engine, Jinja2): # The engine is what we expect... if isinstance(engine.env, XthemeEnvironment): # ... and it's capable of loading themes... if not get_current_theme(request.shop): # ... but there's no theme active?! # Panic! yield Notification( text=_("No theme is active. Click here to activate one."), title=_("Theming"), url="E-Commerce_admin:xtheme.config" )
def get_notifications(self, request): """ Injects a message to the user and also a notification """ # multi-shop not supported if not E-CommerceSettings.get_setting("E-Commerce_ENABLE_MULTIPLE_SHOPS"): from E-Commerce.admin.shop_provider import get_shop shop = get_shop(request) if sample_manager.has_installed_samples(shop): messages.warning(request, _('There is sample data installed. ' 'Access "Settings > Sample Data" for more information.')) yield Notification( _("There is sample data installed. Click here to consolidate or delete them."), title=_("Sample Data"), kind="warning", url="E-Commerce_admin:sample_data" )
def ConfirmChoice(self): self.choice = self.database_combo.currentText() connection = sqlite3.connect("Pet_Service.db") connection.commit() connection.close() #close the database while swapping in old copy shutil.copyfile( os.path.join(os.getcwd() + "\DatabaseBackups", self.choice), os.getcwd() + "\Pet_Service.db" ) #replace .db file that is used with backup (no need to rename) notification = Notification( self, "Restore Complete") #tell user restore has been completed notification.show() notification.raise_() self.came_from.show() self.close()
def get_notifications(self, request): shop = get_shop(request) notif_qs = NotificationModel.objects.unread_for_user(request.user).filter(shop=shop).order_by("-id")[:15] for notif in notif_qs: if notif.priority == Priority.HIGH: kind = "warning" elif notif.priority == Priority.CRITICAL: kind = "danger" else: kind = "info" yield Notification( text=notif.message, url=notif.url, kind=kind, dismissal_url=reverse("E-Commerce_admin:notify.mark-read", kwargs={"pk": notif.pk}), datetime=notif.created_on )
def RestoreDatabase(self): #restore pervious backup are_you_sure = ConfirmationWindow( self, "Are you sure you wish to restore an earlier version of the database? You should make a backup before restoring to be safe." ) are_you_sure.setModal(True) are_you_sure.show() are_you_sure.raise_() self.decision = are_you_sure.exec_() if self.decision == 1: if not (os.path.isdir(os.getcwd() + "\DatabaseBackups") ): #if there isn't the backups dir notification = Notification(self, "No backups have been made") notification.setModal(True) notification.show() notification.raise_() else: filenames = os.listdir( os.getcwd() + "\DatabaseBackups") #get list of all backups select_database = SelectDatabase( self, filenames) #send to restore window select_database.show() select_database.raise_() self.hide()
def get_notifications(self, request): return [Notification(text="OK")]
def processMessage(self, msg): if msg.messageType() == SUBSCRIPTION_STARTED: # print("Route Subscription Started...") return eventStatus = msg.getElementAsInteger("EVENT_STATUS") if eventStatus==1: # Heartbeat # print("Route >> Heartbeat") pass elif eventStatus==4: # Initial paint seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") routeId = msg.getElementAsInteger("EMSX_ROUTE_ID") # print("Route >> Event(4) >> SeqNo: " + str(seqNo) + "\tRouteId: " + str(routeId)) r = self.getBySequenceNoAndId(seqNo, routeId) if r is None: r = self.createRoute(seqNo, routeId) r.fields.populateFields(msg, False) r.notify(Notification(Notification.NotificationCategory.ROUTE, Notification.NotificationType.INITIALPAINT, r, r.fields.getFieldChanges())) elif eventStatus==6: # New order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") routeId = msg.getElementAsInteger("EMSX_ROUTE_ID") # print("Route >> Event(4) >> SeqNo: " + str(seqNo) + "\tRouteId: " + str(routeId)) r = self.getBySequenceNoAndId(seqNo, routeId) if r is None: r = self.createRoute(seqNo, routeId) r.fields.populateFields(msg, False) r.notify(Notification(Notification.NotificationCategory.ROUTE, Notification.NotificationType.NEW, r, r.fields.getFieldChanges())) elif eventStatus==7: # Update order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") routeId = msg.getElementAsInteger("EMSX_ROUTE_ID") # print("Route >> Event(4) >> SeqNo: " + str(seqNo) + "\tRouteId: " + str(routeId)) r = self.getBySequenceNoAndId(seqNo, routeId) if r is None: # print("WARNING >> update received for unknown order") r = self.createRoute(seqNo, routeId) r.fields.populateFields(msg, True) r.notify(Notification(Notification.NotificationCategory.ROUTE, Notification.NotificationType.UPDATE, r, r.fields.getFieldChanges())) elif eventStatus==8: # Delete/Expired order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") routeId = msg.getElementAsInteger("EMSX_ROUTE_ID") # print("Route >> Event(4) >> SeqNo: " + str(seqNo) + "\tRouteId: " + str(routeId)) r = self.getBySequenceNoAndId(seqNo, routeId) if r is None: r = self.createRoute(seqNo, routeId) r.fields.populateFields(msg, False) r.fields.field("EMSX_STATUS").setValue("DELETED") r.notify(Notification(Notification.NotificationCategory.ROUTE, Notification.NotificationType.DELETE, r, r.fields.getFieldChanges())) elif eventStatus==11: # End of init paint # print("End of ROUTE INIT_PAINT") self.initialized=True
def post(self): requestedArgs = getArguments(['title', 'message']) args = requestedArgs.parse_args() notification = dict_as_obj(args, Notification.Notification()) return Notification.addNotification(self.session, notification)
def test_urlless_notification(): assert not Notification().url
from Notification import * # url = 'https://coinmarketcap.com/currencies/ethereum/' url = input( 'ENTER URL ADDRESS OF COIN:' ) # paste url of an crypto coin you choosed from coinmarket.com/currencies # val = "0.0232850" val = input( 'ENTER YOUR LEVEL:') # input your threshold level for your specific coin e_mail = '*****@*****.**' # give here your e mails. receiver = '*****@*****.**' # sender and receiver e mails can be same Coin = Notification(url, val, e_mail, receiver) initial = Coin.init_val val = Coin.val # following code will do: # considers your level you specified and warn you when the real coin value reaches your level. # and send you a notification e mail. if val > initial: print('Notify Up Working') Coin.notify_up() print() elif val < initial: print('Notify Down Working') Coin.notify_down()
import sports From pynotifier import Notification matchinfo = sports.get_sport("cricket") Notification(title= "LIVE SCORE", description= str(matchinfo), duration= 40).send()
from datetime import datetime import Notification import gmailReader import json notification = Notification.Notification() with open("query.json", 'r') as file: parameters = json.loads(file.read()) searchFor = parameters["search_for_word"] received_from_email = parameters['received_from'] our_email = parameters['your_email'] days_ago = parameters['days_ago'] results = gmailReader.search_messages(gmailReader.service, searchFor) # for each email matched, read it for msg in results: # sender=True if you are the sender # msg is dict with keys: From, To, Subject, text sender, msg = gmailReader.read_message(gmailReader.service, msg, our_email) if sender: #Don't want notifications upon sending, only receiving continue msgDate = gmailReader.convertToDateTime(msg['Date']) # want to only check the emails from past 24 hours (new emails) dayDiff = abs((datetime.now() - msgDate).days) # no LinkedIn emails (hate it!!!) if (dayDiff < days_ago and "LinkedIn" not in msg['Subject'] and "linkedin" not in msg['From'] and received_from_email in msg['From']): # give notification as: # <Subject>
def processMessage(self, msg): if msg.messageType() == SUBSCRIPTION_STARTED: # print("Order Subscription Started...") return eventStatus = msg.getElementAsInteger("EVENT_STATUS") if eventStatus == 1: # Heartbeat # print("Order >> Heartbeat") pass elif eventStatus == 4: # Initial paint seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") # print("Order >> Event(4) >> SeqNo: " + str(seqNo)) o = self.getBySequenceNo(seqNo) if o is None: o = self.createOrder(seqNo) o.fields.populateFields(msg, False) o.notify( Notification(Notification.NotificationCategory.ORDER, Notification.NotificationType.INITIALPAINT, o, o.fields.getFieldChanges())) elif eventStatus == 6: # New order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") # print("Order >> Event(6) >> SeqNo: " + str(seqNo)) o = self.getBySequenceNo(seqNo) if o is None: o = self.createOrder(seqNo) o.fields.populateFields(msg, False) o.notify( Notification(Notification.NotificationCategory.ORDER, Notification.NotificationType.NEW, o, o.fields.getFieldChanges())) elif eventStatus == 7: # Update order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") # print("Order >> Event(7) >> SeqNo: " + str(seqNo)) o = self.getBySequenceNo(seqNo) if o is None: # print("WARNING >> update received for unknown order") o = self.createOrder(seqNo) o.fields.populateFields(msg, True) o.notify( Notification(Notification.NotificationCategory.ORDER, Notification.NotificationType.UPDATE, o, o.fields.getFieldChanges())) elif eventStatus == 8: # Delete/Expired order seqNo = msg.getElementAsInteger("EMSX_SEQUENCE") # print("Order >> Event(8) >> SeqNo: " + str(seqNo)) o = self.getBySequenceNo(seqNo) if o is None: o = self.createOrder(seqNo) o.fields.populateFields(msg, False) o.fields.field("EMSX_STATUS").setValue("DELETED") o.notify( Notification(Notification.NotificationCategory.ORDER, Notification.NotificationType.DELETE, o, o.fields.getFieldChanges())) elif eventStatus == 11: # End of init paint # print("End of ORDER INIT_PAINT") self.initialized = True
def shuffle(self): shuffle(self.deck) for l in self.listeners: l.notify(Notification("shuffle-deck"))