Skip to content

Commit

Permalink
Fixed RobotWebSession.enable_fci
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Schneider committed Sep 24, 2023
1 parent f349310 commit bdbf3a6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions franky/robot_web_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def send_api_request(self, target: str, headers: Optional[Dict[str, str]] = None
def send_control_api_request(self, target: str, headers: Optional[Dict[str, str]] = None,
body: Optional[Any] = None,
method: Literal["GET", "POST", "DELETE"] = "POST"):
if self.__control_token is None:
raise ValueError("Client does not have control. Call take_control() first.")
self.__check_control_token()
_headers = {
"X-Control-Token": self.__control_token
}
Expand All @@ -68,6 +67,10 @@ def __exit__(self, type, value, traceback):
self.__token = None
self.__client.close()

def __check_control_token(self):
if self.__control_token is None:
raise ValueError("Client does not have control. Call take_control() first.")

def take_control(self, wait_timeout: float = 10.0):
if self.__control_token is None:
res = self.send_api_request(
Expand All @@ -91,9 +94,10 @@ def release_control(self):
self.__control_token_id = None

def enable_fci(self):
self.__check_control_token()
self.send_control_api_request(
"/desk/api/system/fci", headers={"content-type": "application/x-www-form-urlencoded"},
body=f"token={urllib.parse.quote(self.__control_token)}")
body=f"token={urllib.parse.quote(base64.b64encode(self.__control_token.encode('ascii')))}")

def has_control(self):
if self.__control_token_id is not None:
Expand Down

0 comments on commit bdbf3a6

Please sign in to comment.