[entropy.client] drop FileUpdates attribute, replace with Client.PackageFileUpdates() loader
This commit is contained in:
@@ -71,10 +71,11 @@ def update(entropy_client, cmd = None):
|
||||
if cmd != None:
|
||||
docmd = True
|
||||
|
||||
file_updates = entropy_client.PackageFileUpdates()
|
||||
while True:
|
||||
print_info(brown(" @@ ") + \
|
||||
darkgreen("%s ..." % (_("Scanning filesystem"),)))
|
||||
scandata = entropy_client.FileUpdates.scan(dcache = cache_status)
|
||||
scandata = file_updates.scan(dcache = cache_status)
|
||||
if cache_status:
|
||||
for x in scandata:
|
||||
print_info("("+blue(str(x))+") "+red(" %s: " % (_("file"),) ) + \
|
||||
@@ -104,8 +105,8 @@ def update(entropy_client, cmd = None):
|
||||
# automerge files asking one by one
|
||||
for key in keys:
|
||||
if not os.path.isfile(etpConst['systemroot']+scandata[key]['source']):
|
||||
entropy_client.FileUpdates.ignore(key)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.ignore(key)
|
||||
scandata = file_updates.scan()
|
||||
continue
|
||||
print_info(darkred("%s: " % (_("Configuration file"),) ) + \
|
||||
darkgreen(etpConst['systemroot']+scandata[key]['destination']))
|
||||
@@ -121,8 +122,8 @@ def update(entropy_client, cmd = None):
|
||||
brown(etpConst['systemroot'] + \
|
||||
scandata[key]['destination']))
|
||||
|
||||
entropy_client.FileUpdates.merge(key)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.merge(key)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
break
|
||||
|
||||
@@ -130,11 +131,10 @@ def update(entropy_client, cmd = None):
|
||||
for key in keys:
|
||||
|
||||
if not os.path.isfile(etpConst['systemroot']+scandata[key]['source']):
|
||||
|
||||
entropy_client.FileUpdates.ignore(key)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
|
||||
file_updates.ignore(key)
|
||||
scandata = file_updates.scan()
|
||||
continue
|
||||
|
||||
print_info(darkred("%s: " % (_("Configuration file"),) ) + \
|
||||
darkgreen(etpConst['systemroot']+scandata[key]['destination']))
|
||||
if cmd == -7:
|
||||
@@ -145,8 +145,8 @@ def update(entropy_client, cmd = None):
|
||||
print_info(darkred("%s " % (_("Discarding"),) ) + \
|
||||
darkgreen(etpConst['systemroot']+scandata[key]['source']))
|
||||
|
||||
entropy_client.FileUpdates.remove(key)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.remove(key)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
break
|
||||
|
||||
@@ -156,18 +156,18 @@ def update(entropy_client, cmd = None):
|
||||
# do files exist?
|
||||
if not os.path.isfile(etpConst['systemroot']+scandata[cmd]['source']):
|
||||
|
||||
entropy_client.FileUpdates.ignore(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.ignore(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
continue
|
||||
if not os.path.isfile(etpConst['systemroot']+scandata[cmd]['destination']):
|
||||
print_info(darkred("%s: " % (_("Automerging file"),) ) + \
|
||||
darkgreen(etpConst['systemroot']+scandata[cmd]['source']))
|
||||
|
||||
entropy_client.FileUpdates.merge(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
|
||||
file_updates.merge(cmd)
|
||||
scandata = file_updates.scan()
|
||||
continue
|
||||
|
||||
# end check
|
||||
|
||||
diff = showdiff(etpConst['systemroot']+scandata[cmd]['destination'],
|
||||
@@ -176,8 +176,8 @@ def update(entropy_client, cmd = None):
|
||||
print_info(darkred("%s " % (_("Automerging file"),) ) + \
|
||||
darkgreen(etpConst['systemroot']+scandata[cmd]['source']))
|
||||
|
||||
entropy_client.FileUpdates.merge(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.merge(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
continue
|
||||
|
||||
@@ -205,8 +205,8 @@ def update(entropy_client, cmd = None):
|
||||
scandata[cmd]['destination']) + darkred(" %s " % (_("with"),) ) + \
|
||||
darkgreen(etpConst['systemroot'] + scandata[cmd]['source']))
|
||||
|
||||
entropy_client.FileUpdates.merge(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.merge(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
comeback = True
|
||||
break
|
||||
@@ -217,8 +217,8 @@ def update(entropy_client, cmd = None):
|
||||
scandata[cmd]['source'])
|
||||
)
|
||||
|
||||
entropy_client.FileUpdates.remove(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.remove(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
comeback = True
|
||||
break
|
||||
@@ -246,8 +246,8 @@ def update(entropy_client, cmd = None):
|
||||
print_info(darkred("%s " % (_("Automerging file"),) ) + \
|
||||
darkgreen(scandata[cmd]['source']))
|
||||
|
||||
entropy_client.FileUpdates.merge(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.merge(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
comeback = True
|
||||
break
|
||||
@@ -270,8 +270,8 @@ def update(entropy_client, cmd = None):
|
||||
os.rename(merge_outcome_path, source)
|
||||
except OSError:
|
||||
shutil.move(merge_outcome_path, source)
|
||||
entropy_client.FileUpdates.merge(cmd)
|
||||
scandata = entropy_client.FileUpdates.scan()
|
||||
file_updates.merge(cmd)
|
||||
scandata = file_updates.scan()
|
||||
|
||||
comeback = True
|
||||
break
|
||||
@@ -380,7 +380,7 @@ def interactive_merge(source, destination):
|
||||
'''
|
||||
def confinfo(entropy_client):
|
||||
print_info(brown(" @@ ")+darkgreen(_("These are the files that would be updated:")))
|
||||
data = entropy_client.FileUpdates.scan(dcache = False)
|
||||
data = entropy_client.PackageFileUpdates().scan(dcache = False)
|
||||
counter = 0
|
||||
for item in data:
|
||||
counter += 1
|
||||
|
||||
+2
-2
@@ -289,10 +289,10 @@ def show_config_files_to_update(entropy_client):
|
||||
blue(_("Scanning configuration files to update")), back = True)
|
||||
|
||||
try:
|
||||
file_updates = entropy_client.PackageFileUpdates()
|
||||
while True:
|
||||
try:
|
||||
scandata = entropy_client.FileUpdates.scan(
|
||||
dcache = True, quiet = True)
|
||||
scandata = file_updates.scan(dcache = True, quiet = True)
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
continue
|
||||
|
||||
@@ -616,7 +616,6 @@ class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixi
|
||||
self.sys_settings_client_plugin_id = \
|
||||
etpConst['system_settings_plugins_ids']['client_plugin']
|
||||
|
||||
self.FileUpdates = None
|
||||
self._enabled_repos = []
|
||||
self.UGC = None
|
||||
self.safe_mode = 0
|
||||
@@ -647,9 +646,6 @@ class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixi
|
||||
|
||||
self._cacher = EntropyCacher()
|
||||
|
||||
from entropy.client.misc import FileUpdates
|
||||
self.FileUpdates = FileUpdates(self)
|
||||
|
||||
if noclientdb in (False, 0):
|
||||
self.noclientdb = False
|
||||
elif noclientdb in (True, 1):
|
||||
|
||||
@@ -26,10 +26,12 @@ class LoadersMixin:
|
||||
from entropy.client.interfaces.repository import Repository
|
||||
from entropy.client.interfaces.package import Package
|
||||
from entropy.client.interfaces.sets import Sets
|
||||
from entropy.client.misc import FileUpdates
|
||||
self.__package_loader = Package
|
||||
self.__repository_loader = Repository
|
||||
self.__trigger_loader = Trigger
|
||||
self.__sets_loader = Sets
|
||||
self.__package_files_loader = FileUpdates
|
||||
|
||||
def Sets(self):
|
||||
"""
|
||||
@@ -117,6 +119,16 @@ class LoadersMixin:
|
||||
"""
|
||||
return self.__package_loader(self)
|
||||
|
||||
def PackageFileUpdates(self):
|
||||
"""
|
||||
Load Entropy Package Files instance object. Through this interface,
|
||||
you can scan for package files updates (usually configuration files)
|
||||
and let user merge, remove them interactively.
|
||||
|
||||
@rtype: entropy.client.misc.FileUpdates
|
||||
"""
|
||||
return self.__package_files_loader(self)
|
||||
|
||||
def Settings(self):
|
||||
"""
|
||||
Return SystemSettings instance object
|
||||
|
||||
@@ -2482,7 +2482,8 @@ class Package:
|
||||
|
||||
if protected:
|
||||
# add to disk cache
|
||||
self._entropy.FileUpdates.add(tofile, quiet = True)
|
||||
file_updates = self._entropy.PackageFileUpdates()
|
||||
file_updates.add(tofile, quiet = True)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -4824,7 +4824,8 @@ class Server(Client):
|
||||
back = True
|
||||
)
|
||||
# scanning for config files not updated
|
||||
scandata = self.FileUpdates.scan(dcache = False)
|
||||
file_updates = self.PackageFileUpdates()
|
||||
scandata = file_updates.scan(dcache = False)
|
||||
if scandata:
|
||||
self.output(
|
||||
"[%s] %s" % (
|
||||
|
||||
@@ -226,6 +226,12 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
|
||||
self.gtk_loop()
|
||||
gobject.idle_add(_pkg_install)
|
||||
|
||||
def _get_file_updates(self):
|
||||
# delayed loading, use cache.
|
||||
if not hasattr(self, "_file_updates"):
|
||||
self._file_updates = self._entropy.PackageFileUpdates()
|
||||
return self._file_updates
|
||||
|
||||
def quit(self, widget = None, event = None, sysexit = 0):
|
||||
|
||||
def do_kill(pid):
|
||||
@@ -1384,7 +1390,8 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
|
||||
def _populate_files_update(self):
|
||||
# load filesUpdate interface and fill self.filesView
|
||||
with self._privileges:
|
||||
cached = self._entropy.FileUpdates.scan(quiet = True)
|
||||
file_updates = self._get_file_updates()
|
||||
cached = file_updates.scan(quiet = True)
|
||||
if cached:
|
||||
self.filesView.populate(cached)
|
||||
|
||||
@@ -2105,10 +2112,11 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
|
||||
if direct_install_matches is None:
|
||||
direct_install_matches = []
|
||||
self.show_progress_bars()
|
||||
file_updates = self._get_file_updates()
|
||||
|
||||
def do_file_updates_check():
|
||||
self._entropy.FileUpdates.scan(dcache = False, quiet = True)
|
||||
fs_data = self._entropy.FileUpdates.scan()
|
||||
file_updates.scan(dcache = False, quiet = True)
|
||||
fs_data = file_updates.scan()
|
||||
if fs_data:
|
||||
if len(fs_data) > 0:
|
||||
switch_back_page = 'filesconf'
|
||||
|
||||
+19
-14
@@ -175,46 +175,50 @@ class SulfurApplicationEventsMixin:
|
||||
if not identifier:
|
||||
return True
|
||||
with self._privileges:
|
||||
file_updates = self._get_file_updates()
|
||||
try:
|
||||
self._entropy.FileUpdates.remove(identifier)
|
||||
file_updates.remove(identifier)
|
||||
except KeyError:
|
||||
pass # cope with multithreading requests
|
||||
self.filesView.populate(self._entropy.FileUpdates.scan())
|
||||
self.filesView.populate(file_updates.scan())
|
||||
|
||||
def on_filesMerge_clicked( self, widget ):
|
||||
identifier, source, dest = self._get_Edit_filename()
|
||||
if not identifier:
|
||||
return True
|
||||
with self._privileges:
|
||||
file_updates = self._get_file_updates()
|
||||
try:
|
||||
self._entropy.FileUpdates.merge(identifier)
|
||||
file_updates.merge(identifier)
|
||||
except KeyError:
|
||||
pass # code with multithreaded requests
|
||||
self.filesView.populate(self._entropy.FileUpdates.scan())
|
||||
self.filesView.populate(file_updates.scan())
|
||||
|
||||
def on_mergeFiles_clicked( self, widget ):
|
||||
with self._privileges:
|
||||
self._entropy.FileUpdates.scan(dcache = True)
|
||||
keys = list(self._entropy.FileUpdates.scan().keys())
|
||||
file_updates = self._get_file_updates()
|
||||
file_updates.scan(dcache = True)
|
||||
keys = list(file_updates.scan().keys())
|
||||
for key in keys:
|
||||
try:
|
||||
self._entropy.FileUpdates.merge(key)
|
||||
file_updates.merge(key)
|
||||
# it's cool watching it runtime
|
||||
except KeyError:
|
||||
pass
|
||||
self.filesView.populate(self._entropy.FileUpdates.scan())
|
||||
self.filesView.populate(file_updates.scan())
|
||||
|
||||
def on_deleteFiles_clicked( self, widget ):
|
||||
with self._privileges:
|
||||
self._entropy.FileUpdates.scan(dcache = True)
|
||||
keys = list(self._entropy.FileUpdates.scan().keys())
|
||||
file_updates = self._get_file_updates()
|
||||
file_updates.scan(dcache = True)
|
||||
keys = list(file_updates.scan().keys())
|
||||
for key in keys:
|
||||
try:
|
||||
self._entropy.FileUpdates.remove(key)
|
||||
file_updates.remove(key)
|
||||
# it's cool watching it runtime
|
||||
except KeyError:
|
||||
pass
|
||||
self.filesView.populate(self._entropy.FileUpdates.scan())
|
||||
self.filesView.populate(file_updates.scan())
|
||||
|
||||
def on_filesEdit_clicked( self, widget ):
|
||||
identifier, source, dest = self._get_Edit_filename()
|
||||
@@ -257,8 +261,9 @@ class SulfurApplicationEventsMixin:
|
||||
|
||||
def on_filesViewRefresh_clicked( self, widget ):
|
||||
with self._privileges:
|
||||
self._entropy.FileUpdates.scan(dcache = False)
|
||||
self.filesView.populate(self._entropy.FileUpdates.scan())
|
||||
file_updates = self._get_file_updates()
|
||||
file_updates.scan(dcache = False)
|
||||
self.filesView.populate(file_updates.scan())
|
||||
|
||||
def on_shiftUp_clicked( self, widget ):
|
||||
idx, repoid, iterdata = self._get_selected_repo_index()
|
||||
|
||||
Reference in New Issue
Block a user