Ejemplo n.º 1
0
def init():
    global port
    js = file_util.read_all_text('config.json')
    js = json.loads(js)
    port = js['port']

    app.config.from_object(APSchedulerJobConfig)
    # 初始化Flask-APScheduler,定时任务
    scheduler = APScheduler(BackgroundScheduler(timezone="Asia/Shanghai"))
    scheduler.init_app(app)
    scheduler.start()
Ejemplo n.º 2
0
def main():
    init('local')
    admin_jwt = login("admin", "admin")

    print(admin_jwt)

    register()
    user_jwt = login("1175", "hello")
    user_id = get_id_from_user_me(user_me(user_jwt))
    print(user_id)
    post_article(user_jwt, 'Spring Boot 的 Docker 化实践', "https://tse1-mm.cn.bing.net/th/id/OIP.hClfljxq29JkJrgiwR_v5gAAAA?pid=Api&rs=1",
                 file_util.read_all_text('2020-06-18-Spring Boot 的 Docker 化实践.md'))
Ejemplo n.º 3
0
def me():
    print('me')

    js = file_util.read_all_text('config.json')
    js = json.loads(js)

    users = js['users']

    s = ''

    for user in users:
        print(
            user['username'],
            user['password'],
        )
        serverchans = user['serverchan']
        res, kede = crawl(user['username'], user['password'])
        s += res + '\n'
        for serverchan in serverchans:
            requests.get(
                f'https://sc.ftqq.com/{serverchan}.send?text=电表剩余量{kede}&desp={res}'
            )

    return res
Ejemplo n.º 4
0
        print('test success')
    else:
        print('test failed')


if __name__ == "__main__":
    path_json_files = os.listdir('test_json')
    for path in path_json_files:
        if 'in' in path:
            print(path, end=' ')
    print()
    file_name = input('please input test file name like 1\n')
    path_json = f'test_json/in{file_name}.json'
    print(path_json)

    js = file_util.read_all_text(path_json)
    js = json.loads(js)
    t = js['Time']

    people = []
    for p in js['People']:
        person = algorithm_implement.person()
        person.come_time = p['come_time']
        person.from_floor = p['from_floor']
        person.to_floor = p['to_floor']
        person.current_floor = p['current_floor']
        person.in_which_elevator = p['in_which_elevator']
        person.is_out = p['is_out']

        people.append(person)
    result = algorithm_implement.core_algorithm(t, people)
Ejemplo n.º 5
0

class algorithm_result:
    elevators = []
    people = []

    def to_json(self):
        dict_name_value = {}

        for name, value in vars(self).items():
            dict_name_value[name] = value
        return dict_name_value


if __name__ == "__main__":
    js = file_util.read_all_text('in.json')
    js = json.loads(js)
    t = js['Time']

    people = []
    for p in js['People']:
        person = algorithm_implement.person()
        person.come_time = p['come_time']
        person.from_floor = p['from_floor']
        person.to_floor = p['to_floor']
        person.current_floor = p['current_floor']
        person.in_which_elevator = p['in_which_elevator']
        person.is_out = p['is_out']

        people.append(person)
    result = algorithm_implement.core_algorithm(t, people)
Ejemplo n.º 6
0
import pathlib
import requests
import file_util
import json
import time
import shutil
import json

config = json.loads(file_util.read_all_text('config.json'))

debug = config['debug']

dir_data = pathlib.Path('data')

meta = [["获取所有 DataLog", "get_data_log"], ["发布公告", "send_bulletin"],
        ["查看公告", "get_bulletins"], ["删除公告", "delete_bulletin"]]

if debug:
    host = 'http://localhost:80/api'
else:
    host = 'https://smartlab.backend.117503445.top/api'


def get_data_log():
    print('每次运行脚本都会删除 data 文件夹的所有内容!!!!!')

    global host
    url = f"{host}/DataLog?pageSize=99999"
    print(url)

    if dir_data.exists():
Ejemplo n.º 7
0
def wake_on_lan():
    js = json.loads(file_util.read_all_text('config.json'))
    mac = js['mac']
    broadcast = js['broadcast']
    # print(mac,broadcast)
    send_magic_packet(mac, ip_address=broadcast)