Moitié1
This commit is contained in:
parent
7ff0153c9d
commit
9a1e95cd5a
2
Pipfile
2
Pipfile
@ -6,6 +6,8 @@ name = "pypi"
|
|||||||
[packages]
|
[packages]
|
||||||
packaging = "*"
|
packaging = "*"
|
||||||
discord-py = {extras = ["voice"],git = "https://github.com/Rapptz/discord.py",ref = "84c1eac62a775a37b03bd0971b221b0c50724630"}
|
discord-py = {extras = ["voice"],git = "https://github.com/Rapptz/discord.py",ref = "84c1eac62a775a37b03bd0971b221b0c50724630"}
|
||||||
|
aiohttp = "*"
|
||||||
|
aiofiles = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
73
Pipfile.lock
generated
73
Pipfile.lock
generated
@ -1,7 +1,20 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "3acaf69a4f810e9def8839c2fb3e6ed5f70b0c37439fecd98c30ac32b0809995"
|
"sha256": "e5ce2d692a19fe61098fd4a82500439d23c83afcc1f305cbe84a1c774fcf3505"
|
||||||
|
},
|
||||||
|
"host-environment-markers": {
|
||||||
|
"implementation_name": "cpython",
|
||||||
|
"implementation_version": "3.7.3",
|
||||||
|
"os_name": "posix",
|
||||||
|
"platform_machine": "x86_64",
|
||||||
|
"platform_python_implementation": "CPython",
|
||||||
|
"platform_release": "4.19.27-gentoo-r1",
|
||||||
|
"platform_system": "Linux",
|
||||||
|
"platform_version": "#1 SMP Wed May 1 11:50:20 CEST 2019",
|
||||||
|
"python_full_version": "3.7.3",
|
||||||
|
"python_version": "3.7",
|
||||||
|
"sys_platform": "linux"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -16,6 +29,26 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
|
"aiofiles": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==0.4.0"
|
||||||
|
},
|
||||||
|
"aiohttp": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==3.5.4"
|
||||||
|
},
|
||||||
|
"async-timeout": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==3.0.1"
|
||||||
|
},
|
||||||
|
"attrs": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==19.1.0"
|
||||||
|
},
|
||||||
|
"chardet": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==3.0.4"
|
||||||
|
},
|
||||||
"discord-py": {
|
"discord-py": {
|
||||||
"extras": [
|
"extras": [
|
||||||
"voice"
|
"voice"
|
||||||
@ -23,27 +56,39 @@
|
|||||||
"git": "https://github.com/Rapptz/discord.py",
|
"git": "https://github.com/Rapptz/discord.py",
|
||||||
"ref": "84c1eac62a775a37b03bd0971b221b0c50724630"
|
"ref": "84c1eac62a775a37b03bd0971b221b0c50724630"
|
||||||
},
|
},
|
||||||
|
"idna": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==2.8"
|
||||||
|
},
|
||||||
|
"idna-ssl": {
|
||||||
|
"hashes": [],
|
||||||
|
"markers": "python_version < '3.7'",
|
||||||
|
"version": "==1.1.0"
|
||||||
|
},
|
||||||
|
"multidict": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==4.5.2"
|
||||||
|
},
|
||||||
"packaging": {
|
"packaging": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af",
|
|
||||||
"sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==19.0"
|
"version": "==19.0"
|
||||||
},
|
},
|
||||||
"pyparsing": {
|
"pyparsing": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a",
|
|
||||||
"sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03"
|
|
||||||
],
|
|
||||||
"version": "==2.4.0"
|
"version": "==2.4.0"
|
||||||
},
|
},
|
||||||
"six": {
|
"six": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
|
||||||
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
|
|
||||||
],
|
|
||||||
"version": "==1.12.0"
|
"version": "==1.12.0"
|
||||||
|
},
|
||||||
|
"typing-extensions": {
|
||||||
|
"hashes": [],
|
||||||
|
"markers": "python_version < '3.7'",
|
||||||
|
"version": "==3.7.2"
|
||||||
|
},
|
||||||
|
"yarl": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==1.3.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {}
|
"develop": {}
|
||||||
|
32
modules/modules/api.py
Normal file
32
modules/modules/api.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
import aiofiles
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
class Api:
|
||||||
|
def __init__(self, host):
|
||||||
|
self.host = host
|
||||||
|
self.basepath = "http://"+host+"/api/current"
|
||||||
|
|
||||||
|
def _get(self, endpoint):
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(self.basepath+endpoint) as response:
|
||||||
|
return await response.json()
|
||||||
|
|
||||||
|
def _download(self, endpoint, filename="temp"):
|
||||||
|
if endpoint[0] != "/":
|
||||||
|
endpoint = "/" + endpoint
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(self.basepath+endpoint) as resp:
|
||||||
|
f = await aiofiles.open(filename, mode='wb')
|
||||||
|
await f.write(await resp.read())
|
||||||
|
await f.close()
|
||||||
|
|
||||||
|
async def list(self):
|
||||||
|
return await self._get("modules/")
|
||||||
|
|
||||||
|
async def download(self, module, version):
|
||||||
|
await self._download("modules/"+module+"/"+version, filename="temp.zip")
|
||||||
|
with zipfile.ZipFile('test.zip', "r") as z:
|
||||||
|
z.extractall(os.path.join("modules", module))
|
Loading…
Reference in New Issue
Block a user