Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbeliaev: dry run and exception handling #289

Merged
merged 7 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ package.
* [Promote Docker image](#promote-docker-image)
* [Builds](#builds)
* [Logging](#logging)
* [Exception handling](#exception-handling)
- [Admin area](#admin-area)
* [User](#user)
+ [API Keys](#api-keys)
Expand Down Expand Up @@ -418,6 +419,9 @@ http://example.com/artifactory/published/production/foo-0.0.1.pom
http://example.com/artifactory/published/production/product-1.0.0.tar.gz
http://example.com/artifactory/published/production/product-1.0.0.tar.pom
"""

# you can use dry run just to check if command will succeed without real change, adds debug message
source.copy(dest, dry_run=True)
```

## Move Artifacts
Expand All @@ -436,6 +440,9 @@ source = ArtifactoryPath("http://example.com/artifactory/builds/product/product/
dest = ArtifactoryPath("http://example.com/artifactory/published/production/")

source.move(dest)

# you can use dry run just to check if command will succeed without real change, adds debug message
source.move(dest, dry_run=True)
```

## Remove Artifacts
Expand Down Expand Up @@ -667,6 +674,27 @@ path = ArtifactoryPath(
)
~~~

## Exception handling
Exceptions in this library are represented by `dohq_artifactory.exception.ArtifactoryException` or by `OSError`
If exception was caused by HTTPError you can always drill down the root cause by using following example:
~~~python
from artifactory import ArtifactoryPath
from dohq_artifactory.exception import ArtifactoryException

path = ArtifactoryPath(
"http://my_arti:8080/artifactory/installer/",
auth=("wrong_user", "wrong_pass")
)

try:
path.stat()
except ArtifactoryException as exc:
print(exc) # clean artifactory error message
# >>> Bad credentials
print(exc.__cause__) # HTTP error that triggered exception, you can use this object for more info
# >>> 401 Client Error: Unauthorized for url: http://my_arti:8080/artifactory/installer/
~~~

# Admin area
You can manipulate with user\group\repository and permission. First, create `ArtifactoryPath` object without a repository
```python
Expand Down
Loading