Quellcode durchsuchen

Изменён признак определения наличия обновлений: через файл /var/lib

tags/3.5.0_alpha4
Ursprung
Commit
13279e6107
2 geänderte Dateien mit 27 neuen und 9 gelöschten Zeilen
  1. +18
    -4
      pym/update/update.py
  2. +9
    -5
      pym/update/update_info.py

+ 18
- 4
pym/update/update.py Datei anzeigen

@@ -23,7 +23,7 @@ import time
from calculate.core.server.gen_pid import search_worked_process
from calculate.core.setup_cache import Cache as SetupCache
from calculate.core.server.func import MethodsInterface
from calculate.lib.cl_template import SystemIni
from calculate.lib.cl_template import SystemIni, LayeredIni
from calculate.lib.datavars import DataVarsError

from calculate.lib.utils.tools import AddonError
@@ -49,7 +49,8 @@ from calculate.lib.utils.portage import (Layman, EmergeLog,
Colors = TextState.Colors
from calculate.lib.utils.files import (getProgPath, STDOUT, removeDir,
PercentProgress, process, getRunCommands,
readFile, listDirectory)
readFile, listDirectory, pathJoin,
writeFile)
import emerge_parser
import logging
from emerge_parser import (EmergeParser, EmergeCommand, EmergeError,
@@ -221,7 +222,7 @@ class Update(MethodsInterface):
if not status:
self.printWARNING(_("Updates autocheck is not enabled"))
return False
last_check = SystemIni().getVar('update', 'last_check') or ""
last_check = SystemIni(self.clVars).getVar('update', 'last_check') or ""
re_interval = re.compile("^(\d+)\s*(hours?|days?|weeks?)?", re.I)
interval_match = re_interval.search(interval)
MINUTE = 60
@@ -779,7 +780,7 @@ class Update(MethodsInterface):
"""
Установить отметку о запуске запланированной проверки
"""
SystemIni().setVar('update', {'last_check': str(int(time.time()))})
SystemIni(self.clVars).setVar('update', {'last_check': str(int(time.time()))})

def get_default_emerge_opts(self):
return self.clVars.Get('cl_emerge_default_opts')
@@ -1172,10 +1173,23 @@ class Update(MethodsInterface):
:return:
"""
hosts = self.clVars.Get("update.cl_update_binhost_host")
datas = self.clVars.Get("update.cl_update_binhost_revisions")
bin_cache_fn = pathJoin(self.clVars.Get('cl_chroot_path'),
LayeredIni.IniPath.Grp)
if not hosts:
self.clVars.Delete('cl_update_binhost', location="system")
try:
if path.exists(bin_cache_fn):
os.unlink(bin_cache_fn)
except OSError:
raise UpdateError(
_("Failed to clear ini cache of binary repository"))

raise UpdateError(_("Failed to find the server with "
"appropriate updates"))
else:
with writeFile(bin_cache_fn) as f:
f.write(datas[0].strip()+"\n")
if write_binhost:
if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
self.refresh_binhost = True


+ 9
- 5
pym/update/update_info.py Datei anzeigen

@@ -28,8 +28,7 @@ class UpdateInfo(object):
"""
Информационный объект о процессе обновления
"""
section = "update"
varname = "updates"
update_file = "/var/lib/calculate/calculate-update/updates.available"

def __init__(self, dv=None):
if dv is None:
@@ -46,15 +45,20 @@ class UpdateInfo(object):
"""
Проверить есть ли обновления по ini.env
"""
return SystemIni().getVar(cls.section, cls.varname) == u'on'
return path.exists(cls.update_file)

@classmethod
def set_update_ready(cls, value):
"""
Установить статус обновления
"""
SystemIni().setVar(cls.section,
{cls.varname:"on" if value else "off"})
try:
if value:
writeFile(cls.update_file).close()
else:
os.unlink(cls.update_file)
except OSError:
pass

def check_for_dispatch(self):
"""


Laden…
Abbrechen
Speichern