Example #1
0
def start():
    if len(sys.argv) < 3:
        print('缺少脚本名称')
        return

    script = sys.argv[2]
    if script == 'http_main':
        name = script + common_tools.time_to_str(int(time.time())).replace(
            ' ', '-') + '.log'
        query = 'cp ' + script + '.log' + ' ' + name
        os.system(query)
        print('上一份日志备份到', name)
        time.sleep(1)

        query = 'nohup python3 -u ' + script + '.py > ' + script + '.log 2>&1 &'
        os.system(query)
        print('运行' + script + '.py成功, 日志位置>> ' + script + '.log')

    elif script == 'weibo_bot':
        name = script + common_tools.time_to_str(int(time.time())).replace(
            ' ', '-') + '.log'
        query = 'cp ' + script + '.log' + ' ' + name
        os.system(query)
        print('上一份日志备份到', name)
        time.sleep(1)

        query = 'nohup python3 -u ' + script + '.py ' + sys.argv[
            3] + ' > ' + script + '.log 2>&1 &'
        os.system(query)
        print('运行' + script + '.py成功, 日志位置>> ' + script + '.log')

    else:
        print('非法指令')

    print('start done!')
    open_log = 'cat ' + script + '.log'
    time.sleep(0.5)
    os.system(open_log)
    return
Example #2
0
    def get_case_list_by_cond(cond):
        result_list = []
        res = Data.select('case_info', cond)
        if res == None:
            return
        # 没有结果就返回none
        for line in res:
            info_line = {
                'c_time': common_tools.time_to_str(line['c_time']).split()[0],
                'title': common_tools.decode_base64(line['title']),
                'case_id': line['id']
            }
            result_list.append(info_line)

        result_list = list(reversed(result_list))
        return result_list
Example #3
0
    def post(self):
        data = self.get_post_data()
        if self.get_user_base('admin') != None:
            cond = []
        else:
            cond = [('is_show', '=', 1), ('is_verified', '=', 1)]

        search_time = data['limit_year_time']
        if search_time != '':
            search_time_stamp_start = common.str_to_time(
                str(search_time) + '-01-01 00:00:00')
            search_time_stamp_end = common.str_to_time(
                str(search_time) + '-12-31 23:59:59')
        else:
            search_time_stamp_start = 0
            search_time_stamp_end = 999999999

        condition = [
            ('event_time', '>', search_time_stamp_start),
            ('event_time', '<', search_time_stamp_end),
        ] + cond

        res = Data.select('case_info', condition)
        result_list = []

        if res == None:
            self.send_faild(error.ERROR_NO_RESULT)
            return

        for line in res:
            info_line = {
                'c_time': common.time_to_str(line['c_time']).split()[0],
                'title': common.decode_base64(line['title']),
                'case_id': line['id']
            }
            result_list.append(info_line)

        result_list = list(reversed(result_list))

        result = {'result_list': result_list}

        # print(result)

        self.send_ok(result)
        return
Example #4
0
    def search_case_by_case_id(case_id, character='player'):
        cond = [('id', '=', case_id)]
        if character == 'admin':
            cond.append(('is_show', '=', 1)),

        line = Data.find('case_info', cond)
        if line == None:
            return

        info_line = {
            'case_id': line['id'],
            'content': common_tools.decode_base64(line['content']),
            'c_time': common_tools.time_to_str(line['c_time']).split()[0],
            'title': line['title'],
            'uploader_info': http_tools.get_uploader_info(line['user_id']),
            'post_items': http_tools.get_post_items(line['id']),
        }
        result = info_line
        return result
Example #5
0
def upload_files():
    sm = simulator()
    sm.admin_login(name, pw)
    file_index = get_file_index()
    pass_filename = ['README.md', '_config.yml']
    for file_name in file_index:
        file_name = file_name.strip()
        if file_name not in pass_filename:
            file_content = open(get_file_path() + file_name.strip(),
                                'r').read()
            data = {
                'title': file_name,
                'content': file_content,
                'event_time':
                common_tools.time_to_str(int(time.time())).split()[0],
                'post_items': []
            }
            res = sm.upload(data)
            print(res)