예제 #1
0
    def create_msg(self, action, *args, **kwargs):
        '''
        create_message calls the internal message create_msg
        with an additional "migration_id" argument value.

        :param action: action of this message (message type, i.e. GETSTATUS)
        :param args: arguments to the message
        :param kwargs: additional (dict-type) arguments to the message
        :return: json-encoded message
        '''
        kwargs['migration_id'] = self.migration_id
        msg = create_msg(self.mid, action, *args, **kwargs)
        return msg
예제 #2
0
파일: entry.py 프로젝트: kkeelltt/kelt
def send(key=None):
    session = bottle.request.environ.get('beaker.session')

    # 不正なアクセスでないかチェック
    if not key == session.id:
        return bottle.template('error', error=valid.state('lost_key'))

    # ユーザ宛に確認用メールを送信
    to_addr = '*****@*****.**'
    # to_addr = '{isc_account}@mail.kyutech.jp'.format(**session)
    subject = 'Account request validation'
    for_user = message.write_first(session)
    msg = message.create_msg(FROM_ADDR, to_addr, subject, for_user)
    message.send_msg(SMTP_SVR, msg)

    return bottle.template('send')
예제 #3
0
파일: entry.py 프로젝트: kkeelltt/kelt
def finish(key=None):
    session = bottle.request.environ.get('beaker.session')

    # 不正なアクセスでないかチェック
    if not key == session.id:
        return bottle.template('error', error=valid.state('lost_key'))

    # 承認待ちリストに突っ込む
    database.insert(session)

    # 運用部宛に申請依頼メールを送信
    subject = 'Request for account ({club_account})'.format(**session)
    for_admin = message.write_second(session)
    msg = message.create_msg(FROM_ADDR, ADMIN_ADDR, subject, for_admin)
    message.send_msg(SMTP_SVR, msg)

    # セッションを削除
    session.delete()

    return bottle.template('finish')
    #print("* done recording")

    stream.stop_stream()
    stream.close()
    p.terminate()

    wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
    wf.setnchannels(CHANNELS)
    wf.setsampwidth(p.get_sample_size(FORMAT))
    wf.setframerate(RATE)
    wf.writeframes(b''.join(frames))
    wf.close()
    chroma = HPCP.hpcp(WAVE_OUTPUT_FILENAME,
                       norm_frames=False,
                       win_size=4096,
                       hop_size=1024,
                       output='numpy')
    chroma = np.mean(chroma, axis=0)
    chroma /= sum(chroma)
    chroma = chroma.reshape((1, 12))
    #print(chroma.shape)
    predictions = model.predict(chroma)
    pred_class = np.argmax(predictions, axis=1)
    #print(pred_class)
    #print("predictions array:", predictions)
    content = f"{pred_class[0]}".encode("utf8")
    msg = create_msg(content)
    os.write(fifo, msg)
os.close(fifo)
예제 #5
0
def write_message(msg):
    msg = msg.encode('utf8')
    msg = create_msg(msg)
    os.write(fifo, msg)