def __init__(self, parent=None): super().__init__(parent) pom = send.Send() self.send(pom.send('c')) self.interfejs()
def sending_msg(self, widget, data): self.pbar.show() startiter, enditer = self.textbuffer1.get_bounds() msg = self.textbuffer1.get_text(startiter, enditer, include_hidden_chars=True) print msg # get receiver's number from combobox tostr = self.entry.get_text() print tostr if tostr == '': print 'Enter Receiver Number!' gtk.main_quit() ar = tostr.split(':') if ar[0] == tostr: self.to_no = ar[0] else: a = ar[1] self.to_no = a[1:-1] # Frame a dict to send to crafting self.message = {"to_number": self.to_no, "message": msg} sobj = send.Send('msgapp', self.message)
def run(): lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, bandwidth=1, preamble=10, sf=12, tx_power=20, coding_rate=1) #définition dun truc s = socket.socket( socket.AF_LORA, socket.SOCK_RAW) #définition d'un socket réseaux de type lora print("fc run") if machineA == machine.unique_id(): import send sendACKvrf("tla?", "jesuisla") print("MES parametre:") print("sf=" + str(sf) + " bandwidth=" + str(bandwidth) + " buffersize=" + str(buffersize) + " coding_rate=" + str(coding) + " preamble=" + str(preamble) + " tx_power=" + str(power)) print("éméteur lancement transfer") try: send.Send(bandwidth, sf, buffersize, preamble, "img.py", power, coding, timeout, maxretry) # send.Send.MABITE() except SystemExit as e: print("exeption " + str(e)) if machineB == machine.unique_id(): import receptionLora while s.recv(buffersize) != b'tla?': pass #critique ? s.send("jesuisla") s.send("jesuisla") print("message envoiller !") print("MES parametre:") print("sf=" + str(sf) + " bandwidth=" + str(bandwidth) + " buffersize=" + str(buffersize) + " coding_rate=" + str(coding) + " preamble=" + str(preamble) + " tx_power=" + str(power)) print("éméteur lancement transfer") try: #on l'ance le programe de reception receptionLora.Rcv.__init__(bandwidth, sf, buffersize, preamble, "azer.txt", power, coding, timeout, maxretry) #si on a une exeption exit (fait par trop de retry ) except SystemExit as e: #on abolis d'exeption print("exeption " + str(e))
def api_main(): try: my_json =request.get_json() obj_receive = receive.Receive(my_json) if obj_receive.stage==3: angle11 = (obj_receive.word, '', [], 1) angle_send11 = send.Send(3, word=angle11[0], trans=angle11[1], sentence_list=angle11[2], length=angle11[3]) angle_zhazha11 = dict(angle_send11) angle_j11 = json.dumps(obj=angle_zhazha11) return angle_j11 obj_check = check.Check(receive=obj_receive) print(4) result = obj_check.begin_check() angle = (obj_receive.word, '', [['', '', '', '']], 1) if result != "safe": '''应为result !="safe: return jsonify(result)方便测试其他数据''' angle_send = send.Send( 2,angle[0],angle[1],angle[2],angle[3]) angle_zhazha = dict(angle_send) angle_j = json.dumps(obj=angle_zhazha) return angle_j else: obj_db_manager = db_manager.Db_Manager(receive=obj_receive) obj_get_word_data = obj_db_manager.get_send_data() if obj_get_word_data == "NULL": Null_angle_send = send.Send(1, angle[0], angle[1], angle[2], angle[3]) Null_angle_zhazha = dict(Null_angle_send) Null_angle_j = json.dumps(obj=Null_angle_zhazha) #该单词未录入 return Null_angle_j obj_send = send.Send( 0,obj_get_word_data[0],obj_get_word_data[1],obj_get_word_data[2],obj_get_word_data[3]) zhazha=dict(obj_send) j = json.dumps(obj=zhazha) return j except Exception as e: angle12 =("", '', [], 1) angle_send = send.Send( 3,angle12[0],angle12[1],angle12[2],angle12[3]) angle_zhazha = dict(angle_send) angle_j = json.dumps(obj=angle_zhazha) print("异常") return angle_j
def put(): f = request.files['file'] email = request.form['email'] print(email) if f: con = f.read() charobj = chardet.detect(con) con = con.decode(charobj['encoding']) #过滤邮件头部 index = con.index("\n\n") con = con[index::] #判断邮件内容con judgeobj = analysisEmail.judgeEmail() info, P, email_order_ratio = judgeobj.judge(con) if P > 0.9: string = "《这是垃圾邮件,建议删除》" + con else: string = "《这是正常邮件》" + con sendObj = send.Send() sendObj.sendEmail(string, email) return render_template("show.html", data=(info, P, email_order_ratio))
def __init__(hostname, port, nickname, channel): self.nickname = nickname self.Send = send.Send() self.pomobot = self.server() self.pomobot_connection = self.pomobot.connect(hostname, port, nickname) self.pomobot_connection.add_global_handler("pubmsg", parse_pubmsg) self.pomobot_connection.join(channel) self.process_forever() def parse_pubmsg(connection, event): """Parses all messages sent to channel to see if any are meant for pomobot. Each command in a module is named cmd_* so that when a dot command is given all commands implemented by pomodoro.py can be parsed to see if they share the name of the command. If so the rest of the arguments given are passed directly as strings to the associated handler function. Handler functions return events which are parsed by this function and handled in turn. Each event is a list of lists or tuples where each list starts with the type of event as a string and each of these events is handled.""" if (event.arguments[0][0:len("." + self.nickname + " ")] == "." + self.nickname + " "): def handle_events(self): while not Send.event_queue.empty(): try: event = Send.event_queue.get(timeout=0.2) except Empty: return True self.pomobot_connection.privmsg(event[0], event[1]) return True
def main(): if configs.SHOW_RIGHT: Show_right() Init() f_obj = open('Data' + '/user.md') send_number = f_obj.readline() to_addr_str = f_obj.readline() time_interval = (int)(f_obj.readline()) f_obj.close() while(True): for dic in configs.SPIDER_CONFIG: try: status, new_data = Spider(dic, configs.LOG_ENABLED) if status >= 1: send.Send(new_data, dic['department_CN'], send_number, to_addr_str, dic['type'],configs.LOG_ENABLED) except Exception as e: print('Exception: ', e) Error_log = '异常信息如下:\n' + format_exc() + '-' * 70 + '\n' Log_Write('Exception', Error_log, 0) finally: print('-' * 51) time.sleep(time_interval)
def button(bot, update): query = update.callback_query keyboard = [[InlineKeyboardButton("Start again", callback_data='3')]] reply_markup = InlineKeyboardMarkup(keyboard) if query.data == '0': #Query del menu principal index.min = 0 index.max= 10 validate.sendImail = [False,False,False,False,False] bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) keyboard = [[InlineKeyboardButton("Inbox", callback_data='4'), InlineKeyboardButton("Send a email", callback_data='5'),InlineKeyboardButton("Logout", callback_data='7')]] reply_markup = InlineKeyboardMarkup(keyboard) bot.send_message(chat_id=query.message.chat_id,text='Select an option:', reply_markup=reply_markup) #Qyery del boton login if query.data == '1': #bot.send_photo(chat_id=query.message.chat_id, photo=open('./src/stickers/notWorking.png', 'rb'),caption='Out of service now!',reply_markup=reply_markup) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) bot.send_message( chat_id=query.message.chat_id, text='Introduce your email address:' ) elif query.data == '3': #Query al reiniciar el bot (Start Again) validate.login = [False,False,False] validate.sendImail = [False,False,False,False,False] credentials.email = '' credentials.password = '' hour = int(time.strftime("%H")) text = '' if hour >= 0 and hour <= 11: text="Good Morning!" elif hour >= 12 and hour <= 18: text="Good Afternoon!" elif hour >= 17 and hour <= 23: text="Good Evening!" keyboard = [[InlineKeyboardButton("Login", callback_data='1'),InlineKeyboardButton("Close", callback_data='8')]] reply_markup = InlineKeyboardMarkup(keyboard) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) bot.send_message(chat_id=query.message.chat_id, text= text+'\n\n Select an option:', reply_markup=reply_markup) elif query.data == '4': #Query del imbox para mostrar mas correos o ir al Query del menu principal keyboard = [[InlineKeyboardButton("Read more", callback_data='4'),InlineKeyboardButton("Main menu", callback_data='0')]] reply_markup = InlineKeyboardMarkup(keyboard) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) bot.send_message(chat_id=query.message.chat_id,text='Searching emails, please wait....') inboxlist = inbox.OpenInbox(index.min,index.max) index.min = index.min+10 index.max= index.max+10 #print(inboxlist) for info_email in inboxlist: bot.send_message(chat_id=query.message.chat_id,text=info_email) bot.send_message(chat_id=query.message.chat_id,text='Select an option:', reply_markup=reply_markup) elif query.data == '5': #Query de redactar un correo bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) validate.sendImail[0] = True validate.sendImail[1] = True data.From = credentials.email bot.send_message( chat_id=query.message.chat_id, text='To:' ) elif query.data == '6': #Query que manda el correo y muestra el menu principal de nuevo validate.sendImail = [False,False,False,False,False] keyboard = [[InlineKeyboardButton("Inbox", callback_data='4'), InlineKeyboardButton("Send a email", callback_data='5'), InlineKeyboardButton("Logout", callback_data='7')]] reply_markup = InlineKeyboardMarkup(keyboard) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) bot.send_message(chat_id=query.message.chat_id,text='Sending email, please wait....') result = '' if data.file_url == '' and data.file_name == '': result = send.Send(credentials.email,credentials.password,data.From,data.To,data.Subject,data.Body) else: result = sendattch.Send(credentials.email,credentials.password,data.From,data.To,data.Subject,data.Body,data.file_url,data.file_name) if result == 'ok': data.Body = '' data.From = '' data.To = '' data.Subject = '' newsticker = Sticker(file_id= 'CAADAgADAgMAApzW5woU5Cm1Ey_jtAI', width= 512, height= 512) bot.send_sticker(chat_id=query.message.chat_id, sticker= newsticker) bot.send_message(chat_id=query.message.chat_id,text='The email has been sent....') bot.send_message(chat_id=query.message.chat_id,text='Select an option:', reply_markup=reply_markup) else: data.Body = '' data.From = '' data.To = '' data.Subject = '' newsticker = Sticker(file_id= 'CAADAgADCAMAApzW5wqTpbtQDP42agI', width= 512, height= 512) bot.send_sticker(chat_id=update.message.chat_id, sticker= newsticker) bot.send_message(chat_id=query.message.chat_id,text='Has been an error, try again....') bot.send_message(chat_id=query.message.chat_id,text='Select an option:', reply_markup=reply_markup) elif query.data == '7': #Query de cerrar sesion validate.login = [False,False,False] validate.sendImail = [False,False,False,False,False] credentials.email = '' credentials.password = '' index.min = 0 index.max= 10 inbox.Logout() newsticker = Sticker(file_id= 'CAADAgAD9QIAApzW5woDP3qDEC4ObwI', width= 512, height= 512) bot.send_sticker(chat_id=query.message.chat_id, sticker= newsticker) bot.send_message(chat_id=query.message.chat_id,text='Bye!',reply_markup=reply_markup) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) elif query.data == '8': #Query de cerrar bot validate.login = [False,False,False] validate.sendImail = [False,False,False,False,False] credentials.email = '' credentials.password = '' index.min = 0 index.max= 10 newsticker = Sticker(file_id= 'CAADAgAD9QIAApzW5woDP3qDEC4ObwI', width= 512, height= 512) bot.send_sticker(chat_id=query.message.chat_id, sticker= newsticker) bot.send_message(chat_id=query.message.chat_id,text='Bye!\nRemember... I am your father!!',reply_markup=reply_markup) bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) elif query.data == '9': #Query de agregar adjuntable validate.sendImail[4] = True bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) bot.send_message(chat_id=query.message.chat_id,text='Add your file') elif query.data == '10': #Query de no adjuntar archivo al correo, da opcion de enviar o volver al menu principal bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id) keyboard = [[InlineKeyboardButton("Send", callback_data='6'),InlineKeyboardButton("Main menu", callback_data='0')]] reply_markup = InlineKeyboardMarkup(keyboard) bot.send_message(chat_id=query.message.chat_id, text= 'Select an option:', reply_markup=reply_markup)
import receive import gui import time import os if __name__ == "__main__": username = "******" password = "******" labels = [ '"[Gmail]/All Mail"', 'Inbox', '"[Gmail]/Sent Mail"', '"[Gmail]/Trash"' ] # initialize smtp (email sending) and imap (email recieving) protocols receive = receive.Receive(username, password) send = send.Send(username, password) # send.send_message(username, "sadasd", "asdasdffasasfdsfa") msgs = [] file_name = 'messages.data' # if msg file exists then read from it, else retreive msgs using imap if os.path.exists(file_name): msgs = gui.read_from_file(file_name) else: for label in labels: msgs.append(receive.get_message(category=label)) # print inbox category only # for msg in msgs: # print("To:\t", msg[1]) # print("Date:\t", msg[2])
_("Error"), _("There has been an error while taking a screenshot. Please try again later" )) loading_window.destroy() def show_settings_window(self): loading_window = loading.Loading() while Gtk.events_pending(): Gtk.main_iteration() settings_window.show_window() loading_window.destroy() if __name__ == '__main__': notifications_window = notifications.Notifications() summary_window = summary.Summary() send_window = send.Send() controls_window = controls.Controls() settings_window = settings.Settings() tray = TrayIcon() # control notifications every 5 seconds interval_ms = 5 GLib.timeout_add_seconds(interval_ms, tray.get_notifications_interval) Gtk.main()
def create_send(self, topic, msg_type): return send.Send(topic, msg_type)
def confirm(self, image, filename): self.frame_confirm.destroy() self.current_frame = self.frame_send = send.Send(self.master, self, image, filename) #self.frame_email.pack(fill=tk.BOTH, expand=True) self.frame_send.grid(row=0, column=0, sticky="news")
# chaci = yanzheng.get_send_data() # finly = send.Send(chaci[0], chaci[1], chaci[2], chaci[3]) # back_json = send.Send.to_dict(finly) # # 将目前对象转换为字典 # print(back_json) # return jsonify(back_json) # else:return jsonify(fankui) my_json = { "security": { "uname": "amy", "key": 12323, "time": 2321 }, "word": "a", "option": { "level": 1 } } obj_receive = receive.Receive(my_json) print(obj_receive.option.level) obj_check = check.Check(receive=obj_receive) result = obj_check.begin_check() if result == "safe": print(1) else: obj_db_manager = db_manager.Db_Manager(receive=obj_receive) obj_get_word_data = obj_db_manager.get_send_data() obj_send = send.Send(obj_get_word_data[0], obj_get_word_data[1], obj_get_word_data[2], obj_get_word_data[3]) print(obj_send) # fasong = get_send_json(obj_send)