|
1 | 1 | import base64
|
2 | 2 | import hashlib
|
| 3 | +import http.client |
3 | 4 | import json
|
4 | 5 | import ssl
|
5 | 6 | import time
|
6 | 7 | import urllib.parse
|
7 | 8 | from http.client import HTTPSConnection, HTTPResponse
|
8 |
| -from typing import TYPE_CHECKING, Dict, Optional, Any, Literal |
| 9 | +from typing import Dict, Optional, Any, Literal |
9 | 10 | from urllib.error import HTTPError
|
10 | 11 |
|
11 |
| -if TYPE_CHECKING: |
12 |
| - from .robot import Robot |
13 |
| - |
14 | 12 |
|
15 | 13 | class RobotWebSession:
|
16 |
| - def __init__(self, robot: "Robot", username: str, password: str): |
17 |
| - self.__robot = robot |
| 14 | + def __init__(self, fci_hostname: str, username: str, password: str): |
| 15 | + self.__fci_hostname = fci_hostname |
18 | 16 | self.__username = username
|
19 | 17 | self.__password = password
|
20 | 18 |
|
@@ -52,7 +50,7 @@ def send_control_api_request(self, target: str, headers: Optional[Dict[str, str]
|
52 | 50 | return self.send_api_request(target, headers=_headers, method=method, body=body)
|
53 | 51 |
|
54 | 52 | def __enter__(self):
|
55 |
| - self.__client = HTTPSConnection(self.__robot.fci_hostname, timeout=12, context=ssl._create_unverified_context()) |
| 53 | + self.__client = HTTPSConnection(self.__fci_hostname, timeout=12, context=ssl._create_unverified_context()) |
56 | 54 | self.__client.connect()
|
57 | 55 | payload = json.dumps(
|
58 | 56 | {"login": self.__username, "password": self.__encode_password(self.__username, self.__password)})
|
@@ -116,7 +114,6 @@ def unlock_brakes(self):
|
116 | 114 | "/desk/api/joints/unlock", headers={"content-type": "application/x-www-form-urlencoded"})
|
117 | 115 |
|
118 | 116 | def lock_brakes(self):
|
119 |
| - self.__robot.stop() |
120 | 117 | self.send_control_api_request(
|
121 | 118 | "/desk/api/joints/lock", headers={"content-type": "application/x-www-form-urlencoded"})
|
122 | 119 |
|
|
0 commit comments