Proxy support in workers and stuff
This commit is contained in:
parent
a4bbe0434c
commit
b1860ce065
|
@ -46,7 +46,7 @@ class App(tk.Tk):
|
||||||
ts = datetime.fromtimestamp(self._last_update / 1000)
|
ts = datetime.fromtimestamp(self._last_update / 1000)
|
||||||
path = ts.strftime(SCREENSHOTS_TMPL)
|
path = ts.strftime(SCREENSHOTS_TMPL)
|
||||||
print("SAVED", path)
|
print("SAVED", path)
|
||||||
self._image.save(path)
|
self._image.save(path, lossless=True)
|
||||||
|
|
||||||
self.after(10000, self._save_image)
|
self.after(10000, self._save_image)
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
|
@ -41,28 +41,12 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
|
||||||
"type": "time",
|
|
||||||
"x": 75,
|
|
||||||
"y": 100,
|
|
||||||
"format": "And time is: %Y-%m-%d %H:%M:%S UTC",
|
|
||||||
"spf": 20,
|
|
||||||
"font": "/usr/share/fonts/TTF/TerminusTTF.ttf",
|
|
||||||
"size": 12
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"path": "../pictures/casey.png",
|
"path": "../pictures/casey.png",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 128
|
"y": 128
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "animation",
|
|
||||||
"path": "../pictures/neko.gif",
|
|
||||||
"spf": 30,
|
|
||||||
"x": 625,
|
|
||||||
"y": 496
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"path": "../pictures/casey_qr.png",
|
"path": "../pictures/casey_qr.png",
|
||||||
|
@ -71,9 +55,15 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"path": "../pictures/hueh.png",
|
"x": 69,
|
||||||
"x": 490,
|
"y": 112,
|
||||||
"y": 810
|
"path": "./thomas_adhd.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"x": 69,
|
||||||
|
"y": 300,
|
||||||
|
"path": "./thomas_lain.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import functools
|
import functools
|
||||||
|
import json
|
||||||
from multiprocessing.shared_memory import SharedMemory
|
from multiprocessing.shared_memory import SharedMemory
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
|
@ -31,9 +32,12 @@ class WorkerManager:
|
||||||
self.n_toggles = 0
|
self.n_toggles = 0
|
||||||
|
|
||||||
async def queue_manager(self):
|
async def queue_manager(self):
|
||||||
index = random.randint(0, 999999)
|
offset = random.randint(0, 999999)
|
||||||
while True:
|
while True:
|
||||||
index = (index + 1) % 1000000
|
for oy in [0, 4, 2, 6, 1, 3, 5, 7]:
|
||||||
|
for y in range(oy, 1000, 8):
|
||||||
|
for x in range(1000):
|
||||||
|
index = (x + y * 1000 + offset) % 1000000
|
||||||
byte, bit = divmod(index, 8)
|
byte, bit = divmod(index, 8)
|
||||||
mask = 0x80 >> bit
|
mask = 0x80 >> bit
|
||||||
|
|
||||||
|
@ -105,14 +109,29 @@ class WorkerManager:
|
||||||
self.shmem.close()
|
self.shmem.close()
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main(config_path: str = "worker.json", *_):
|
||||||
async with WorkerManager() as mgr:
|
with open(config_path, "r") as fp:
|
||||||
|
config = json.load(fp)
|
||||||
|
|
||||||
|
n_bots = config.get("n_bots", 1)
|
||||||
|
|
||||||
|
async with WorkerManager(config.get("shmem", "omcb-bot")) as mgr:
|
||||||
|
|
||||||
|
mgr.delay = config.get("delay", mgr.delay)
|
||||||
|
|
||||||
|
workers = []
|
||||||
|
if proxies := config.get("proxy", []):
|
||||||
|
workers.extend([mgr.writer(i, proxies[i % len(proxies)]) for i in range(n_bots)])
|
||||||
|
else:
|
||||||
|
workers.extend([mgr.writer(i) for i in range(n_bots)])
|
||||||
|
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
mgr.queue_manager(),
|
mgr.queue_manager(),
|
||||||
mgr.status_display(),
|
mgr.status_display(),
|
||||||
*[mgr.writer(i) for i in range(4)]
|
*workers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
from sys import argv
|
||||||
|
asyncio.run(main(*argv[1:]))
|
||||||
|
|
Loading…
Reference in New Issue