69 lines
2.1 KiB
Python
Executable File
69 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright © 2024 Nicole O'Connor
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import logging
|
|
import os
|
|
import math
|
|
import pathlib
|
|
import time
|
|
import threading
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
import blocklists
|
|
import screen
|
|
|
|
log = logging.getLogger("main")
|
|
|
|
if __name__ == "__main__":
|
|
screen.screen_init()
|
|
screen.scr_light.value = True
|
|
|
|
img_canvas = Image.new("RGB", (135, 240))
|
|
hnd_canvas = ImageDraw.Draw(img_canvas)
|
|
hnd_canvas.rectangle((0,0,135,240), (0,0,0))
|
|
img_canvas.paste(Image.open("res/image/hourglass.png"),(math.floor(135/2) - math.ceil(49/2),math.floor(240/2) - math.ceil(90/2)))
|
|
screen.scr.image(img_canvas)
|
|
|
|
if not (blocklists.pth_blocklist_lib / "dns-blocklists-main.zip").exists():
|
|
blocklists.update_blocklists()
|
|
|
|
if not (blocklists.pth_cache_root / "lists").exists():
|
|
(blocklists.pth_cache_root / "lists").mkdir()
|
|
blocklists.deploy_blocklists()
|
|
|
|
blocklists.build_dnsmasq_file()
|
|
|
|
thr_blocklists = threading.Thread(target=blocklists.blocklist_thread)
|
|
thr_screen = threading.Thread(target=screen.screen_thread)
|
|
thr_blocklists.start()
|
|
thr_screen.start()
|
|
|
|
ok = True
|
|
while ok:
|
|
try:
|
|
thr_blocklists.join(5.0)
|
|
thr_screen.join(5.0)
|
|
ok = thr_blocklists.is_alive() and thr_screen.is_alive()
|
|
except KeyboardInterrupt:
|
|
ok = False
|
|
print("KEYBOARD INTERRUPT")
|
|
except:
|
|
ok = False
|
|
|
|
screen.running = False
|
|
blocklists.running = False
|
|
thr_screen.join()
|
|
thr_blocklists.join() |