File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change 5
5
import click
6
6
import httpx
7
7
8
+ from ..._utils ._errors import handle_errors
8
9
from .._utils ._console import ConsoleLogger
9
10
from ._models import TenantsAndOrganizationInfoResponse , TokenData
10
11
from ._oidc_utils import get_auth_config
@@ -49,21 +50,15 @@ def update_token_data(self, token_data: TokenData):
49
50
50
51
def get_tenants_and_organizations (self ) -> TenantsAndOrganizationInfoResponse :
51
52
url = f"https://{ self .domain } .uipath.com/{ self .prt_id } /portal_/api/filtering/leftnav/tenantsAndOrganizationInfo"
52
- response = client .get (
53
- url , headers = {"Authorization" : f"Bearer { self .access_token } " }
54
- )
55
- if response .status_code < 400 :
53
+ headers = {"Authorization" : f"Bearer { self .access_token } " }
54
+
55
+ with handle_errors ():
56
+ response = client .get (url , headers = headers )
57
+
56
58
result = response .json ()
57
59
self ._tenants_and_organizations = result
60
+
58
61
return result
59
- elif response .status_code == 401 :
60
- console .error ("Unauthorized" )
61
- else :
62
- console .error (
63
- f"Failed to get tenants and organizations: { response .status_code } { response .text } "
64
- )
65
- # Can't reach here, console.error exits, linting
66
- raise Exception ("Failed to get tenants" )
67
62
68
63
def get_uipath_orchestrator_url (self ) -> str :
69
64
if self ._tenants_and_organizations is None :
Original file line number Diff line number Diff line change 6
6
import httpx
7
7
from dotenv import load_dotenv
8
8
9
+ from .._utils ._errors import handle_errors
9
10
from ._utils ._common import get_env_vars
10
11
from ._utils ._console import ConsoleLogger
11
12
from ._utils ._folders import get_personal_workspace_info
@@ -121,7 +122,7 @@ def publish(feed):
121
122
else :
122
123
url = url + "?feedId=" + feed
123
124
124
- with open (package_to_publish_path , "rb" ) as f :
125
+ with open (package_to_publish_path , "rb" ) as f , handle_errors () :
125
126
files = {"file" : (package_to_publish_path , f , "application/octet-stream" )}
126
127
response = client .post (url , headers = headers , files = files )
127
128
You can’t perform that action at this time.
0 commit comments