mirror of
https://git.wownero.com/wowlet/wowlet-backend.git
synced 2024-08-15 01:03:13 +00:00
Merge pull request 'track wownerod version' (#18) from wownerod into master
Reviewed-on: https://git.wownero.com/wowlet/wowlet-backend/pulls/18
This commit is contained in:
commit
56714c7411
3 changed files with 58 additions and 1 deletions
|
@ -59,7 +59,7 @@ async def _setup_tasks(app: Quart):
|
||||||
BlockheightTask, HistoricalPriceTask, FundingProposalsTask,
|
BlockheightTask, HistoricalPriceTask, FundingProposalsTask,
|
||||||
CryptoRatesTask, FiatRatesTask, RedditTask, RPCNodeCheckTask,
|
CryptoRatesTask, FiatRatesTask, RedditTask, RPCNodeCheckTask,
|
||||||
XmrigTask, SuchWowTask, WowletReleasesTask, ForumThreadsTask,
|
XmrigTask, SuchWowTask, WowletReleasesTask, ForumThreadsTask,
|
||||||
YellWowTask)
|
YellWowTask, WownerodTask)
|
||||||
|
|
||||||
asyncio.create_task(BlockheightTask().start())
|
asyncio.create_task(BlockheightTask().start())
|
||||||
asyncio.create_task(HistoricalPriceTask().start())
|
asyncio.create_task(HistoricalPriceTask().start())
|
||||||
|
@ -72,6 +72,7 @@ async def _setup_tasks(app: Quart):
|
||||||
asyncio.create_task(WowletReleasesTask().start())
|
asyncio.create_task(WowletReleasesTask().start())
|
||||||
asyncio.create_task(ForumThreadsTask().start())
|
asyncio.create_task(ForumThreadsTask().start())
|
||||||
asyncio.create_task(YellWowTask().start())
|
asyncio.create_task(YellWowTask().start())
|
||||||
|
asyncio.create_task(WownerodTask().start())
|
||||||
|
|
||||||
if settings.COIN_SYMBOL in ["xmr", "wow"]:
|
if settings.COIN_SYMBOL in ["xmr", "wow"]:
|
||||||
asyncio.create_task(FundingProposalsTask().start())
|
asyncio.create_task(FundingProposalsTask().start())
|
||||||
|
|
|
@ -168,3 +168,4 @@ from wowlet_backend.tasks.suchwow import SuchWowTask
|
||||||
from wowlet_backend.tasks.wowlet import WowletReleasesTask
|
from wowlet_backend.tasks.wowlet import WowletReleasesTask
|
||||||
from wowlet_backend.tasks.forum import ForumThreadsTask
|
from wowlet_backend.tasks.forum import ForumThreadsTask
|
||||||
from wowlet_backend.tasks.yellow import YellWowTask
|
from wowlet_backend.tasks.yellow import YellWowTask
|
||||||
|
from wowlet_backend.tasks.wownerod import WownerodTask
|
||||||
|
|
55
wowlet_backend/tasks/wownerod.py
Normal file
55
wowlet_backend/tasks/wownerod.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
# Copyright (c) 2022, The Monero Project.
|
||||||
|
# Copyright (c) 2022, dsc@xmr.pm
|
||||||
|
|
||||||
|
from dateutil.parser import parse
|
||||||
|
|
||||||
|
import settings
|
||||||
|
from wowlet_backend.utils import httpget
|
||||||
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
|
class WownerodTask(WowletTask):
|
||||||
|
"""Fetches the latest Wownerod releases using gitea's API"""
|
||||||
|
def __init__(self, interval: int = 3600):
|
||||||
|
super(WownerodTask, self).__init__(interval)
|
||||||
|
|
||||||
|
self._cache_key = "wownerod_releases"
|
||||||
|
self._cache_expiry = self.interval
|
||||||
|
|
||||||
|
self._websocket_cmd = "wownerod_releases"
|
||||||
|
|
||||||
|
self._http_endpoint = "https://git.wownero.com/api/v1/repos/wownero/wownero/releases?limit=1"
|
||||||
|
|
||||||
|
async def task(self) -> dict:
|
||||||
|
blob = await httpget(self._http_endpoint)
|
||||||
|
if not isinstance(blob, list) or not blob:
|
||||||
|
raise Exception(f"Invalid JSON response for {self._http_endpoint}")
|
||||||
|
|
||||||
|
blob = blob[0]
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
for asset in blob['assets']:
|
||||||
|
operating_system = "linux"
|
||||||
|
if "w64" in asset['name'] or "msvc" in asset['name'] or "win64" in asset['name'] or "windows" in asset['name']:
|
||||||
|
operating_system = "windows"
|
||||||
|
elif "macos" in asset["name"] or "apple" in asset["name"]:
|
||||||
|
operating_system = "macos"
|
||||||
|
|
||||||
|
data.setdefault(operating_system, [])
|
||||||
|
data[operating_system].append({
|
||||||
|
"name": asset["name"],
|
||||||
|
"created_at": parse(asset["created_at"]).strftime("%Y-%m-%d"),
|
||||||
|
"url": asset['browser_download_url'],
|
||||||
|
"download_count": asset["download_count"],
|
||||||
|
"size": asset['size']
|
||||||
|
})
|
||||||
|
|
||||||
|
tag = blob['tag_name']
|
||||||
|
if tag.startswith("v"):
|
||||||
|
tag = tag[1:]
|
||||||
|
|
||||||
|
return {
|
||||||
|
"version": tag,
|
||||||
|
"assets": data
|
||||||
|
}
|
Loading…
Reference in a new issue