fix
This commit is contained in:
parent
cb6d9ec324
commit
5f30d588dc
39
App.py
39
App.py
@ -4,14 +4,11 @@ from Config import CURRENT_CONFIG
|
|||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_restful import Api
|
from flask_restful import Api
|
||||||
|
import api.Repo as repoApi
|
||||||
from api.Repo import BrowseRepo, InfoLastPackage, DownloadLastPackage, DownloadPackage, DownloadPackageVersion, BrowseRepoVersion
|
from api.Repo import BrowseRepo, InfoLastPackage, DownloadLastPackage, DownloadPackage, DownloadPackageVersion, \
|
||||||
from utils.PackageFinder import PackageFinder
|
BrowseRepoVersion
|
||||||
from utils.PackageVersioning import PackageVersioning
|
from utils.PackageVersioning import PackageVersioning
|
||||||
|
|
||||||
import api.Repo as pr
|
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(CURRENT_CONFIG)
|
app.config.from_object(CURRENT_CONFIG)
|
||||||
api = Api(app, catch_all_404s=True)
|
api = Api(app, catch_all_404s=True)
|
||||||
@ -26,9 +23,12 @@ api.add_resource(
|
|||||||
|
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
BrowseRepoVersion,
|
BrowseRepoVersion,
|
||||||
'/<string:repo_name>/<string:package_name>/<int:version_major>', # Retrieve data version <package_name> from default <repo_name>
|
'/<string:repo_name>/<string:package_name>/<int:version_major>',
|
||||||
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>', # Retrieve data version <package_name> from default <repo_name>
|
# Retrieve data version <package_name> from default <repo_name>
|
||||||
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>', # Retrieve data version <package_name> from default <repo_name>
|
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>',
|
||||||
|
# Retrieve data version <package_name> from default <repo_name>
|
||||||
|
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>',
|
||||||
|
# Retrieve data version <package_name> from default <repo_name>
|
||||||
)
|
)
|
||||||
|
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
@ -38,14 +38,18 @@ api.add_resource(
|
|||||||
|
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
DownloadLastPackage,
|
DownloadLastPackage,
|
||||||
'/download/<string:repo_name>/<string:package_name>/last', # Download last version <package_name> from default <repo_name>
|
'/download/<string:repo_name>/<string:package_name>/last',
|
||||||
|
# Download last version <package_name> from default <repo_name>
|
||||||
)
|
)
|
||||||
|
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
DownloadPackageVersion,
|
DownloadPackageVersion,
|
||||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>', # Download version <package_name> from default <repo_name>
|
'/download/<string:repo_name>/<string:package_name>/<int:version_major>',
|
||||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>', # Download version <package_name> from default <repo_name>
|
# Download version <package_name> from default <repo_name>
|
||||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>', # Download version <package_name> from default <repo_name>
|
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>',
|
||||||
|
# Download version <package_name> from default <repo_name>
|
||||||
|
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>',
|
||||||
|
# Download version <package_name> from default <repo_name>
|
||||||
)
|
)
|
||||||
|
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
@ -53,7 +57,12 @@ api.add_resource(
|
|||||||
'/download/<string:repo_name>/<string:filename>', # Download version <filename> from repo_name
|
'/download/<string:repo_name>/<string:filename>', # Download version <filename> from repo_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_first_request
|
||||||
|
def setup():
|
||||||
|
repoApi.package_versioning = PackageVersioning(json.load(open(app.config['REPOS_JSON_CONFIG_PATH'])))
|
||||||
|
repoApi.package_versioning.__enter__()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with PackageVersioning(json.load(open(app.config['REPOS_JSON_CONFIG_PATH']))) as pv:
|
|
||||||
pr.package_versioning = pv
|
|
||||||
app.run(host="0.0.0.0")
|
app.run(host="0.0.0.0")
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
from flask import json
|
||||||
from flask_restful import Resource, abort
|
from flask_restful import Resource, abort
|
||||||
from flask import redirect, send_file
|
from flask import redirect, send_file
|
||||||
|
|
||||||
from utils.PackageFinder import InvalidPackageName
|
from utils.PackageFinder import InvalidPackageName
|
||||||
from utils.PackageVersioning import VersionDoNotExist, RepoDoNotExist, PackageDoNotExist
|
from utils.PackageVersioning import VersionDoNotExist, RepoDoNotExist, PackageDoNotExist, PackageVersioning
|
||||||
|
|
||||||
package_versioning = None
|
package_versioning = None
|
||||||
|
|
||||||
|
|
||||||
class BrowseRepo(Resource):
|
class BrowseRepo(Resource):
|
||||||
def get(self, repo_name=None, package_name=None):
|
def get(self, repo_name=None, package_name=None):
|
||||||
try:
|
try:
|
||||||
|
@ -112,6 +112,9 @@ class PackageVersioning(FileSystemEventHandler):
|
|||||||
|
|
||||||
self.__repos_public[repo_name] = repo_public
|
self.__repos_public[repo_name] = repo_public
|
||||||
self.__repos_private[repo_name] = repo_private
|
self.__repos_private[repo_name] = repo_private
|
||||||
|
print(self.__repos_public)
|
||||||
|
print(self.__repos_private)
|
||||||
|
|
||||||
|
|
||||||
def get_all_packages(self, package_name=None, repo_name=None):
|
def get_all_packages(self, package_name=None, repo_name=None):
|
||||||
repo_name, repo_public, _ = self.__get_repo(repo_name)
|
repo_name, repo_public, _ = self.__get_repo(repo_name)
|
||||||
|
Reference in New Issue
Block a user