4

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?

Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
KKO
  • 1,913
  • 3
  • 27
  • 35

2 Answers2

5

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.

FkYkko
  • 1,015
  • 1
  • 12
  • 18
KKO
  • 1,913
  • 3
  • 27
  • 35
1

You might want to take look at Party, either look on how they do it, or just use it directly.

JBaruch
  • 22,610
  • 5
  • 62
  • 90