mirror of
https://git.wownero.com/wowlet/wowlet-backend.git
synced 2024-08-15 01:03:13 +00:00
Introduce websocket cmd for SuchWow so that it can dynamically add/update new images and change FeatherTask to WowletTask
This commit is contained in:
parent
136e7909fa
commit
891baaff71
10 changed files with 23 additions and 22 deletions
|
@ -8,7 +8,7 @@ import random
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class FeatherTask:
|
class WowletTask:
|
||||||
"""
|
"""
|
||||||
The base class of many recurring tasks for this
|
The base class of many recurring tasks for this
|
||||||
project. This abstracts away some functionality:
|
project. This abstracts away some functionality:
|
||||||
|
|
|
@ -9,10 +9,10 @@ from functools import partial
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget, popularity_contest
|
from wowlet_backend.utils import httpget, popularity_contest
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class BlockheightTask(FeatherTask):
|
class BlockheightTask(WowletTask):
|
||||||
"""
|
"""
|
||||||
Fetch latest blockheight using webcrawling. We pick the most popular
|
Fetch latest blockheight using webcrawling. We pick the most popular
|
||||||
height from a list of websites. Arguably this approach has benefits
|
height from a list of websites. Arguably this approach has benefits
|
||||||
|
|
|
@ -12,10 +12,10 @@ import aiofiles
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class HistoricalPriceTask(FeatherTask):
|
class HistoricalPriceTask(WowletTask):
|
||||||
"""
|
"""
|
||||||
This class manages a historical price (USD) database, saved in a
|
This class manages a historical price (USD) database, saved in a
|
||||||
textfile at `self._path`. A Feather wallet instance will ask
|
textfile at `self._path`. A Feather wallet instance will ask
|
||||||
|
|
|
@ -7,10 +7,10 @@ from typing import List
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class FundingProposalsTask(FeatherTask):
|
class FundingProposalsTask(WowletTask):
|
||||||
"""Fetch funding proposals made by the community."""
|
"""Fetch funding proposals made by the community."""
|
||||||
def __init__(self, interval: int = 600):
|
def __init__(self, interval: int = 600):
|
||||||
from wowlet_backend.factory import app
|
from wowlet_backend.factory import app
|
||||||
|
|
|
@ -6,10 +6,10 @@ from typing import List, Union
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class CryptoRatesTask(FeatherTask):
|
class CryptoRatesTask(WowletTask):
|
||||||
def __init__(self, interval: int = 180):
|
def __init__(self, interval: int = 180):
|
||||||
super(CryptoRatesTask, self).__init__(interval)
|
super(CryptoRatesTask, self).__init__(interval)
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ from datetime import datetime, timedelta
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class FiatRatesTask(FeatherTask):
|
class FiatRatesTask(WowletTask):
|
||||||
def __init__(self, interval: int = 43200):
|
def __init__(self, interval: int = 43200):
|
||||||
super(FiatRatesTask, self).__init__(interval)
|
super(FiatRatesTask, self).__init__(interval)
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
import html
|
import html
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class RedditTask(FeatherTask):
|
class RedditTask(WowletTask):
|
||||||
def __init__(self, interval: int = 900):
|
def __init__(self, interval: int = 900):
|
||||||
from wowlet_backend.factory import app
|
from wowlet_backend.factory import app
|
||||||
super(RedditTask, self).__init__(interval)
|
super(RedditTask, self).__init__(interval)
|
||||||
|
|
|
@ -7,10 +7,10 @@ from typing import List
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget, popularity_contest
|
from wowlet_backend.utils import httpget, popularity_contest
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class RPCNodeCheckTask(FeatherTask):
|
class RPCNodeCheckTask(WowletTask):
|
||||||
def __init__(self, interval: int = 60):
|
def __init__(self, interval: int = 60):
|
||||||
super(RPCNodeCheckTask, self).__init__(interval)
|
super(RPCNodeCheckTask, self).__init__(interval)
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ from bs4 import BeautifulSoup
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget, image_resize
|
from wowlet_backend.utils import httpget, image_resize
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class SuchWowTask(FeatherTask):
|
class SuchWowTask(WowletTask):
|
||||||
def __init__(self, interval: int = 600):
|
def __init__(self, interval: int = 300):
|
||||||
"""
|
"""
|
||||||
This task is specifically for Wownero - fetching a listing
|
This task is specifically for Wownero - fetching a listing
|
||||||
of recent SuchWow submissions.
|
of recent SuchWow submissions.
|
||||||
|
@ -31,15 +31,16 @@ class SuchWowTask(FeatherTask):
|
||||||
self._http_endpoint = "https://suchwow.xyz/"
|
self._http_endpoint = "https://suchwow.xyz/"
|
||||||
self._tmp_dir = os.path.join(settings.cwd, "data", "suchwow")
|
self._tmp_dir = os.path.join(settings.cwd, "data", "suchwow")
|
||||||
|
|
||||||
|
self._websocket_cmd = "suchwow"
|
||||||
|
|
||||||
if not os.path.exists(self._tmp_dir):
|
if not os.path.exists(self._tmp_dir):
|
||||||
os.mkdir(self._tmp_dir)
|
os.mkdir(self._tmp_dir)
|
||||||
|
|
||||||
async def task(self):
|
async def task(self):
|
||||||
from wowlet_backend.factory import app
|
from wowlet_backend.factory import app
|
||||||
result = await httpget(f"{self._http_endpoint}api/list", json=True)
|
result = await httpget(f"{self._http_endpoint}api/list?limit=15&offset=0", json=True)
|
||||||
|
|
||||||
result = list(sorted(result, key=lambda k: k['id'], reverse=True))
|
result = list(sorted(result, key=lambda k: k['id'], reverse=True))
|
||||||
result = result[:15]
|
|
||||||
|
|
||||||
for post in result:
|
for post in result:
|
||||||
post_id = int(post['id'])
|
post_id = int(post['id'])
|
||||||
|
|
|
@ -6,10 +6,10 @@ from dateutil.parser import parse
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from wowlet_backend.utils import httpget
|
from wowlet_backend.utils import httpget
|
||||||
from wowlet_backend.tasks import FeatherTask
|
from wowlet_backend.tasks import WowletTask
|
||||||
|
|
||||||
|
|
||||||
class XmrigTask(FeatherTask):
|
class XmrigTask(WowletTask):
|
||||||
"""Fetches the latest XMRig releases using Github's API"""
|
"""Fetches the latest XMRig releases using Github's API"""
|
||||||
def __init__(self, interval: int = 43200):
|
def __init__(self, interval: int = 43200):
|
||||||
super(XmrigTask, self).__init__(interval)
|
super(XmrigTask, self).__init__(interval)
|
||||||
|
|
Loading…
Reference in a new issue