2023-04-23 20:16:59 +02:00
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
from urllib3 import PoolManager
|
|
|
|
|
|
|
|
from slpkg.repositories import Repositories
|
|
|
|
|
|
|
|
|
2024-04-29 21:02:08 +02:00
|
|
|
class Check: # pylint: disable=[R0903]
|
2024-05-21 21:01:26 +02:00
|
|
|
"""Check for repository update."""
|
2023-04-23 20:16:59 +02:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.repos = Repositories()
|
|
|
|
self.repositories = Repositories().repositories
|
|
|
|
|
2024-04-29 21:02:08 +02:00
|
|
|
def test(self) -> None:
|
2024-05-21 21:01:26 +02:00
|
|
|
"""Test for ChangLog files."""
|
2023-04-23 20:16:59 +02:00
|
|
|
local_size: int = 0
|
|
|
|
for name, data in self.repositories.items():
|
|
|
|
|
2023-05-13 16:51:44 +02:00
|
|
|
local_chg_txt: Path = Path(data['path'], 'ChangeLog.txt')
|
2024-06-05 16:30:47 +02:00
|
|
|
repo_chg_txt: str = f"{data['mirror_changelog']}ChangeLog.txt"
|
2023-04-23 20:16:59 +02:00
|
|
|
|
|
|
|
http = PoolManager()
|
|
|
|
repo = http.request('GET', repo_chg_txt)
|
|
|
|
repo_size: int = int(repo.headers['Content-Length'])
|
|
|
|
|
|
|
|
if local_chg_txt.is_file():
|
|
|
|
local_size: int = int(os.stat(local_chg_txt).st_size)
|
|
|
|
|
|
|
|
print(f'{name=} = {local_size=}, {repo_size=}, {local_size != repo_size}')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
check = Check()
|
|
|
|
check.test()
|