コード例 #1
0
 def weather_change(self, w=None, currently_active=None):
     #try:
     if self._last_current_weather['data'] == {}:
         if self.current_weather() == {}:
             return
     last = self._last_current_weather['data']
     if w is None: w = self.current_weather()
     status_message = status.Status().active_change(currently_active)
     if self.weather_text(w)[1] != self.weather_text(last)[1]:
         if self.weather_text(w)[1]:
             message.send_message(
                 '<a href="https://openweathermap.org/city/4720060"><b>Weather has changed:</b></a>\n<i>'
                 + self.weather_text(w)[0] + '</i>' + status_message)
         else:
             message.send_message(
                 '<a href="https://openweathermap.org/city/4720060"><b>Weather has changed:</b></a>\n<i>'
                 + self.weather_text(w)[0] + '</i>' + status_message)
     elif self.wind_text(w)[1] != self.wind_text(last)[1]:
         if self.wind_text(w)[1]:
             message.send_message(
                 '<a href="https://openweathermap.org/city/4720060"><b>Wind has changed:</b></a>\n<i>'
                 + self.wind_text(w)[0] + '</i>' + status_message)
         else:
             message.send_message(
                 '<a href="https://openweathermap.org/city/4720060"><b>Wind has changed:</b></a>\n<i>'
                 + self.wind_text(w)[0] + '</i>' + status_message)
     elif self.weather_text(w)[1] != self.weather_text(
             last)[1] and self.wind_text(w)[1] != self.wind_text(last)[1]:
         out = '<a href="https://openweathermap.org/city/4720060"><b>Weather and wind have changed:</b></a><i>\nWeather: '
         out += ('✅' if self.weather_text(w)[1] else '❌')
         out += ' ' + self.weather_text(w)[0] + '\nWind: '
         out += ('✅' if self.wind_text(w)[1] else '❌')
         out += ' ' + self.wind_text(w)[0] + '</i>'
         message.send_message(out + status_message)
コード例 #2
0
def start_game(input_queue, queues):
    # Starts send and receive threads for each client
    log("start_game", "starting new_troops thread")
    assign_territories(len(queues))
    t1 = new_troops(input_queue)
    t1.daemon = True
    t1.start()
    t2 = update_quota(input_queue)
    t2.daemon = True
    t2.start()
    send_new_state(queues)
    while running:
        process_commands(input_queue)
        check_timers()
        send_new_state(queues)
    print("TIME TO END!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
    for sock in socks:
        try:
            final_cmd = json.dumps(['end', 0])
            message.send_message(sock, final_cmd)
            print("send final cmd # # # # # # # # ")
            sock.close()
        except:
            pass
    sys.exit()
コード例 #3
0
 def send_to_all(self, orig_sock, msg: str):
     for s in self.sockets_list:
         if s != orig_sock and s != self.connect_socket:
             try:
                 message.send_message(s, msg)
             except:
                 self.remove_socket(s)
コード例 #4
0
ファイル: server.py プロジェクト: tanelso2/MessagingService
 def send_to_all(self, orig_sock, msg: str):
     for s in self.sockets_list:
         if s != orig_sock and s != self.connect_socket:
             try: 
                 message.send_message(s, msg)
             except:
                 self.remove_socket(s)
コード例 #5
0
ファイル: check_packt.py プロジェクト: mjarosie/packt-checker
def main():
    if cfg.INFO:
        print('Started script with parameters: ' + '; '.join(sys.argv[1:]))
    args = parse_args()
    if cfg.INFO:
        print('Sender: ' + args.sender)
        print('List of recipients: [' + ', '.join(args.recipients) + ']')
        print('URL: ' + args.url)

    # Prepare a page to be scraped.
    page_content = url_requester.urlopen(args.url).read()
    soup = get_page_soup(page_content)

    # Get offer parameters.
    offer_image_url = offer.offer_image_url_extracter(soup)
    offer_title = offer.offer_title_extracter(soup)
    offer_description = offer.offer_description_extracter(soup)

    if cfg.INFO:
        if offer_image_url != '':
            print('Offer image url: ' + offer_image_url)
        if offer_title != '':
            print('Offer title: ' + offer_title)
        if offer_description != '':
            print('Offer description: ' + offer_description)

    # Prepare a message to be send.
    image = offer.image_getter(offer_image_url)
    msg_to_be_send = offer.message_creator(image, offer_image_url, offer_title,
                                           offer_description, args.sender,
                                           args.recipients)

    # Send a message.
    message.send_message(msg_to_be_send, args.sender, args.recipients)
コード例 #6
0
ファイル: client.py プロジェクト: tanelso2/MessagingService
 def select_name(self):
     name = self.top_entry.get()
     message.send_message(self.sock, name)
     self.entry.config(state=tk.NORMAL)
     self.button.config(state=tk.NORMAL, command=self.send_msg)
     self.entry.focus_set()
     self.master.title("TN Messenger: User {}".format(name))
     self.master.bind('<Return>', self.return_callback)
     self.top.destroy()
コード例 #7
0
ファイル: customer.py プロジェクト: haiyanzzz/CRM-
    def single_view(self, request):
        if request.method == "GET":
            form = SingleModelForm()
            return render(request, "single_view.html", {"form": form})
        else:
            form = SingleModelForm(request.POST)
            if form.is_valid():
                # exclude = ["status", "consultant", "last_consult_date", "recv_date"]
                print(form.cleaned_data)
                """客户表新增数据:
                     - 获取该分配的课程顾问id
                     - 当前时间
                 客户分配表中新增数据
                     - 获取新创建的客户ID
                     - 顾问ID
             """

                # 方式一
                sale_id = AutoSale.get_sale_id()  #获取该分配的销售id
                if not sale_id:
                    return HttpResponse("无销售顾问 ,无法进行自动分配")
                ctime = datetime.datetime.now().date()
                try:

                    with transaction.atomic():
                        print(111)
                        #创建客户表
                        #由于页面上没有这个值,所以数据库里面的值没有添加上,
                        # save保存会把所有的都保存。如果不设置值就会报错。所以,可以通过这种方式去做。额外的增加一条数据
                        form.instance.consultant_id = sale_id
                        form.instance.recv_date = ctime
                        form.instance.last_consult_date = ctime
                        customer_obj = form.save()
                        #创建客户分配表
                        models.CustomerDistribution.objects.create(
                            user_id=sale_id,
                            customer=customer_obj,
                            ctime=ctime)
                    # 方式二:
                    # with transaction.atomic():
                    #     sale_id = Input_information.get_sale_id()
                    #     ctime = datetime.datetime.now().date()
                    #     course = form.cleaned_data.pop('course')
                    #     customer_obj = models.Customer.objects.create(**form.cleaned_data, consultant_id=sale_id,
                    #                                                   recv_date=ctime)
                    #     customer_obj.course.add(*course)
                    #     models.CustomerDistribution.objects.create(user_id=sale_id, customer=customer_obj, ctime=ctime)

                    #发送消息
                    message.send_message('*****@*****.**', 'dsfdfd', '你好',
                                         '这是真的')
                except Exception as e:
                    AutoSale.rollback(sale_id)
                    return HttpResponse("录入异常")
                return HttpResponse("录入数据成功")
            else:
                return render(request, "single_view.html", {"form": form})
コード例 #8
0
ファイル: client.py プロジェクト: tanelso2/MessagingService
 def select_name(self):
     name = self.top_entry.get()
     message.send_message(self.sock, name)
     self.entry.config(state=tk.NORMAL)
     self.button.config(state=tk.NORMAL, command=self.send_msg)
     self.entry.focus_set()
     self.master.title("TN Messenger: User {}".format(name))
     self.master.bind('<Return>', self.return_callback)
     self.top.destroy()
コード例 #9
0
ファイル: server.py プロジェクト: davidMcneil/Real-Time-Risk
  def run(self):
    while True:
      command = self.output_queue.get()
      if command[0] == "quota":
	if self.ID in command[1]:
	  command[1] = command[1][self.ID]
        else: command[1] = 0
      log("send_commands", command)
      command = str(command)
      message.send_message(self.socket, command)
コード例 #10
0
def manage_twitter(twit:twitter.Twitter):
    handle_elon(twit)
    resp = twit.update()
    if resp is None:
        return
    for x in resp:
        for tweet in resp[x]:
            link = 'https://twitter.com/'+x+'/status/'+str(tweet['id'])
            if twitter_filter(x, tweet['text']):
                message.send_message('<a href="'+link+'">‌‌<b>Tweet by '+twit.get_Name(x)+'</b>\n(@'+x+' on Twitter)</a>',False)
コード例 #11
0
ファイル: reporter.py プロジェクト: stanf0rd/commit-watcher
def report(app_id, event, data, config):
    """ Collects data from json and sends message to bot """

    message = "New #{} activity:\n".format(app_id)

    if event == "push":
        message += gen_push_report(data)

    send_message(message, config.get('chats'))
    return
コード例 #12
0
 def run(self):
     while True:
         command = self.output_queue.get()
         if command[0] == "quota":
             if self.ID in command[1]:
                 command[1] = command[1][self.ID]
             else:
                 command[1] = 0
         log("send_commands", command)
         command = str(command)
         message.send_message(self.socket, command)
コード例 #13
0
def add_client(l, input_queue, client_num):
    ###Creates socket and recieve and send thread for each client
    log("add_client", "creating connection")
    sock = create_connection(l)
    first_command = str(['ID', client_num])
    message.send_message(sock, first_command)
    log("add_client", "starting receiver")
    receive_commands(input_queue, sock).start()
    output_queue = Queue.Queue()
    send_commands(sock, output_queue, client_num).start()
    return output_queue
コード例 #14
0
ファイル: server.py プロジェクト: davidMcneil/Real-Time-Risk
def add_client(l, input_queue, client_num):
###Creates socket and recieve and send thread for each client
  log("add_client", "creating connection")
  sock = create_connection(l)
  first_command = str(['ID',client_num])
  message.send_message(sock, first_command)
  log("add_client", "starting receiver")
  receive_commands(input_queue, sock).start()
  output_queue = Queue.Queue()
  send_commands(sock, output_queue, client_num).start()
  return output_queue
コード例 #15
0
ファイル: app.py プロジェクト: srr013/groupmebot-yahoo
def transactions(groupme_id):
	# groupme_bot = GroupMe_Bot.GroupMe_Bot(app)
	# group_data = initialize_group(groupme_id)
	group_data = GroupMe_Bot.get_group_data(groupme_id)
	if group_data['status'] > 0:
		logging.warn("Getting league transactions")
		transaction_msg = GroupMe_Bot.get_transaction_msg(group_data)
		logging.warn("Transaction message: %s" %(transaction_msg))
		if transaction_msg:
			m.send_message(transaction_msg, group_data['bot_id'])
	return display_status()
コード例 #16
0
def manage_closures(inlastmin = 1):
    if CameronCountyData().road_closure_active() != []:
        for x in CameronCountyData().road_closure_active():
            if x not in currently_active['closure']:
                currently_active['closure'].append(x)
                if x[0]+datetime.timedelta(minutes=inlastmin) > datetime.datetime.utcnow():
                    message.send_message('<a href="https://www.cameroncounty.us/spacex/"><b>Road closure now active!</b></a>\n(<i>From '+Database().datetime_to_string(x[0])+' to '+Database().datetime_to_string(x[1])+' UTC</i>)'+Status().active_change(currently_active))
    for x in currently_active['closure']:
        if x not in CameronCountyData().road_closure_active():
            currently_active['closure'].remove(x)
            message.send_message('<a href="https://www.cameroncounty.us/spacex/"><b>Road closure no longer active!</b></a>\n(<i><s>From '+Database().datetime_to_string(x[0])+' to '+Database().datetime_to_string(x[1])+' </s>UTC</i>)'+Status().active_change(currently_active))
コード例 #17
0
def manage_tfrs(inlastmin = 1):
    if FAAData().faa_active() != []:
        for x in FAAData().faa_active():
            if x not in currently_active['tfr']:
                currently_active['tfr'].append(x)
                if x[0]+datetime.timedelta(minutes=inlastmin) > datetime.datetime.utcnow():
                    message.send_message('<a href="https://tfr.faa.gov/tfr_map_ims/html/cc/scale7/tile_33_61.html"><b>TFR (unlimited) now active!</b></a>\n(<i>From '+Database().datetime_to_string(x[0])+' to '+Database().datetime_to_string(x[1])+' UTC</i>)'+Status().active_change(currently_active))
    for x in currently_active['tfr']:
        if x not in FAAData().faa_active():
            currently_active['tfr'].remove(x)
            message.send_message('<a href="https://tfr.faa.gov/tfr_map_ims/html/cc/scale7/tile_33_61.html"><b>TFR (unlimited) no longer active!</b></a>\n(<i><s>From '+Database().datetime_to_string(x[0])+' to '+Database().datetime_to_string(x[1])+'</s> UTC</i>)'+Status().active_change(currently_active))
コード例 #18
0
def start_app(spy):

    current_status_message = None

    if spy['age'] > 12 and spy['age'] < 50:

        if spy['rating'] >= 0.0 and spy['rating'] < 2.5:
            print'Authentication completed. Welcome %s %s, age : %d.' \
                  ' Proud to have you on board. You are a noobie' \
                   % (spy['salutation'], spy['name'], spy['age'])
        elif spy['rating'] >= 2.5 and spy['rating'] < 4.0:
            print'Authentication completed. Welcome %s %s, age : %d. ' \
                 'Proud to have you on board. You are an intermediate' \
             % (spy['salutation'], spy['name'], spy['age'])
        elif spy['rating'] >= 4.0:
            print'Authentication completed. Welcome %s %s, age : %d. ' \
                 'Proud to have you on board. You are an expert' \
             % (spy['salutation'], spy['name'], spy['age'])

        show_menu = True

        while show_menu:

            menu_choices = "What do you want to do?\n" \
                           "1. Add a status update\n" \
                           "2. Add a friend \n" \
                           "3. Send a secret message \n" \
                           "4. Read a secret message\n" \
                           "5. Read Chats from a user \n" \
                           "6. Close Application \n"

            menu_choice = raw_input(menu_choices)

            if len(menu_choice) > 0:
                menu_choice = int(menu_choice)

                if menu_choice == 1:
                    current_status_message = add_status1(
                        current_status_message)

                elif menu_choice == 2:
                    number_of_friends = add_buddy1()
                    print 'You have %d friends' % (number_of_friends)
                elif menu_choice == 3:
                    send_message()
                elif menu_choice == 4:
                    read_message()
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
                    print 'Enter a valid option'
    else:
        print 'Sorry you are not of the correct age to be a spy'
コード例 #19
0
ファイル: start.py プロジェクト: dy-fi/Custom-Email-Lobber
def send_messages(service, users, mes, subject, attachments=None):
    print(users)
    for k, v in users:
        f = m.format_message(k, mes)
        s = m.format_message(k, subject)
        if attachments:
            formed_message = m.create_message_with_attachment(v, s, f, attachments)
            print("sending to: " + k)
            m.send_message(service, "me", formed_message)
        else:
            formed_message = m.create_message(v, s, f)
            print("sending to: " + k)
            m.send_message(service, "me", formed_message)
コード例 #20
0
def switch_off():
    global is_stove_on
    global flag
    # turn off the stove
    #change value of TURN ON/OFF FLAG in jog
    print('the stove is off')
    is_stove_on = False
    GPIO.output(14, False)
    flag = 0

    video_thread = threading.Thread(target=recordVideo)
    video_thread.start()

    send_message(bot, chat_id, "stove is off")
    time.sleep(3)
    return redirect(url_for('main'))
コード例 #21
0
def run_alarm(lcd, red_light, api_key):
    print("Alarm Triggered")
    # Clear Display
    lcd.clear()
    lcd.home()
    lcd.cursor = False
    # Flash denied message and red light
    red_light.blink()
    message.send_message(api_key, "Your mailbox alarm was triggered",
                         "Protecta Alarm")
    for i in range(4):
        lcd.home()
        lcd.message = "Alarm! Alarm!\nPolice Called"
        time.sleep(0.5)
        lcd.clear()
        time.sleep(0.5)
コード例 #22
0
 def run(self):
     global running
     while True:
         command = self.output_queue.get()
         if command[0] == "quota":
             if self.ID in command[1]:
                 command[1] = command[1][self.ID]
             else:
                 command[1] = 0
         # log("send_commands", command)
         command = json.dumps(command)
         try:
             message.send_message(self.socket, command)
         except Exception as e:
             # self.socket.close()
             print("# # # # # # # # # ##", e, "exiting game")
             running = False
コード例 #23
0
def add_client(l, input_queue, client_num):
    # Creates socket and recieve and send thread for each client
    log("add_client", "creating connection")
    sock = create_connection(l)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    global socks
    socks.append(sock)
    first_command = json.dumps(['ID', client_num])
    message.send_message(sock, first_command)
    log("add_client", "starting receiver")
    t1 = receive_commands(input_queue, sock, client_num)
    t1.daemon = True
    t1.start()
    output_queue = Queue.Queue()
    t2 = send_commands(sock, output_queue, client_num)
    t2.daemon = True
    t2.start()
    return output_queue
コード例 #24
0
def process_compose_message_form():
    """Handler for POST requests to ``/compose/`` path.

    * Processes the message form

        1. Validates the submitted form

            - **If the form is has any errors**, saves the errors as
              danger alerts and redirects the user back to ``/compose/``
            - Otherwise (no errors) proceed to step 2.

        2. Saves message data to a new file on disk

        3. Save a success alert message

        4. Redirects the user to ``/``

    * Requires users to be logged in

    :returns: None. This function only redirects users to other
        pages. It has no template to render.

    """
    # Validate the form, get errors if there are any.
    errors = validate_message_form(request.forms)

    # Save errors and redirect
    if errors:
        save_danger(*errors)
        redirect('/compose/')

    # Otherwise get the necessary info in the dictionary
    dict = {}
    dict['to'] = request.forms['to']
    dict['from'] = request.get_cookie("logged_in_as")
    dict['subject'] = request.forms['subject']
    dict['body'] = request.forms['body']
    dict['time'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    # Send the message (creates a .json file in messages/)
    send_message(dict)

    save_success("Message sent!")
    redirect("/")
コード例 #25
0
def send_alert():
    db = UserModel(dbname='../../db.sqlite3')
    user_list = db.get_items()
    # Get vacancies for the last day
    data = get_new_vacancies()
    # Compare old and new data. Get filtered new data.
    new_data = compare_data(data)
    if new_data:
        # Saving last sent vacancies
        with open('last_sent_vacancies.json', 'w+') as outfile:
            json.dump(new_data, outfile, indent=4, ensure_ascii=False)
    # Sending vacancies
    for user in user_list:
        send_message(chat_id=user, text=first_message)
        count = len(new_data)
        if count == 0:
            send_message(chat_id=user,
                         text=no_vacancies_message
                         )
        else:
            if count == 1:
                send_message(chat_id=user,
                             text=single_vacancy_warning_message.format(count)
                             )
            else:
                send_message(chat_id=user,
                             text=plural_vacancy_warning_message.format(count)
                             )
            for vacancy in new_data:
                send_message(chat_id=user,
                             text=vacancy_message.format(
                                                    count=count,
                                                    title=vacancy['title'],
                                                    company=vacancy['company'],
                                                    location=vacancy['location'],
                                                    salary=vacancy['salary'],
                                                    overview=vacancy['overview'],
                                                    url=vacancy['url']
                                                    )
                             )
                count -= 1
                time.sleep(.1)  # Wait 0.1 sec before the next vacancy
コード例 #26
0
ファイル: app.py プロジェクト: srr013/groupmebot-yahoo
def webhook():
	monitoring_status, messaging_status = GroupMe_Bot.get_application_status()
	if request.method == 'GET':
		return display_status()
	elif request.method == 'POST' and monitoring_status:
		message = request.get_json()
		logging.warn("Message received from %s at %s" % (str(message['name']), datetime.datetime.strftime(datetime.datetime.now(), '%d-%m-%Y %H:%M')))
		group_data = GroupMe_Bot.get_group_data(message['group_id'])
		GroupMe_Bot.save_message(message)
		msg_ready = False
		msg_type = 'reply'
		msg = ''
		if not m.sender_is_bot(message):
			msg_ready, msg, msg_type = GroupMe_Bot.check_msg_for_command(message, group_data)
			if int(group_data['messaging_status']) > 0 or msg_ready:
				GroupMe_Bot.increment_message_num(group_data['index'])
				logging.warn("Checking for active triggers")
				active_triggers = GroupMe_Bot.check_triggers(group_data)
				if active_triggers:
					trigger_msg = GroupMe_Bot.get_trigger_messages(group_data, active_triggers)
					if trigger_msg:
						m.send_message(trigger_msg, group_data['bot_id'])
				logging.warn("Processing user message")
				# logging.info(group_data)
				if not msg_ready:
					msg_ready, msg, msg_type = GroupMe_Bot.long_post(message, group_data)
				if not msg_ready:
					msg_ready, msg, msg_type = GroupMe_Bot.talking_to_self(group_data)
				if not msg_ready:
					msg_ready, msg, msg_type = GroupMe_Bot.talking_to_bot(message, group_data)
				if not msg_ready:
					if group_data['message_num'] >= group_data['message_limit']:
						msg_ready, msg, msg_type = GroupMe_Bot.insult(message, group_data)
				if msg_ready:
					if msg_type == 'mention':
						m.send_with_mention(msg, message['name'], message['sender_id'], group_data['bot_id'])
					elif msg_type == 'image':
						m.send_with_image(group_data['bot_id'], msg)
					else:
						m.send_message(msg, group_data['bot_id'])
		return "ok", 200
	return "not found", 404
コード例 #27
0
def end_standup(target_channel, token, length):

    time.sleep(length)

    # update channel with end standup
    target_channel['standup']['is_standup'] = False
    target_channel['standup']['time_finish'] = None

    # join all messages into standup_messages separated by new line
    standup_messages = '\n'.join(target_channel['standup']['standup_messages'])

    # get user
    caller = check_token(token)

    # send standup_messages from the user who called the standup
    send_message(caller, standup_messages, target_channel,
                 target_channel['id'])

    # clear messages from standup buffer
    for old_message in target_channel['standup']['standup_messages']:
        target_channel['standup']['standup_messages'].remove(old_message)
コード例 #28
0
def jog_on_off():
    global flag
    global is_stove_on

    # stove starts off
    flag = 0
    curr_stat = 0
    stat = 0

    is_temp_thread_start = 0  ##temp_thread flag --> to start temp_thread only once

    # turning stove on and off with jog center button
    while True:
        curr_stat = GPIO.input(button)
        time.sleep(0.2)
        if curr_stat != stat:
            stat = curr_stat

        #for center led blinks
        if stat == 1:
            if flag == 0:
                print('the stove is on')
                is_stove_on = True

                GPIO.output(led1, True)
                flag = 1
                send_message(bot, chat_id, "stove is on")

                if (not is_temp_thread_start):
                    temp_thread.start()
                    is_temp_thread_start = 1

            else:
                print('the stove is off')
                is_stove_on = False
                GPIO.output(led1, False)
                flag = 0
                send_message(bot, chat_id, "stove is off")
コード例 #29
0
def daily_update(logger):
    logger.debug('>daily')
    try:
        ccp = CameronCountyParser()
        ccp.parse()
        CameronCountyData().append_cameroncounty(ccp.closures, False)
        faa = FAAParser()
        faa.parse()
        FAAData().append_faa(faa.tfrs, False)
        logger.debug('>collected & waiting')
        #make sure the message is sent exactly at 11:00 (UTC)
        wait = (datetime.datetime.combine(datetime.datetime.utcnow().date(),
                                          Database().daily_message_time) -
                datetime.datetime.utcnow()).total_seconds()
        if wait > 0:
            time.sleep(wait)
        message.send_message(message.daily_update_message(
            closures=CameronCountyData().road_closure_today(),
            tfrs=FAAData().faa_today(),
            weather=Weather().today_forecast()),
                             color=16767232)
    except Exception as e:
        message.ErrMessage().sendErrMessage(
            'Error daily-message!\n\nException:\n' + str(e))
コード例 #30
0
ファイル: main.py プロジェクト: foximler/MasterPike
def api_uuid():
    # Check if a UUID was provided as part of the URL
    # If UUID is provided, assign it to a variable
    # If not UUID is provided, display error in browser
    # Repeat for other arguments
    arguments = ['uuid', 'temp', 'humid', 'alert', 'lat', 'long', 'time']
    argument_data = {}
    for argument in arguments:
        if argument in request.args:
            if request.args[argument] is not None:
                argument_data[argument] = request.args[argument]
        else:
            return f"Error, {argument} not provided. Please specify a {argument}"

    update_database(argument_data)
    check = "Successful Request!"
    if argument_data['alert'] == "1":
        check = send_message('content.txt', argument_data['uuid'])

    return check
コード例 #31
0
import inputs
import search_reddit
import message
import time

##############################################################################
#
# Script

if __name__ == '__main__':
    user_specs = inputs.get_laptop_specs()
    links = search_reddit.search_submissions(user_specs)

    if len(links) != 0:
        message.send_message(user_specs, links)
    else:
        print("Unable to find any laptops that fit the specifications")

    while True:
        enable_notifications = str(
            input(
                "\nWould you like to enable notifications for new submissions that match your specifications (yes/no)?: "
            ))
        if enable_notifications.lower() == "yes":
            while True:
                notification_links = search_reddit.search_submissions(
                    user_specs, True)
                if len(notification_links) != 0:
                    print("A new laptop has been found")
                    message.send_message(user_specs, notification_links)
コード例 #32
0
 def info(self, msg):
     self.logger.info(msg)
     if self.broadcast:
         message.send_message(f'Log: [INFO] {msg}', color=1237395)
コード例 #33
0
 def warning(self, msg):
     self.logger.warning(msg)
     if self.broadcast:
         message.send_message(f'Log: [WARN] {msg}', color=16767232)
コード例 #34
0
 def error(self, msg):
     self.logger.error(msg)
     if self.broadcast:
         message.send_message(f'Log: [ERROR] {msg}', color=13632027)
コード例 #35
0
ファイル: client.py プロジェクト: tanelso2/MessagingService
 def send_msg(self):
     msg = self.entry.get()
     message.send_message(self.sock, msg)
     self.entry.delete(0, tk.END)
コード例 #36
0
ファイル: client.py プロジェクト: davidMcneil/Real-Time-Risk
 def run(self):
   while True:
     command = output_queue.get()
     command = str(command)
     message.send_message(self.socket, command)
コード例 #37
0
ファイル: kernel.py プロジェクト: yasusii/shaling
    for (i,doc,part) in docs:
      if config.LABEL4DRAFT not in doc.get_labels():
        raise Kernel.ValueError('Message not in the draft: %d' % (i+1))
      msg = doc.get_msg(0)
      try:
        (fromaddr, rcpts) = validate_message_headers(msg, not force)
      except MessageFormatError, e:
        raise Kernel.ValueError('%s: message %d' % (e, i+1))
      msgs.append((doc.loc, msg, fromaddr, rcpts))

    # Move the message from the draft to inbox (sent).
    corpus = self.get_selection().get_corpus()
    corpus.set_writable()
    for (loc,msg,fromaddr,rcpts) in msgs:
      try:
        data = message.send_message(msg, fromaddr, rcpts)
      except message.MessageTransportError, e:
        raise Kernel.ValueError('%s: %r' % (e, rcpts))
      if verbose:
        self.terminal.notice('From: %r' % fromaddr)
        self.terminal.notice('Rcpt: %r' % rcpts)
      corpus.mark_deleted(loc)
      corpus.add_message(data, config.LABEL4SENT)
    corpus.flush(self.notice_indexing)
    self.remove_selection()
    return

  # cmd_inc
  def cmd_inc(self, args):
    'usage: inc [-q)uiet] [-E)rase] [-P)reserve] [-r rulefile] [+label] [spool ...]'
    import importer