Beispiel #1
0
    def test_create_first_memo(self):
        self.config = get_config(TEST_CONFIG_PATH)
        self.config.set('memo', 'memo_dir', self.test_memo_dir)

        memo = Memo(self.config)
        memo.create_first_memo()
        self.assertTrue(os.path.exists(memo.new_memo_path))
Beispiel #2
0
    def main(self):
        while True:
            self.menu()
            answer = input(">> 원하시는 서비스를 입력해주세요~(exit 입력시 종료합니다)\n")
            if answer == 'exit':  #exit 받으면 종료
                sys.exit()
            elif answer == '0':  # 메모장 실행
                m = Memo()
                m.memo()
            elif answer == '1':  # 디데이 실행
                d = Dday()
                d.dday()
                while True:
                    answer = input(">> 계속 하시겠습니까? (예:y, 아니오:n)\n")
                    if answer.lower() == "y":  #대소문자 상관없이
                        d.dday()
                    elif answer.lower() == "n":
                        self.main()
                    else:
                        print("※ 다시 입력해주세요! ※")
                        continue  #다시 while문으로

            elif answer == '2':  #군대용어 실행
                a = Armyword()
                a.quiz()
                while True:
                    answer = input(">> 계속 하시겠습니까? (예:y, 아니오:n)\n")
                    if answer.lower() == "y":
                        a.quiz()
                    elif answer.lower() == "n":
                        self.main()
                    else:
                        print("※ 다시 입력해주세요! ※")
                        continue

            elif answer == '3':  #전역일계산기 실행
                d = Discharge()
                d.discharge()
                while True:
                    answer = input(">> 계속 하시겠습니까? (예:y, 아니오:n)\n")
                    if answer.lower() == "y":
                        d.discharge()
                    elif answer.lower() == "n":
                        self.main()
                    else:
                        print("※ 다시 입력해주세요! ※")
                        continue
            else:
                print("※ 재입력해주세요! ※")
                continue
Beispiel #3
0
 def addMemo(self):
     #set dict message about single memo
     list = self.data['memo_data']
     numInfo = len(list) > 0 and list[-1]['id'] or 0
     info = {}
     info.update(id=numInfo + 1)
     info.update(self.memoSettings)
     #get the time of creating memo
     date = QDate.currentDate()
     date = date.toString(Qt.ISODate)
     #initialize memo object
     allCount = self.layoutr.count()
     label = Memo(self, info)
     if allCount == 0:
         self.layoutr.addWidget(label)
     else:
         self.layoutr.insertWidget(allCount + 1, label)
     #save new memo's message
     memo_data = {}
     memo_data.update(id=numInfo + 1,
                      content='It is empty!',
                      set_date=date,
                      if_done=[])
     self.data['memo_data'].append(memo_data)
     self.data['memo_num'] = len(list)
     write(self.data)
Beispiel #4
0
 def loadMemo(self, data):
     label = Memo(self, data)
     allCount = self.layoutr.count()
     if allCount == 0:
         self.layoutr.addWidget(label)
     else:
         self.layoutr.insertWidget(allCount + 1, label)
Beispiel #5
0
def handle_exception(ex, stacktrace=None):
    err_icon = os.path.join(os.path.dirname(__file__), 'graphics', 'icon_error.gif')
    frm = Form(caption='Exception: {}'.format(ex.__class__.__name__),
               left=100, top=100, width=350, height=180)
    frm.resizable = False
    msg = Label(frm, left=45, top=5, width=305, height=40, caption=ex.message)
    msg.wordwrap = True
    img = Image(frm, left=5, top=15, width=32, height=32, file=err_icon)
    trace = Memo(frm, left=5, top=55, width=335, height=90)
    trace.text = stacktrace

    def close_form():
        frm.close()
    
    btn = Button(frm, left=140, top=148, width=65, height=27, caption="Close")
    btn.on_click = close_form
    frm.show_modal()
Beispiel #6
0
 def get_memo(self, memo_id):
     raw_row = db.get_row(memo_id)
     recorded_memo = Memo(user_id=raw_row[1],
                          memo_type=raw_row[2],
                          memo_name=raw_row[3],
                          link=raw_row[4],
                          notify_time=str2dt(raw_row[5]),
                          notify_count=raw_row[6])
     return recorded_memo
Beispiel #7
0
def return_overdue_memos(current_time):
    memos_list = []
    raw_data = db.get_rows_by_deadline(current_time)
    for raw_row in raw_data:
        recorded_memo = Memo(user_id=raw_row[1],
                             memo_type=raw_row[2],
                             memo_name=raw_row[3],
                             link=raw_row[4],
                             notify_time=str2dt(raw_row[5]),
                             notify_count=raw_row[6])
        memos_list.append(recorded_memo)
    return memos_list
Beispiel #8
0
 def get_memos_list(self):
     memos_list = []
     raw_data = db.get_rows_by_user_id(self.chat_id)
     for raw_row in raw_data:
         recorded_memo = Memo(user_id=raw_row[1],
                              memo_type=raw_row[2],
                              memo_name=raw_row[3],
                              link=raw_row[4],
                              notify_time=str2dt(raw_row[5]),
                              notify_count=raw_row[6])
         memos_list.append(recorded_memo)
     return memos_list
Beispiel #9
0
def file_recieve(message):

    if message.document:
        path = file_saver.save_file(message.chat.id, message.text)
        next_notify_time = datetime.datetime.now() + test_notify_delta[0]
        new_memo = Memo(user_id=message.chat.id,
                        memo_type="text",
                        memo_name=memo_name.pop(message.chat.id),
                        link=path,
                        notify_time=next_notify_time,
                        notify_count=0)
        user = User(message.chat.id)
        user.add_memo(new_memo=new_memo)

        bot.send_message(
            message.chat.id, "<b>Мемо успешно создан.</b>\n"
            "Включи уведомления и я буду присылать тебе напоминания.",
            parse_mode='html',
            reply_markup=keyboards.back_to_main)
        bot.clear_step_handler_by_chat_id(chat_id=message.chat.id)
Beispiel #10
0
    def addMemo(self):
        list = self.data['memo_data']
        numInfo = len(list) > 0 and list[-1]['id'] or 0
        info = {}
        info.update(id=numInfo + 1)
        info.update(self.memoSettings)

        allCount = self.layoutr.count()
        label = Memo(self, info)
        if allCount == 0:
            self.layoutr.addWidget(label)
        else:
            self.layoutr.insertWidget(allCount + 1, label)

        memo_data = {}
        memo_data.update(id=numInfo + 1,
                         content='It is empty!',
                         set_date='',
                         if_done={})
        self.data['memo_data'].append(memo_data)
        self.data['memo_num'] = len(list)
        write(self.data)
Beispiel #11
0
    def run(self,
            num_steps,
            initial_state=None,
            initial_feed_dict={},
            iteration_feed_dict={},
            loss=None,
            stepwise_loss=None):
        memo = Memo()
        memo.initial_feed_dict = initial_feed_dict
        memo.iteration_feed_dict = iteration_feed_dict
        if initial_state is None:
            initial_state = self.initial_state
        memo.initial_state = initial_state

        initial_evaluated = []
        for t in initial_state:
            if isinstance(t, tf.Tensor):
                initial_evaluated.append(self.sess.run(t, initial_feed_dict))
            else:
                initial_evaluated.append(t)

        memo.steps = [initial_evaluated]
        memo.actuations = [None]
        if self.use_visualize:
            memo.point_visualization.append(
                self.evaluate_points(memo.steps[0], iteration_feed_dict))
            memo.vector_visualization.append(
                self.evaluate_vectors(memo.steps[0], iteration_feed_dict))

        rest_steps = num_steps
        while rest_steps > 0:
            now_step = min(rest_steps, self.part_size)
            memo.last_step = now_step
            rest_steps -= now_step
            feed_dict = {self.initial_state.to_tuple(): memo.steps[-1]}
            feed_dict.update(iteration_feed_dict)

            if self.updated_state.controller is not None:
                ret_ph = [
                    self.states[now_step].to_tuple(),
                    self.states[now_step].actuation
                ]

                #options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
                #run_metadata = tf.RunMetadata()

                if stepwise_loss is None:
                    # ret, swl = self.sess.run(ret_ph, feed_dict=feed_dict, options=options, run_metadata=run_metadata), []
                    ret, swl = self.sess.run(ret_ph, feed_dict=feed_dict), []
                else:
                    ret, swl = self.sess.run([ret_ph, stepwise_loss],
                                             feed_dict=feed_dict)

                # Create the Timeline object, and write it to a json file
                # fetched_timeline = timeline.Timeline(run_metadata.step_stats)
                # chrome_trace = fetched_timeline.generate_chrome_trace_format()
                #with open('timeline_01.json', 'w') as f:
                #  f.write(chrome_trace)

                memo.update_stepwise_loss(swl)
                memo.steps.append(ret[0])
                memo.actuations.append(ret[1])
                if self.use_visualize:
                    memo.point_visualization.append(
                        self.evaluate_points(memo.steps[-1],
                                             iteration_feed_dict))
                    memo.vector_visualization.append(
                        self.evaluate_vectors(memo.steps[-1],
                                              iteration_feed_dict))
            else:
                ret_ph = self.states[now_step].to_tuple()
                if stepwise_loss is None:
                    ret, swl = self.sess.run(ret_ph, feed_dict=feed_dict), []
                else:
                    ret, swl = self.sess.run([ret_ph, stepwise_loss],
                                             feed_dict=feed_dict)
                memo.update_stepwise_loss(swl)
                memo.steps.append(ret)
                memo.actuations.append(None)
                if self.use_visualize:
                    memo.point_visualization.append(
                        self.evaluate_points(memo.steps[-1],
                                             iteration_feed_dict))
                    memo.vector_visualization.append(
                        self.evaluate_vectors(memo.steps[-1],
                                              iteration_feed_dict))

        if loss is not None:
            feed_dict = {self.initial_state.to_tuple(): memo.steps[-1]}
            feed_dict.update(iteration_feed_dict)
            memo.loss = self.sess.run(loss, feed_dict=feed_dict)
        return memo
 def __init__(self):
     self.computed_memo = Memo()  # 缓存经计算得出的数据
Beispiel #13
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
# file: packmemo.py
from evernotecontroller import EvernoteController
from memo import Memo

MEMO_NAME = '备忘录'
MEMO_DIR = 'Memo'
# MEMO_STORAGE_DIR = 'S-Memo'


def f(fn, *args, **kwargs):
    try:
        fn(*args, **kwargs)
    except:
        pass


m = Memo()
e = EvernoteController()
f(e.create_notebook, MEMO_DIR)
# f(e.create_notebook, MEMO_STORAGE_DIR)
f(e.move_note, MEMO_DIR + '/' + MEMO_NAME, MEMO_DIR + '/' + MEMO_NAME)
e.create_note(MEMO_NAME, m.raw_memo(), MEMO_DIR)
Beispiel #14
0
def _main():
    config = get_config(CONFIG_PATH)

    check_ssl_expire_date(config)

    get_twitter(config)

    memo = Memo(config)

    if memo.is_exist_today_memo():
        print("Today's memo file has been created already.")
    else:
        print("Today's memo file does not exist.\n"
              "The latest memo will be copied.")
        try:
            memo.copy_memo_from_newest()
        except MemoError as err:
            print('Failed to copy memo file: {}'.format(err))
            exit(1)

        print("Did you fill out yesterday's attendance?")
        memo.open_excel()
        memo.open_website_url()

    memo.open_today_memo()
    exit(0)
Beispiel #15
0
            'videos': self.videos,
            'viewers': self.viewers,
            'playing': self.playing,
        }

    def LEAVE(self):
        self.viewers -= 1

    def VOTE(self, id):
        if id in self.videos:
            self.videos[id]['score'] = 1 + self.videos[id]['score']
            return 'OK'
        return 'not found'

    def ADD(self, url):
        video = embed(url, autoplay=True).value()
        id = url.split('/')[-1]
        if id not in self.videos:
            video['score'] = 1
            video['id'] = id
            self.videos[id] = video
        else:
            video = self.videos[id]
            video['score'] += 1
        return video


server = Memo(address='127.0.0.1', port=8008)
server.add_structure(Station)
server.start()