6 changed files with 48 additions and 3 deletions
@ -1,2 +1,3 @@ |
|||
# flake8: noqa F401 |
|||
from alice.runners.pythonrunner import PythonRunner |
|||
from alice.runners.pypirunner import PyPiRunner |
|||
|
@ -0,0 +1,29 @@ |
|||
import json |
|||
import sys |
|||
from urllib import request |
|||
from pkg_resources import parse_version |
|||
|
|||
from alice.exceptions import NonZeroRetcode, RunnerError, ConfigException |
|||
|
|||
|
|||
class PyPiRunner(): |
|||
def __init__(self, params, user_defaults) -> None: |
|||
self.verbose = params["verbose"] |
|||
if self.verbose: |
|||
print("[PyPiRunner] Initializing") |
|||
self.workdir = user_defaults["workdir"] |
|||
# config only contains env and workdir |
|||
self.config = user_defaults |
|||
self.default_repo = "https://pypi.python.org/pypi" |
|||
|
|||
def __versions(self, pkg_name): |
|||
# TODO: Error handling |
|||
url = f'{self.default_repo}/{pkg_name}/json' |
|||
releases = json.loads(request.urlopen(url).read())['releases'] |
|||
return sorted(releases, key=parse_version, reverse=True) |
|||
|
|||
def update_config(self, config): |
|||
print(config) |
|||
|
|||
def run(self, job_spec): |
|||
print(self.__versions("alice-ci")) |
Loading…
Reference in new issue