Skip to content

Commit

Permalink
Merge pull request #289 from beliaev-maksim/mbeliaev/copy2
Browse files Browse the repository at this point in the history
mbeliaev: dry run and exception handling
  • Loading branch information
allburov authored Oct 6, 2021
2 parents 70d7882 + 6f5141c commit 37cc72d
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 102 deletions.
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

0 comments on commit 37cc72d

Please sign in to comment.