Example #1
0
    parser.add_argument("-P", "--password", help="set the password")
    parser.add_argument("--remote-disable", help="disable remote control")
    parser.add_argument("-b", "--base-path", help="base path for web app",default="/")
    parser.parse_args()
    return parser


if __name__ == "__main__":
    if sys.version_info < (3, 6):
        raise RuntimeError("This application requires Python 3.6+")
    parser = parse_args()
    args = parser.parse_args()
    my_logger(handler_level=args.debug)
    logger.info("server start")
    if args.config:
        web.app.myp = MyPSACC.load_config(name=args.config.name)
    else:
        web.app.myp = MyPSACC.load_config()
    atexit.register(web.app.myp.save_config)
    if args.record:
        web.app.myp.set_record(True)
    try:
        web.app.myp.manager._refresh_token()
    except OAuthError:
        if args.mail and args.password:
            client_email = args.mail
            client_password = args.password
        else:
            client_email = input("mypeugeot email: ")
            client_password = input("mypeugeot password: ")
        web.app.myp.connect(client_email, client_password)
            "Version": "1.27.0"
        },
        cert=("certs/public.pem", "certs/private.pem"),
    )

    res_dict = res2.json()["success"]
    customer_id = BRAND[package_name]["brand_code"] + "-" + res_dict["id"]

except:
    traceback.print_exc()
    print(res2.text)
    sys.exit(1)

# Psacc

psacc = MyPSACC(None, client_id, client_secret, remote_refresh_token, customer_id, BRAND[package_name]["realm"],
                country_code)
psacc.connect(client_email, client_password)

os.chdir(current_dir)
psacc.save_config(name="test.json")
res = psacc.get_vehicles()

for vehicle in res_dict["vehicles"]:
    label = vehicle["short_label"].split(" ")[-1]
    car = psacc.vehicles_list.get_car_by_vin(vehicle["vin"])
    if car.label == "unknown":
        car.label = label
        car.set_energy_capacity()
psacc.vehicles_list.save_cars()

print(f"\nYour vehicles: {res}")
    customer_id_enc = getxmlvalue(root, "CRYPTED_CUSTOMER_ID")
    customer_id = base64.b64decode(customer_id_enc).decode('utf-8')

    root = ET.parse("HUTokenManager.xml").getroot()
    remote_enc = root[0].text
    remote_refresh_token = json.loads(
        base64.b64decode(remote_enc))["refresh_token"]

client_email = input("mypeugeot email: ")
client_paswword = input("mypeugeot password: "******"What is the car api realm : clientsB2CPeugeot, clientsB2CDS, clientsB2COpel, clientsB2CVauxhall\n"
)
psacc = MyPSACC(None,
                client_id,
                client_secret,
                remote_refresh_token,
                customer_id,
                realm=client_realm)
psacc.connect(client_email, client_paswword)

os.chdir(current_dir)
psacc.save_config(name="test.json")
res = psacc.get_vehicles()
print(f"\nYour vehicles: {res}")

if not argv[1].endswith(".apk"):
    os.remove("backup.tar")
    shutil.rmtree('apps')
    charge_controls = ChargeControls()
    for vin, vehicle in res.items():
        chc = ChargeControl(None, vin, 100, [0, 0])
Example #4
0
def save_config(my_peugeot: MyPSACC, name):
    my_peugeot.save_config(name)
    threading.Timer(30, save_config, args=[my_peugeot, name]).start()
Example #5
0
if __name__ == "__main__":
    if sys.version_info < (3, 6):
        raise RuntimeError("This application requires Python 3.6+")
    parser = parse_args()
    args = parser.parse_args()
    try:
        args.debug = int(args.debug)
    except ValueError:
        pass
    my_logger(handler_level=args.debug)
    logger.info("server start")
    if args.config:
        config_name = args.config.name
    else:
        config_name = "config.json"
    web.app.myp = MyPSACC.load_config(name=config_name)
    atexit.register(web.app.myp.save_config)
    if args.record:
        web.app.myp.set_record(True)
    if args.offline:
        logger.info("offline mode")
    else:
        try:
            web.app.myp.manager._refresh_token()
        except OAuthError:
            if args.mail and args.password:
                client_email = args.mail
                client_password = args.password
            else:
                client_email = input("mypeugeot email: ")
                client_password = input("mypeugeot password: ")
Example #6
0
def save_config(my_peugeot: MyPSACC):
    my_peugeot.save_config()
    threading.Timer(30, save_config, args=[my_peugeot]).start()