예제 #1
0
def start():
    token = common.Cfg().get('wechat', 'token')
    if not token:
        token = input('Please enter your wechat token: ')
        common.Cfg().write('wechat', 'token', token)

    public_ip = common.Cfg().get('wechat', 'public_ip')
    if not public_ip:
        public_ip = input('Please enter public IP: ')
        common.Cfg().write('wechat', 'public_ip', public_ip)

    port = common.Cfg().get('wechat', 'port')
    ma_path = manage.__file__
    exe_list = ['python3', ma_path, 'runserver', ':'.join([public_ip, port])]
    exe_str = ' '.join(exe_list)
    os.system(exe_str)
예제 #2
0
    def do_check(self, data_path_list=[]):
        try:
            if not data_path_list:
                data_path_list = common.Cfg().get('local', 'data_paths')
            data_path_list = common.expand_path(data_path_list)
            data_path_list = common.get_yml_path_list(data_path_list)
            for data_path in data_path_list:
                print('')
                LOG.info('Checking %s' % data_path)

                with open(data_path, 'r') as f:
                    qas = yaml.load(f.read())

                for qa in qas:
                    if not qa:
                        self._error(qa, 'qa is none')
                    for value in qa.values():
                        if not value:
                            self._error(qa, 'value is none')
                        else:
                            for item in value:
                                if type(item) is dict:
                                    self._error(qa, 'item is dict')
                                if not item:
                                    self._error(qa, 'item is none')
                LOG.info('Check Passed!')

        except Exception as e:
            LOG.error(e)
예제 #3
0
파일: idea.py 프로젝트: ideamark/breadbot
 def store_idea(self, user, idea_str):
     if not common.is_super(user):
         return
     if not idea_str:
         return
     data_path = common.Cfg().get('local', 'data_paths')[0]
     file_path = os.path.join(data_path, self.store_file)
     time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
     text = '* %s %s\n' % (time_str, idea_str)
     with open(file_path, 'a') as fp:
         fp.write(text)
     return 'OK, idea is stored.'
예제 #4
0
 def do_teach(self, user, in_str):
     if not common.is_super(user):
         return
     if not in_str:
         return
     if self.split_sym not in in_str:
         return
     data_path = common.Cfg().get('local', 'data_paths')[0]
     file_path = os.path.join(data_path, self.teach_file)
     f = open(file_path, 'a')
     que = in_str.split(self.split_sym)[0]
     ans_list = in_str.split(self.split_sym)[1:]
     ans = self.split_sym.join(ans_list)
     que = common.init_input(que)
     ans = common.init_input(ans)
     text = '\n- que:\n  - %s\n  ans:\n  - %s\n' % (que, ans)
     f.write(text)
     f.close()
     return 'OK, I learned.'
예제 #5
0
def get_path_list():
    path_list = common.Cfg().get('local', 'data_paths')
    path_list = common.expand_path(path_list)
    path_list = common.get_md_path_list(path_list)
    return path_list