Artifactory (parallels/artifactory)

0.1.17 · abandoned · verified Thu Apr 16

The `artifactory` library, currently at version 0.1.17, provides a Python interface for interacting with JFrog Artifactory. It's designed as a pathlib-like module for object-oriented path manipulations for Artifactory resources. However, this repository is largely unmaintained and considered outdated, with an active fork (`dohq-artifactory` / `pyartifactory`) being the recommended alternative for modern Python environments. It has a very slow release cadence, with the last release being 0.1.17.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `ArtifactoryPath` with basic authentication using environment variables and perform common operations like creating a path and deploying an artifact. It simulates deploying a file to a specified Artifactory repository.

import os
from artifactory import ArtifactoryPath

ART_URL = os.environ.get('ARTIFACTORY_URL', 'http://localhost:8081/artifactory')
ART_USER = os.environ.get('ARTIFACTORY_USERNAME', 'admin')
ART_PASS = os.environ.get('ARTIFACTORY_PASSWORD', 'password') # Or API key

try:
    # Initialize ArtifactoryPath for a repository with authentication
    # Note: For security, use environment variables or a config file for credentials.
    repo_path = ArtifactoryPath(
        f"{ART_URL}/my-local-repo", 
        auth=(ART_USER, ART_PASS)
    )
    
    # Create a directory (if it doesn't exist)
    repo_path.mkdir()
    print(f"Successfully connected and accessed: {repo_path}")

    # Example: Deploy a dummy file
    dummy_content = b"This is a test artifact."
    artifact_name = "test_artifact.txt"
    artifact_path = repo_path / artifact_name

    with open(artifact_name, "wb") as f:
        f.write(dummy_content)
    
    artifact_path.deploy_file(artifact_name)
    print(f"Deployed artifact: {artifact_path}")
    
    # Clean up local dummy file
    os.remove(artifact_name)

    # Example: List contents of the repository
    print(f"\nContents of {repo_path}:")
    for item in repo_path:
        print(item)

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure Artifactory is running and accessible, and credentials are correct.")

view raw JSON →