Skip to content

Commit

Permalink
Merge pull request #89 from superfaceai/doc/python_readme
Browse files Browse the repository at this point in the history
More pythonic example in docs
  • Loading branch information
freaz authored Aug 15, 2023
2 parents 2a72df7 + 00aa929 commit f25f6c6
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions host/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ The final structure should look like this:
Create `__main__.py` file with following content and update:

```py
import os

import sys
from one_sdk import OneClient, PerformError, UnexpectedError

client = OneClient()

profile = client.get_profile("<profileName>")
use_case = profile.get_usecase("<usecaseName>")
try:
Expand All @@ -101,13 +99,10 @@ try:
}
)
print(f"RESULT: {r}")
except Exception as e:
if isinstance(e, PerformError):
print(f"ERROR RESULT: {e.error_result}")
elif isinstance(e, UnexpectedError):
print(f"ERROR:", e, file=sys.stderr)
else:
raise e
except PerformError as e:
print(f"ERROR RESULT: {e.error_result}")
except UnexpectedError as e:
print(f"ERROR:", e, file = sys.stderr)
finally:
client.send_metrics_to_superface()
```
Expand Down

0 comments on commit f25f6c6

Please sign in to comment.