Skip to content

Commit

Permalink
🚀 feat(_construct): still on contruction
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanized committed Dec 3, 2024
1 parent debc718 commit 2a9885f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
41 changes: 41 additions & 0 deletions lib/Kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Store kernel data from ALA, pacman sync db
import datetime
from datetime import datetime


class Kernel:
def __init__(self, name, headers, version, size, last_modified, file_format):
self.name = name
self.headers = headers
self.version = version
self.size = size
self.last_modified = last_modified
self.file_format = file_format

def __gt__(self, other):
datetime_value_self = (datetime.strptime(self.last_modified, "%d-%b-%Y %H:%M").replace(tzinfo=None).date())
datetime_value_other = (datetime.strptime(other.last_modified, "%d-%b-%Y %H:%M").replace(tzinfo=None).date())
if datetime_value_other >= datetime_value_self:
return datetime_value_other


class CommunityKernel:
def __init__(self, name, headers, repository, version, build_date, install_size):
self.name = name
self.headers = headers
self.repository = repository
self.version = version
self.build_date = build_date
self.install_size = install_size

def __gt__(self, other):
if other.name > self.name:
return other


class InstalledKernel:
def __init__(self, name, version, date, size):
self.name = name
self.version = version
self.date = date
self.size = size
13 changes: 11 additions & 2 deletions lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gi
from gi.repository import Gtk
gi.require_version("Gtk", "3.0")
from Kernel import Kernel, CommunityKernel, InstalledKernel

BaseDir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
SudoUsername = os.getlogin()
Expand Down Expand Up @@ -133,8 +134,14 @@ def writeCache():
except Exception as e:
logger.error("Found error in write_cache() ! Type: %s" % e)

CacheDays = 5
CachedKernelsList = []
def refreshCache(self):
CachedKernelsList.clear()
if os.path.exists(CacheFile):
os.remove(CacheFile)
get_official_kernels(self)

CacheDays = 5
def readCache(self):
try:
self.timestamp = None
Expand All @@ -156,7 +163,7 @@ def readCache(self):
delta = datetime.datetime.now() - self.timestamp
if delta.days >= CacheDays:
logger.info("Cache is older than 5 days, refreshing ..")
refresh_cache(self)
refreshCache(self)
else:
if delta.days > 0:
logger.debug("Cache is %s days old" % delta.days)
Expand All @@ -183,3 +190,5 @@ def readCache(self):
logger.error("Failed to read cache file")
except Exception as e:
logger.error("Exception in read_cache(): %s" % e)

def getOfficialKernels(self):

0 comments on commit 2a9885f

Please sign in to comment.