Esempio n. 1
0
 def post(self, sender, text):
     self.subscribers_lock.acquire()
     try:
         for client in self.subscribers:
             client.send_message(message.ChatMessage(self.name, sender, text))
     finally:
         self.subscribers_lock.release()
Esempio n. 2
0
def derp():
    slack_event = json.loads(request.data)

    if "challenge" in slack_event:
        return make_response(slack_event["challenge"], 200, {"content_type": "application/json" })

    if verification_token != slack_event.get("token"):
        message = "Invalid Slack verification token: %s \npyBot has: \
                %s\n\n" % (slack_event["token"], verification_token.verification)

        make_response(message, 403, {"X-Slack-No-Retry": 1})

    if "event" in slack_event:
        event = slack_event['event']
        if "text" in event.keys() and event['text'].startswith('!last'):
            number = 1
            split = event['text'].split(" ")
            if len(split) > 1:
                number = int(split[1])
            last = list(fetch())[:number]
            for message in entries_to_messages(last):
                send_message(message)
            return make_response("OK", 200, {})

    return make_response("[NO EVENT IN SLACK REQUEST] These are not the droids\
                             you're looking for.", 404, {"X-Slack-No-Retry": 1})
Esempio n. 3
0
    def process_raw_readings(self):
        processed_pitch = self.moving_rms( self.raw_pitches )
        processed_volume = self.moving_rms( self.raw_volumes )

        self.pitches.append(processed_pitch)
        self.pitches.append(processed_volume)
        print("Pitch {:.2f}, Volume {:.2f}".format(processed_pitch, processed_volume))
        send_message(processed_pitch, processed_volume)
Esempio n. 4
0
def BuzzGeoFindNeighboursRequest(client, lat, lon, cursor, offset):
  request = test_pb2.BuzzGeoFindNeighboursRequest()
  request.requestId = "99"
  request.latitude = lat
  request.longitude = lon
  request.cursor_pos = cursor
  request.offset = offset
  logging.info("GeoFindNeighboursRequest:%s", request)
  client.send_message(21, request)
Esempio n. 5
0
def BuzzGeoReport(client, lat, log, id):
  request = test_pb2.BuzzGeoReport()
  request.requestId = "99"
  request.info.latitude = lat
  request.info.longitude = log
  request.info.buzz_id = id
  logging.info("GeoReportRequest:%s",request)
  print request
  client.send_message(20, request)
Esempio n. 6
0
def help_message(channel, command, help):
    """
    Post a formatted help message to the given channel
    :param channel: channel to post into
    :param command: command pattern
    :param help: descriptive text
    :return:
    """
    if help:
        send_message(channel, " - ".join([command, help]))
Esempio n. 7
0
def BuzzGeo(client, lat, lon, id):
  request = test_pb2.BuzzGeoReport()
  request.requestId = "99"
  request.info.latitude = lat
  request.info.longitude = lon
  request.info.buzz_id = id
  msg = client.send_message(20, request)
  response = test_pb2.BuzzGeoReportResponse.FromString(msg)
  print response
Esempio n. 8
0
def start_play(threadname, headset):
    uuid = headset.uuid
    files = headset.todayplaylist
    paths = [os.path.join("data", uuid, file) for file in files]
    for path in paths:
        cmd = " ".join(["ffplay", path])
        start = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        commands.getstatusoutput(cmd)
        end = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        basename = os.path.basename(path)
        resourceid = os.path.splitext(basename)[0]

        msg = {
        "businessCode": 807,
        "data": [{"headsetCourseResourceId":resourceid, "startTime":start,\
                        "endTime":end, "playProgress":100}]
        }
        send_message(headset, msg)
    tkinter.messagebox.showinfo('提示', '今天任务已完成')
Esempio n. 9
0
def BuzzGeoFindNeighbours(client, lat, lon, cursor, offset):
  request = test_pb2.BuzzGeoFindNeighboursRequest()
  request.requestId = "99"
  request.latitude = lat
  request.longitude = lon
  request.cursor_pos = cursor
  request.offset = offset
  msg = client.send_message(21, request)
  response = test_pb2.BuzzGeoFindNeighboursRequestResponse.FromString(msg)
  print response
Esempio n. 10
0
    def send(self):
        # Creates the log file name
        global username
        message = self.ids['message'].text
        log_message = "[" + username + "]" + message + "\n"
        global receiver
        global client

        # Send a signal to the client to send messages to the server, with the necessary args
        client.send_message([receiver], message)
        self.ids['message'].text = ""
        if sys.platform.startswith('win32'):
            dir_path = os.path.dirname(os.path.realpath(__file__)) + "\\logs\\"
        elif sys.platform.startswith('linux'):
            dir_path = os.path.dirname(os.path.realpath(__file__)) + "/logs/"
        filename = dir_path + username + ";" + receiver

        # When a message is sent, write in log
        log = open(filename, 'a')
        log.write(log_message)
        log.close()
        global client
Esempio n. 11
0
 def send_message(self, address, message, context=None):
     if context:
         self.request_context[message.request_id] = context
         client.sendonly_message(address, message)
     else:
         return client.send_message(address, message)
Esempio n. 12
0
                        cv2.rectangle(frame, (left, top), (right, bottom),
                                      (0, 0, 255), 2)
                        cv2.rectangle(frame, (left, bottom - 35),
                                      (right, bottom), (0, 0, 255), cv2.FILLED)
                        font = cv2.FONT_HERSHEY_DUPLEX

                        cv2.putText(frame, name, (left + 6, bottom - 6), font,
                                    1.0, (255, 255, 255), 1)

                        # client.send_message(b"UNLOCK",IP,PORT)
                        # print("Found Face")
                        name_list.append(name)

                        if len(name_list) >= 8:
                            if all_same(name_list[-8:]):
                                print("Found Face")
                                client.send_message(b"UNLOCK", IP, PORT)
                                name_list = []

        # print(rgb_small_frame)

        # gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        # Display the resulting frame
        cv2.imshow('Face Detector', frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

cap.release()
cv2.destroyAllWindows()
Esempio n. 13
0
 def send_message(self, address, message, context=None):
     if context:
         self.request_context[message.request_id] = context
         client.sendonly_message(address, message)
     else:
         return client.send_message(address, message)
Esempio n. 14
0
def post_new_entries():
    global new_entries
    existing_entries = new_entries[:]
    new_entries = fetch()
    for msg in get_new_entries(existing_entries, new_entries):
        send_message(msg)