fix some issues
This commit is contained in:
parent
3b7a73ced8
commit
d7a3dd585b
2
App.py
2
App.py
@ -56,4 +56,4 @@ api.add_resource(
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with PackageVersioning(json.load(open(app.config['REPOS_JSON_CONFIG_PATH']))) as pv:
|
with PackageVersioning(json.load(open(app.config['REPOS_JSON_CONFIG_PATH']))) as pv:
|
||||||
pr.package_versioning = pv
|
pr.package_versioning = pv
|
||||||
app.run()
|
app.run(host="0.0.0.0")
|
||||||
|
@ -11,7 +11,8 @@ class BrowseRepo(Resource):
|
|||||||
def get(self, repo_name=None, package_name=None):
|
def get(self, repo_name=None, package_name=None):
|
||||||
try:
|
try:
|
||||||
return package_versioning.get_all_packages(package_name=package_name, repo_name=repo_name), 200
|
return package_versioning.get_all_packages(package_name=package_name, repo_name=repo_name), 200
|
||||||
except (RepoDoNotExist, PackageDoNotExist):
|
except (RepoDoNotExist, PackageDoNotExist) as e:
|
||||||
|
print(type(e))
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +26,8 @@ class BrowseRepoVersion(Resource):
|
|||||||
version_minor=version_minor,
|
version_minor=version_minor,
|
||||||
version_release=version_release
|
version_release=version_release
|
||||||
)
|
)
|
||||||
except (RepoDoNotExist, PackageDoNotExist, VersionDoNotExist):
|
except (RepoDoNotExist, PackageDoNotExist, VersionDoNotExist) as e:
|
||||||
|
print(e)
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ class DownloadLastPackage(Resource):
|
|||||||
def get(self, package_name, repo_name):
|
def get(self, package_name, repo_name):
|
||||||
try:
|
try:
|
||||||
return redirect(
|
return redirect(
|
||||||
package_versioning.get_last_version_package(package_name=package_name, repo_name=repo_name)['apk_url']
|
package_versioning.get_last_version_package(package_name=package_name, repo_name=repo_name)['url']
|
||||||
)
|
)
|
||||||
except (RepoDoNotExist, PackageDoNotExist):
|
except (RepoDoNotExist, PackageDoNotExist):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
lol
|
@ -5,8 +5,8 @@
|
|||||||
"description": "Description Repo Example",
|
"description": "Description Repo Example",
|
||||||
"package_regex_name": "^(?P<package_name>[^-]*)-(?P<version_major>\\d+)(\\.(?P<version_minor>\\d+)|\\.apk)(\\.(?P<version_release>\\d+)\\.apk|\\.apk)?$",
|
"package_regex_name": "^(?P<package_name>[^-]*)-(?P<version_major>\\d+)(\\.(?P<version_minor>\\d+)|\\.apk)(\\.(?P<version_release>\\d+)\\.apk|\\.apk)?$",
|
||||||
"security": {
|
"security": {
|
||||||
"is_public": false,
|
"is_public": true,
|
||||||
"allow_hash_key": ["SuperApiKey"]
|
"allow_hash_key": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -116,16 +116,18 @@ class PackageVersioning(FileSystemEventHandler):
|
|||||||
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)
|
||||||
try:
|
try:
|
||||||
return repo_public[package_name] if \
|
return repo_public[repo_name][package_name] if \
|
||||||
package_name is not None else repo_public
|
package_name is not None else repo_public
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
print(package_name)
|
||||||
|
print(repo_public)
|
||||||
raise PackageDoNotExist
|
raise PackageDoNotExist
|
||||||
|
|
||||||
def get_last_version_package(self, package_name, repo_name=None):
|
def get_last_version_package(self, package_name, repo_name):
|
||||||
_, repo_public, _ = self.__get_repo(repo_name)
|
_, repo_public, _ = self.__get_repo(repo_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
package = repo_public[package_name]
|
package = repo_public[repo_name][package_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise PackageDoNotExist
|
raise PackageDoNotExist
|
||||||
|
|
||||||
@ -137,13 +139,13 @@ class PackageVersioning(FileSystemEventHandler):
|
|||||||
|
|
||||||
return package[str(last_version)]
|
return package[str(last_version)]
|
||||||
|
|
||||||
def get_path_package(self, filename, repo_name=None):
|
def get_path_package(self, filename, repo_name):
|
||||||
_, _, repo_private = self.__get_repo(repo_name)
|
_, _, repo_private = self.__get_repo(repo_name)
|
||||||
if not repo_private['package_finder'].is_valid_filename(filename):
|
if not repo_private[repo_name]['package_finder'].is_valid_filename(filename):
|
||||||
raise InvalidPackageName
|
raise InvalidPackageName
|
||||||
return os.path.join(repo_private['directory_path'], filename)
|
return os.path.join(repo_private[repo_name]['directory_path'], filename)
|
||||||
|
|
||||||
def __get_repo(self, repo_name, api_key="SuperApiKey"):
|
def __get_repo(self, repo_name, api_key=None):
|
||||||
try:
|
try:
|
||||||
r_pub = {}
|
r_pub = {}
|
||||||
r_pri = {}
|
r_pri = {}
|
||||||
|
Reference in New Issue
Block a user