Search code examples
pythondeploymentpy2exeartifactoryartifact

Deploy to artifactory via python script


I am trying to create a python script that can deploy an artifact to Artifactory. I am using Python 3.4 and I want the resulted script to put it through py2exe, so external libraries might create issues.

Through all my research, I found that one way is this, but I don't know how to "translate" it to Python:

curl -X PUT -u user:password --data-binary @/absolute/path/my-utils-2.3.jar "http://localhost/artifactory/my-repo/my/utils/2.3/"

How can I achieve that into Python? Or is it any either way for deploying?


Solution

  • Been trying the whole day and I've had some successful testing using the requests library.

    import requests
    
    url = "repo/path/test.txt"
    
        file_name = "test.txt"
        auth=(USERNAME, PASSWORD)
        
      
        with open(file_name, 'rb') as fobj:
            res = requests.put(url, auth=auth, data=fobj)
            print(res.text)
            print(res.status_code)
    

    And py2exe had no issues with it.