mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-24 03:42:43 -06:00
fix a bit
This commit is contained in:
parent
e72cfbf72c
commit
b5e9a1c4db
2 changed files with 9 additions and 4 deletions
5
demo.py
5
demo.py
|
@ -281,4 +281,9 @@ if __name__ == "__main__":
|
|||
parser.add_argument("--gateway", type=str, help="Override the gateway phone number")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.pdu.startswith("REG-RESP"):
|
||||
print("Invalid REG-RESP PDU")
|
||||
exit(1)
|
||||
|
||||
trio.run(main, args)
|
|
@ -21,7 +21,7 @@ def register(push_token: bytes, no_parse = False, gateway = GATEWAY) -> tuple[st
|
|||
if no_parse:
|
||||
print("Now do the next part and rerun with --pdu")
|
||||
exit()
|
||||
parse_pdu(r, req_id)
|
||||
parse_pdu(r.text, req_id)
|
||||
|
||||
# if r.text.split("?")[0] != "REG-RESP":
|
||||
# raise Exception(f"Failed to register: {r.text}")
|
||||
|
@ -37,10 +37,10 @@ def register(push_token: bytes, no_parse = False, gateway = GATEWAY) -> tuple[st
|
|||
# return resp_params["n"], signature
|
||||
|
||||
def parse_pdu(r: str, req_id: int | None = None):
|
||||
if r.text.split("?")[0] != "REG-RESP":
|
||||
raise Exception(f"Failed to register: {r.text}")
|
||||
if r.split("?")[0] != "REG-RESP":
|
||||
raise Exception(f"Failed to register: {r}")
|
||||
#assert r.text.split("?")[0] == "REG-RESP"
|
||||
resp_params = r.text.split("?")[1]
|
||||
resp_params = r.split("?")[1]
|
||||
resp_params = resp_params.split(";")
|
||||
resp_params = {param.split("=")[0]: param.split("=")[1] for param in resp_params}
|
||||
assert resp_params["v"] == "3"
|
||||
|
|
Loading…
Reference in a new issue