Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwagnerdev committed Nov 11, 2024
1 parent 6288122 commit eb77415
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 33 deletions.
3 changes: 1 addition & 2 deletions examples/01_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@


my_instance = Instance(
url=os.getenv("WANDELAPI_BASE_URL"),
access_token=os.getenv("NOVA_ACCESS_TOKEN"),
url=os.getenv("WANDELAPI_BASE_URL"), access_token=os.getenv("NOVA_ACCESS_TOKEN")
)

my_robot = MotionGroup(
Expand Down
3 changes: 1 addition & 2 deletions examples/02_plan_and_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@


my_instance = Instance(
url=os.getenv("WANDELAPI_BASE_URL"),
access_token=os.getenv("NOVA_ACCESS_TOKEN"),
url=os.getenv("WANDELAPI_BASE_URL"), access_token=os.getenv("NOVA_ACCESS_TOKEN")
)

my_robot = MotionGroup(
Expand Down
3 changes: 1 addition & 2 deletions examples/03_plan_and_execute_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@


my_instance = Instance(
url=os.getenv("WANDELAPI_BASE_URL"),
access_token=os.getenv("NOVA_ACCESS_TOKEN"),
url=os.getenv("WANDELAPI_BASE_URL"), access_token=os.getenv("NOVA_ACCESS_TOKEN")
)

my_robot = MotionGroup(
Expand Down
3 changes: 1 addition & 2 deletions examples/04_execute_in_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@


my_instance = Instance(
url=os.getenv("WANDELAPI_BASE_URL"),
access_token=os.getenv("NOVA_ACCESS_TOKEN"),
url=os.getenv("WANDELAPI_BASE_URL"), access_token=os.getenv("NOVA_ACCESS_TOKEN")
)

my_robot = MotionGroup(
Expand Down
3 changes: 1 addition & 2 deletions examples/05_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
"outputs": [],
"source": [
"my_instance = Instance(\n",
" url=os.getenv(\"WANDELAPI_BASE_URL\"),\n",
" access_token=os.getenv(\"NOVA_ACCESS_TOKEN\"),\n",
" url=os.getenv(\"WANDELAPI_BASE_URL\"), access_token=os.getenv(\"NOVA_ACCESS_TOKEN\")\n",
")\n",
"\n",
"motion_groups = motion_group_api.get_active_motion_groups(\n",
Expand Down
4 changes: 1 addition & 3 deletions wandelbots/core/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def _parse_url(self, host: str) -> str:
_url = host.rstrip("/")

if self.has_access_token() and self.has_basic_auth():
raise ValueError(
"please choose either user and password or access token access"
)
raise ValueError("please choose either user and password or access token access")

if _url.startswith("https"):
if not self.has_auth():
Expand Down
13 changes: 4 additions & 9 deletions wandelbots/request/asyncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def _get_auth_header(instance: Instance) -> Optional[Dict[str, str]]:

def _get_auth(instance: Instance) -> Optional[httpx.BasicAuth]:
if instance.has_basic_auth():
return requests.auth.HTTPBasicAuth(
username=instance.user, password=instance.password
)
return requests.auth.HTTPBasicAuth(username=instance.user, password=instance.password)
return None


Expand Down Expand Up @@ -61,9 +59,7 @@ async def delete(url: str, instance: Instance) -> int:
return 500


async def post(
url: str, instance: Instance, data: Dict = {}
) -> Tuple[int, Optional[Dict]]:
async def post(url: str, instance: Instance, data: Dict = {}) -> Tuple[int, Optional[Dict]]:
async with httpx.AsyncClient(
headers=_get_auth_header(instance), auth=_get_auth(instance)
) as client:
Expand All @@ -75,9 +71,8 @@ async def post(
_handle_request_error(err)
return 500, None

async def put(
url: str, instance: Instance, data: Dict = {}
) -> Tuple[int, Optional[Dict]]:

async def put(url: str, instance: Instance, data: Dict = {}) -> Tuple[int, Optional[Dict]]:
async with httpx.AsyncClient(
headers=_get_auth_header(instance), auth=_get_auth(instance)
) as client:
Expand Down
14 changes: 3 additions & 11 deletions wandelbots/request/syncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ def _get_auth_header(instance: Instance) -> Optional[Dict[str, str]]:

def _get_auth(instance: Instance) -> Optional[httpx.BasicAuth]:
if instance.has_basic_auth():
return requests.auth.HTTPBasicAuth(
username=instance.user, password=instance.password
)
return requests.auth.HTTPBasicAuth(username=instance.user, password=instance.password)
return None


Expand All @@ -39,10 +37,7 @@ def _handle_request_error(err):
def get(url: str, instance: Instance) -> Tuple[int, Optional[Dict]]:
try:
response = requests.get(
url,
timeout=TIMEOUT,
headers=_get_auth_header(instance),
auth=_get_auth(instance),
url, timeout=TIMEOUT, headers=_get_auth_header(instance), auth=_get_auth(instance)
)
response.raise_for_status()
return response.status_code, response.json()
Expand All @@ -54,10 +49,7 @@ def get(url: str, instance: Instance) -> Tuple[int, Optional[Dict]]:
def delete(url: str, instance: Instance) -> int:
try:
response = requests.delete(
url,
timeout=TIMEOUT,
headers=_get_auth_header(instance),
auth=_get_auth(instance),
url, timeout=TIMEOUT, headers=_get_auth_header(instance), auth=_get_auth(instance)
)
response.raise_for_status()
return response.status_code
Expand Down

0 comments on commit eb77415

Please sign in to comment.