2022-11-03 18:25:24 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
2022-11-03 19:26:49 +01:00
|
|
|
import os
|
2022-11-03 18:25:24 +01:00
|
|
|
import urllib3
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
from slpkg.configs import Configs
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class CheckUpdates:
|
|
|
|
sbo_repo_url: str = Configs.sbo_repo_url
|
|
|
|
sbo_repo_path: str = Configs.sbo_repo_path
|
|
|
|
chglog_txt: str = Configs.chglog_txt
|
|
|
|
|
|
|
|
def updates(self):
|
|
|
|
|
2022-11-06 17:13:45 +01:00
|
|
|
local_date = 0
|
2022-11-03 18:25:24 +01:00
|
|
|
local_chg_txt = f'{self.sbo_repo_path}/{self.chglog_txt}'
|
|
|
|
|
|
|
|
http = urllib3.PoolManager()
|
|
|
|
repo = http.request(
|
|
|
|
'GET', f'{self.sbo_repo_url}/{self.chglog_txt}')
|
|
|
|
|
2022-11-06 17:13:45 +01:00
|
|
|
if os.path.isfile(local_chg_txt):
|
|
|
|
local_date = int(os.stat(local_chg_txt).st_size)
|
|
|
|
|
|
|
|
repo_date = int(repo.headers['Content-Length'])
|
2022-11-05 18:26:07 +01:00
|
|
|
|
2022-11-06 19:14:51 +01:00
|
|
|
if repo_date != local_date:
|
2022-11-03 18:25:24 +01:00
|
|
|
print('\nThere are new updates available.\n')
|
|
|
|
else:
|
|
|
|
print('\nNo updated packages since the last check.\n')
|