A Python to Artifactory interface
Project description
Python interface library for Jfrog Artifactory
==============================================
|Build Status|
This module is intended to serve as a logical descendant of
`pathlib <https://docs.python.org/3/library/pathlib.html>`__, a Python 3
module for object-oriented path manipulations. As such, it implements
everything as closely as possible to the origin with few exceptions,
such as stat().
Usage Examples
==============
Walking Directory Tree
----------------------
Getting directory listing:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/gradle-ivy-local")
for p in path:
print p
Find all .gz files in current dir, recursively:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/distributions/org/")
for p in path.glob("**/*.gz"):
print p
Downloading Artifacts
---------------------
Download artifact to a local filesystem:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/distributions/org/apache/tomcat/apache-tomcat-7.0.11.tar.gz")
with path.open() as fd:
with open("tomcat.tar.gz", "wb") as out:
out.write(fd.read())
Uploading Artifacts
-------------------
Deploy a regular file ``myapp-1.0.tar.gz``
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0")
path.mkdir()
path.deploy_file('./myapp-1.0.tar.gz')
Deploy a debian package ``myapp-1.0.deb``
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/ubuntu-local/pool")
path.deploy_deb('./myapp-1.0.deb',
distribution='trusty',
component='main',
architecture='amd64')
Authentication
--------------
To provide username and password to access restricted resources, you can
pass ``auth`` parameter to ArtifactoryPath:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/myrepo/restricted-path",
auth=('admin', 'ilikerandompasswords'))
path.touch()
SSL Cert Verification Options
-----------------------------
See `Requests - SSL
verification <http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification>`__
for more details.
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0")
... is the same as
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
verify=True)
Specify a local cert to use as client side certificate
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
cert="/path_to_file/server.pem")
Disable host cert verification
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
verify=False)
| **Note:** If host cert verification is disabled urllib3 will throw a
`InsecureRequestWarning <https://urllib3.readthedocs.org/en/latest/security.html#insecurerequestwarning>`__.
| To disable these warning, one needs to call
urllib3.disable\_warnings().
.. code:: python
import requests.packages.urllib3 as urllib3
urllib3.disable_warnings()
Global Configuration File
-------------------------
Artifactory Python module also has a way to specify all
connection-related settings in a central file,
``~/.artifactory_python.cfg`` that is read upon the creation of first
``ArtifactoryPath`` object and is stored globally. For instance, you can
specify per-instance settings of authentication tokens, so that you
won't need to explicitly pass ``auth`` parameter to ``ArtifactoryPath``.
Example:
.. code:: ini
[http://artifactory-instance.com/artifactory]
username = deployer
password = ilikerandompasswords
verify = false
[another-artifactory-instance.com/artifactory]
username = foo
password = @dmin
cert = ~/mycert
Whether or not you specify ``http://`` or ``https://`` prefix is not
essential. The module will first try to locate the best match and then
try to match URLs without prefixes. So if in the config you specify
``https://my-instance.local`` and call ``ArtifactoryPath`` with
``http://my-instance.local``, it will still do the right thing.
.. |Build Status| image:: https://travis-ci.org/Parallels/artifactory.svg?branch=develop
:target: https://travis-ci.org/Parallels/artifactory
==============================================
|Build Status|
This module is intended to serve as a logical descendant of
`pathlib <https://docs.python.org/3/library/pathlib.html>`__, a Python 3
module for object-oriented path manipulations. As such, it implements
everything as closely as possible to the origin with few exceptions,
such as stat().
Usage Examples
==============
Walking Directory Tree
----------------------
Getting directory listing:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/gradle-ivy-local")
for p in path:
print p
Find all .gz files in current dir, recursively:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/distributions/org/")
for p in path.glob("**/*.gz"):
print p
Downloading Artifacts
---------------------
Download artifact to a local filesystem:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/distributions/org/apache/tomcat/apache-tomcat-7.0.11.tar.gz")
with path.open() as fd:
with open("tomcat.tar.gz", "wb") as out:
out.write(fd.read())
Uploading Artifacts
-------------------
Deploy a regular file ``myapp-1.0.tar.gz``
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0")
path.mkdir()
path.deploy_file('./myapp-1.0.tar.gz')
Deploy a debian package ``myapp-1.0.deb``
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/ubuntu-local/pool")
path.deploy_deb('./myapp-1.0.deb',
distribution='trusty',
component='main',
architecture='amd64')
Authentication
--------------
To provide username and password to access restricted resources, you can
pass ``auth`` parameter to ArtifactoryPath:
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/myrepo/restricted-path",
auth=('admin', 'ilikerandompasswords'))
path.touch()
SSL Cert Verification Options
-----------------------------
See `Requests - SSL
verification <http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification>`__
for more details.
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0")
... is the same as
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
verify=True)
Specify a local cert to use as client side certificate
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
cert="/path_to_file/server.pem")
Disable host cert verification
.. code:: python
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://my-artifactory/artifactory/libs-snapshot-local/myapp/1.0",
verify=False)
| **Note:** If host cert verification is disabled urllib3 will throw a
`InsecureRequestWarning <https://urllib3.readthedocs.org/en/latest/security.html#insecurerequestwarning>`__.
| To disable these warning, one needs to call
urllib3.disable\_warnings().
.. code:: python
import requests.packages.urllib3 as urllib3
urllib3.disable_warnings()
Global Configuration File
-------------------------
Artifactory Python module also has a way to specify all
connection-related settings in a central file,
``~/.artifactory_python.cfg`` that is read upon the creation of first
``ArtifactoryPath`` object and is stored globally. For instance, you can
specify per-instance settings of authentication tokens, so that you
won't need to explicitly pass ``auth`` parameter to ``ArtifactoryPath``.
Example:
.. code:: ini
[http://artifactory-instance.com/artifactory]
username = deployer
password = ilikerandompasswords
verify = false
[another-artifactory-instance.com/artifactory]
username = foo
password = @dmin
cert = ~/mycert
Whether or not you specify ``http://`` or ``https://`` prefix is not
essential. The module will first try to locate the best match and then
try to match URLs without prefixes. So if in the config you specify
``https://my-instance.local`` and call ``ArtifactoryPath`` with
``http://my-instance.local``, it will still do the right thing.
.. |Build Status| image:: https://travis-ci.org/Parallels/artifactory.svg?branch=develop
:target: https://travis-ci.org/Parallels/artifactory
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
artifactory-0.1.10.tar.gz
(14.3 kB
view details)
File details
Details for the file artifactory-0.1.10.tar.gz
.
File metadata
- Download URL: artifactory-0.1.10.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5ad11a153a566189ee1579c3e2ea520d92c9ce92f2b3589b4559e6b9b069d5c |
|
MD5 | df824bf92658888272f295d468cad21f |
|
BLAKE2b-256 | 2ab0dcf484e6032421f3b2b10492262c87f836f644a652262c125c6aa576cab5 |