Exemplo n.º 1
0
def restart_lantern():
    try:
        # print('正在重启蓝灯.....')
        os.popen('open -a Lantern.app')
        time.sleep(5)
        # 最小化窗口
        os.popen('osascript hide.scpt')
    except Exception as e:
        print('exception.....')
        pass
    else:
        # print('return.......')
        return 'lanten_restart_success'
Exemplo n.º 2
0
def login_ten_times():
	# 重试十次,每次间隔 5 秒
	num = 10;
	state = ''
	while 0 != num:
		state = auto_login()
		num = num -1
		if state == 'success' or state == 'already_login':
			return state
		else:
			print('正在发起新的请求.......')
			time.sleep(5)
			continue
	return state
Exemplo n.º 3
0
def restart_lantern_and_relogin():
    restart_lantern.kill_lantern()
    # 修改完成后登陆
    state = login.login_ten_times()
    if state == 'success' or state == 'already_login':
        time.sleep(1)
        print('登录成功,即将重启蓝灯,可能需要您输入密码')
        state = restart_lantern.restart_lantern()
        print(state)
        time.sleep(1)
        if state == 'lanten_restart_success':
            print('重启蓝灯成功!')
        else:
            print('重启蓝灯失败')
    else:
        print(state)
        print('登录函数返回值异常')
Exemplo n.º 4
0
def kill_and_restart_lantern():
    kill_lantern()
    time.sleep(4)
    restart_lantern()