mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
b8a9413cb5
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
35 lines
1,022 B
Python
35 lines
1,022 B
Python
import os
|
|
from pathlib import Path
|
|
from urllib3 import PoolManager
|
|
|
|
from slpkg.repositories import Repositories
|
|
|
|
|
|
class Check: # pylint: disable=[R0903]
|
|
"""Check for repository update."""
|
|
|
|
def __init__(self):
|
|
self.repos = Repositories()
|
|
self.repositories = Repositories().repositories
|
|
|
|
def test(self) -> None:
|
|
"""Test for ChangLog files."""
|
|
local_size: int = 0
|
|
for name, data in self.repositories.items():
|
|
|
|
local_chg_txt: Path = Path(data['path'], 'ChangeLog.txt')
|
|
repo_chg_txt: str = f"{data['mirror_changelog']}ChangeLog.txt"
|
|
|
|
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()
|