Skip to content

Commit 0fdb1b4

Browse files
author
Tim Schneider
committed
Made RobotWebSession not require a Robot instance as input anymore
1 parent 494d91d commit 0fdb1b4

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

franky/robot_web_session.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import base64
22
import hashlib
3+
import http.client
34
import json
45
import ssl
56
import time
67
import urllib.parse
78
from http.client import HTTPSConnection, HTTPResponse
8-
from typing import TYPE_CHECKING, Dict, Optional, Any, Literal
9+
from typing import Dict, Optional, Any, Literal
910
from urllib.error import HTTPError
1011

11-
if TYPE_CHECKING:
12-
from .robot import Robot
13-
1412

1513
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
1816
self.__username = username
1917
self.__password = password
2018

@@ -52,7 +50,7 @@ def send_control_api_request(self, target: str, headers: Optional[Dict[str, str]
5250
return self.send_api_request(target, headers=_headers, method=method, body=body)
5351

5452
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())
5654
self.__client.connect()
5755
payload = json.dumps(
5856
{"login": self.__username, "password": self.__encode_password(self.__username, self.__password)})
@@ -116,7 +114,6 @@ def unlock_brakes(self):
116114
"/desk/api/joints/unlock", headers={"content-type": "application/x-www-form-urlencoded"})
117115

118116
def lock_brakes(self):
119-
self.__robot.stop()
120117
self.send_control_api_request(
121118
"/desk/api/joints/lock", headers={"content-type": "application/x-www-form-urlencoded"})
122119

0 commit comments

Comments
 (0)