parallels / artifactory Goto Github PK
View Code? Open in Web Editor NEWA Python client for Artifactory
License: MIT License
A Python client for Artifactory
License: MIT License
Currently the PyPi page of artifactory.py looks very clumsy. Need to at least add proper formatting.
Curently there is an argument in deploy_file, called 'parameters' that one can use to specify additional metadata to attach to the file.
deploy_deb lacks this option, which is inconvenient
Help us poor guys using CentOS/RHEL :)
I am running into an issue in artifactory 0.1.17 on python 2.7.14 (32 bit).
The code parsed.append(intern(x))
in pathlib._Flavour.parse_parts()
is raising the exception TypeError: intern() argument 1 must be string, not unicode
.
I found that this is ultimately due to configparser.ConfigParser.read()
in artifactory.read_config()
returning unicode strings, but those are never converted via str(s)
anywhere.
I was able to workaround this with the following code:
import artifactory
# fix for bug in artifactory module, caused by unicode/str issues
artifactory.read_global_config()
new_config = {}
for section in artifactory.global_config:
new_config[str(section)] = artifactory.global_config[section]
artifactory.global_config[section] = None
artifactory.global_config = new_config
Hi,
I am trying to upload via the deploy_file method, and i had issue uploading through a virtual repository with error "404, Not found", what does not make sense because i am trying to upload a new file that he shouldn't be exists any way.
So after debugging the error trace back i found that in the API when i try to reach a file is not exists, i had different behavior if it is virtual repo or not;
in regular repository i get this:
{ "errors" : [ { "status" : 404, "message" : "Unable to find item" } ] }
however in the virtual repository i get a different error message:
{ "errors" : [ { "status" : 404, "message" : "Not Found" } ] }
And the library method artifactory.py in get_stat_json (Line 457),
if code == 404 and "Unable to find item" in text:
Which make this condition not working in virtual repository.
Thank you very much.
If a path has double slashes (e.g. http://artifactory:8081/artifactory//something/artifact.jar) then, assuming that the artifact does actually exist, ArtifactoryPath.exists() will return True.
However, when open() is called on the same path, it will fail with RuntimeError: 404
Obviously it would make life easier if open() would succeed on such a call, but barring this exists() should fail so that it is possible to check for artifacts without actually trying to open them.
I am trying to download snapshot artifacts and stat data about them from my Artifactory. While everything else is working, I cannot get this to work. Is there a way to do this?
Example that works with wget:
http://somewhere.com:8090/artifactory/libs-snapshot-local/com/company/foo/bar/foobar-artifact/0.1-master-SNAPSHOT/foobar-artifacts-0.1-master-SNAPSHOT.py
If this is not possible, I would like to make it so.
The latest code in pathlib makes Path iterable, using the following code:
def __iter__(self):
"""Iterate over the files in this directory. Does not yield any
result for the special paths '.' and '..'.
"""
if self._closed:
self._raise_closed()
for name in self._accessor.listdir(self):
if name in {'.', '..'}:
# Yielding a path object for these makes little sense
continue
yield self._make_child_relpath(name)
if self._closed:
self._raise_closed()
I think ArtifactoryPath should implement this interface too
AQL is a very important feature of aritfactory.
Why not add its suppport?
When I use the Locust performance test tool (see Locust.io) with the Artifactory Python package it will collect and stats. Other than that works fine.
I am using Locust 1.4.4., WIN7 , 16GB on a VM.
If I have following files in the artifactory:
package.tgz
package.tgz.sha1
package.tgz.md5
only first one will be listed using example for here:
https://pypi.org/project/artifactory/0.1.17/
from artifactory import ArtifactoryPath path = ArtifactoryPath( "http://repo.jfrog.org/artifactory/gradle-ivy-local") for p in path: print p
artifact = ArtifactoryPath( url, auth=auth)
changes https://whatever... to https:/whatever... (removing one forward slash) after which the library renders unusable.
I am using JFrog's artifactoryonline SaaS service with a repository url like:
https://mycompany.artifactoryonline.com/(mycompany)/path/to/artifacts
Notice that the root (in parenthesis) is the name of my company and not 'artifactory' as is hardcoded in the module.
I would suggest that the root value become a configurable item. Thank you.
Hello,
Any way to remove a complete folder?
I am trying using path.unlink() but it is displayed an Operation not Permited error.
Thanks in advance
Hello,
According to the PyPI doc the latest python version artifactory 0.1.17 supports is python 3.3.
Does it also supports python 3.11x?
if no, is there any plan of supporting it?
PyPI shows 0.1.14 available, but only 0.1.13 is able to be installed via pip.
(archtype) C:\Dev\arch>pip install artifactory==45.1.0
Collecting artifactory==45.1.0
Could not find a version that satisfies the requirement artifactory==45.1.0 (from versions: 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.6, 0.1.7, 0.1.9, 0.1.10, 0.1.11, 0.1.12, 0.1.13)
No matching distribution found for artifactory==45.1.0
(archtype) C:\Dev\arch>pip show -f artifactory
---
Metadata-Version: 2.0
Name: artifactory
Version: 0.1.13
Summary: A Python to Artifactory interface
Home-page: http://github.com/parallels/artifactory
Author: Konstantin Nazarov
Author-email: [email protected]
License: MIT License
Location: c:\python\.virtualenvs\archtype\lib\site-packages
Requires: requests, python-dateutil, pathlib
Classifiers:
Development Status :: 3 - Alpha
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.2
Programming Language :: Python :: 3.3
Topic :: Software Development :: Libraries
Topic :: System :: Filesystems
Files:
__pycache__\artifactory.cpython-35.pyc
artifactory-0.1.13.dist-info\DESCRIPTION.rst
artifactory-0.1.13.dist-info\METADATA
artifactory-0.1.13.dist-info\RECORD
artifactory-0.1.13.dist-info\WHEEL
artifactory-0.1.13.dist-info\metadata.json
artifactory-0.1.13.dist-info\top_level.txt
artifactory.py
You can specify multiple layouts when uploading packages, i.e.
pool/libatk1.0_i386.deb;deb.distribution=precise;deb.distribution=trusty;deb.component=main;deb.component=contrib;deb.architecture=i386;deb.architecture=64bit-arm
Can we please support this?
It would be great if you could document the differences between this libary and the other existing one namd Party - https://pypi.python.org/pypi/Party/
How do they compare, pros, cons, maybe policy regarding accepting contributions.
I am asking this because I do want to pick one and probably I will want to contribute to it and I want to make a good pick and not having to maintain my own fork. As a side not, on open-source world is good to document about "competition" :)
I'm trying to use this module using the following trivial code (taken from examples):
#!/usr/bin/env python3
import artifactory
path = artifactory.ArtifactoryPath('https://mycompany.artifactoryonline.com/mycompany/some-repo')
for p in path:
print(p)
Note, we use JFrog Artifactory as a SaaS. Without any config file (i.e. ~/.artifactory_python.cfg
) it gives me the following error:
Traceback (most recent call last):
File "./a.py", line 7, in <module>
for p in path:
File "/work/GitHub/artifactory/artifactory.py", line 990, in __iter__
for name in self._accessor.listdir(self):
File "/work/GitHub/artifactory/artifactory.py", line 546, in listdir
stat = self.stat(pathobj)
File "/work/GitHub/artifactory/artifactory.py", line 492, in stat
jsn = self.get_stat_json(pathobj)
File "/work/GitHub/artifactory/artifactory.py", line 467, in get_stat_json
cert=pathobj.cert)
File "/work/GitHub/artifactory/artifactory.py", line 415, in rest_get
cert=cert)
File "/usr/lib64/python3.5/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib64/python3.5/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib64/python3.5/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib64/python3.5/site-packages/requests/sessions.py", line 590, in send
adapter = self.get_adapter(url=request.url)
File "/usr/lib64/python3.5/site-packages/requests/sessions.py", line 672, in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '/api/storage/https:/mycompany.artifactoryonline.com/mycompany/some-repo'
If I'm going to add the config file:
[https://mycompany.artifactoryonline.com/mycompany/]
username = myuser
password = mypass
verify = false
it throws another error:
Traceback (most recent call last):
File "./a.py", line 7, in <module>
for p in path:
File "/work/GitHub/artifactory/artifactory.py", line 990, in __iter__
for name in self._accessor.listdir(self):
File "/work/GitHub/artifactory/artifactory.py", line 546, in listdir
stat = self.stat(pathobj)
File "/work/GitHub/artifactory/artifactory.py", line 492, in stat
jsn = self.get_stat_json(pathobj)
File "/work/GitHub/artifactory/artifactory.py", line 464, in get_stat_json
str(pathobj.relative_to(pathobj.drive)).strip('/')])
File "/work/GitHub/artifactory/artifactory.py", line 929, in relative_to
obj = super(ArtifactoryPath, self).relative_to(*other)
File "/usr/lib64/python3.5/pathlib.py", line 864, in relative_to
.format(str(self), str(formatted)))
ValueError: 'https://mycompany.artifactoryonline.com/mycompany/some-repo/' does not start with 'https:/mycompany.artifactoryonline.com/mycompany'
I would really appreciate if someone point me on my mistake, but actually I think it is a bug…
PS. As one may notice, I'm using Python 3.5, with pathlib
builtin.
If you are a native english speaker and seek to help this project, you can always help by improving the README.md file.
Both the introduction text and the walkthrough section require some work.
Is the Search API and AQL is included? How to search for file using Property?
trying to download an artifact with the example provided in the README downloads a file that contains a text like this:
{
"var1" : "value1",
"var2" : "value2",
"created" : "2018-01-03T15:59:24.432Z",
"createdBy" : "svc-olp-acf",
"lastModified" : "2018-01-03T15:59:24.283Z",
"modifiedBy" : "svc-olp-acf",
"lastUpdated" : "2018-01-03T15:59:24.283Z",
"downloadUri" : "uri",
"mimeType" : "mime/type",
"size" : "2485",
"checksums" : {
"sha1" : "764...",
"md5" : "b1f50..."
},
"originalChecksums" : {
"sha1" : "764d3648..",
"md5" : "b1f50b84.."
},
"uri" : "https://artifact/url"
}
but not actually a pom, jar or zip
i'm using python 3.6.3
from artifactory import ArtifactoryPath
path = ArtifactoryPath("http://mytest.repository.com/mytestdir")
path.mkdir() --> fails. Path string in ArtifactoryPath object is "http:/mytest.respository.com/mytestdir" . The additional "/" after http:/ has been removed by the utility.
This is latest released version. Tested on both Windows and Linux - same result.
Everywhere we use relative_to there is some form of stripping the '/' character happening. In some places we rstrip. Is some places we strip. In some places we slice arrays to strip.
This should at least be consistent. A good way is to move the strip into relative_to and remove it from all the caller's code. This would define the interface to be relative_to always returns a path without a leading or trailing '/' character.
If you approve, I can do this.
As of Artifactory 3.3 pro, debian package are now supported.
http://www.jfrog.com/confluence/display/RTF/Debian+Repositories
This is more of a question than an issue.
Artifactory has a Builds
tab for each artifact that shows you where it came from. Normally, if I use a Jenkins Artifactory plugin to push to Artifactory, then this tab is populated with relevant build information.
However, when I use this library to deploy files, I don't see anything under the Builds tab. Does this library support populating build info fields? If so, how and if not, how do I go about doing so using my deploy script?
Example of empty Builds tab:
Build Info documentation page is located here
Deprecation warnings are raised due to invalid escape sequences. This can be fixed by using raw strings or escaping the literals. pyupgrade also helps in automatic conversion : https://github.com/asottile/pyupgrade/
find . -iname '*.py' | grep -Ev 'example|utl|samples|deps' | xargs -P 4 -I{} python3.8 -Wall -m py_compile {}
./test.py:36: DeprecationWarning: invalid escape sequence \,
self.assertEqual(s, "a\,b\|c\=d")
./test.py:46: DeprecationWarning: invalid escape sequence \|
self.assertEqual(s, "baz=ba\\r,qu\|ux|foo=a\,s\=df")
Implemented and pull request created.
There should be a config file that looks like this:
[artifactory-instance.com/artifactory]
username = deployer
password = ilikerandompasswords
[another-artifactory-instance.com/artifactory]
username = foo
password = @dmin
And then, when one instantiates ArtifactoryPath with url starting from what's in the config, authentication information should be picked up automatically.
The config should be called ~/.artifactory_python.cfg
The following exception is raised when is_file() method is called for an artifact where its name contains square branckets ('[' or ']'):
if artifact.is_file():
File "C:\Python37-32\lib\site-packages\artifactory.py", line 1035, in is_file
return self._accessor.is_file(self)
File "C:\Python37-32\lib\site-packages\artifactory.py", line 534, in is_file
stat = self.stat(pathobj)
File "C:\Python37-32\lib\site-packages\artifactory.py", line 492, in stat
jsn = self.get_stat_json(pathobj)
File "C:\Python37-32\lib\site-packages\artifactory.py", line 471, in get_stat_json
raise RuntimeError(text)
RuntimeError: {
"errors" : [ {
"status" : 400,
"message" : "Bad Request"
} ]
}
the library depends on pathlib, but it seems can't work if configparser installed.
File "xxxxx/lib/python2.7/site-packages/artifactory.py", line 311, in parse_parts
drv, root, parsed = super(_ArtifactoryFlavour, self).parse_parts(parts)
File "xxxxx/lib/python2.7/site-packages/pathlib.py", line 90, in parse_parts
parsed.append(intern(x))
TypeError: intern() argument 1 must be string, not unicode
In my case Artifactory is hidden behind GCE for the access restriction. I should be able to use deploy_file and open methods, if i pass 'x-api-key' header in request.
More information: https://cloud.google.com/endpoints/docs/restricting-api-access-with-api-keys-openapi
Currently we don't have possibility to pass headers for deploy_file or open methods.
It would be great if you could document the differences between this libary and the other existing one namd Party - https://pypi.python.org/pypi/Party/
How do they compare, pros, cons, maybe policy regarding accepting contributions.
Maybe a small note in the README and the package homepage from PyPi?
I am asking this because I do want to pick one and probably I will want to contribute to it and I want to make a good pick and not having to maintain my own fork. As a side not, on open-source world is good to document about "competition" :)
Hi,
It appears that globbing behavior in Pathlib has changed/optimized to use scandir
in 3.6: https://bugs.python.org/issue26032
File "/usr/lib/python3.6/pathlib.py", line 1081, in glob
for p in selector.select_from(self):
File "/usr/lib/python3.6/pathlib.py", line 489, in select_from
scandir = parent_path._accessor.scandir
AttributeError: '_ArtifactoryAccessor' object has no attribute 'scandir'
Trivially implementing scandir
on _ArtifactoryAccessor
results in a second failure, so this may be more than just adding a new method that wraps listdir
.
The latest release (0.1.17) was Mar 12, 2016.
The latest commit to the master branch was Oct 23, 2016.
It's not completely clear who has permission to merge PRs or close issues, but it seems to me like no such person has commented on any PRs or issues in several months.
Please close this issue if this repo is not abandoned.
First off, I don't know if this is an Artifactory issue or something that is happening when using this library.
But when I am specifying the artifact url such as https://myartifactory.com/artifactory/libs-snapshot-local/path/to/amp/version/amp-version-SNAPSHOT
it ends up giving me an error and saying it cannot find the file -- https://myartifactory.com/artifactory/api/storage/libs-snapshot-local/path/to/amp/version/amp-version-SNAPSHOT
. This has the string api/storage
inserted into it.
I can't figure out if this is something that our artifactory server is re-routing the request to or if it is something with the Artifactory lib.
I mean if I I want create a path like this:
http://localhost:8080/artifactory/<xxx-yyy>
is that possible, I got exception:
AssertionError: OSError(2, "No such file or directory:
It would be great if this supported the API key in addition to username/pw
Is there a way to delete a file in Artifactory? I'm currently trying to update a file that exists but upon upload I'm getting an error stating the file exists:
[Errno 17] File exists
I saw the 'unlink' method on the _ArtifactoryAccessor class, but that is a private class.
I have created config file and put it in to the home directory. Every time I try to run my script I got following message:
RuntimeError: {
"errors" : [ {
"status" : 404,
"message" : "{"error":"Item artifactory_item-local:api/storage does not exist"}"
} ]
}
I checked twice and the url address of Artifactory is correct when I use it with my browser.
relrepo.deploy_file(os.path.join(".",art),calc_md5=False,calc_sha1=False)
File "/usr/local/lib/python2.7/dist-packages/artifactory.py", line 1092, in deploy_file
target.deploy(fobj, md5, sha1, parameters)
UnboundLocalError: local variable 'md5' referenced before assignment
since md5 and sha1 is not initialized
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.