diff --git a/libraries/entropy.py b/libraries/entropy.py index dcd5d313f..038f5545b 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -1453,7 +1453,8 @@ class EquoInterface(TextInterface): matchRepo = None, server_repos = [], serverInstance = None, - extendedResults = False + extendedResults = False, + useCache = True ): if not server_repos: @@ -1465,29 +1466,28 @@ class EquoInterface(TextInterface): if self.xcache: - if matchRepo and (type(matchRepo) in (list,tuple,set)): + if matchRepo and isinstance(matchRepo,(list,tuple,set,)): u_hash = hash(tuple(matchRepo)) else: u_hash = hash(matchRepo) - z_hash = "0" - if extendedResults: - z_hash = "1" - c_hash = str(hash(atom)) + \ - str(hash(matchSlot)) + \ + c_hash = str(atom) + \ + str(matchSlot) + \ str(hash(tuple(matchBranches))) + \ - str(hash(packagesFilter)) + \ + str(packagesFilter) + \ str(hash(tuple(self.validRepositories))) + \ str(hash(tuple(etpRepositories.keys()))) + \ - str(hash(multiMatch)) + \ - str(hash(multiRepo)) + \ - str(hash(caseSensitive)) + \ - str(hash(matchRevision)) + \ - z_hash + \ + str(multiMatch) + \ + str(multiRepo) + \ + str(caseSensitive) + \ + str(matchRevision) + \ + str(extendedResults) + \ str(u_hash) c_hash = str(hash(c_hash)) - cached = self.dumpTools.loadobj(etpCache['atomMatch']+c_hash) - if cached != None: - return cached + + if useCache: + cached = self.dumpTools.loadobj(etpCache['atomMatch']+c_hash) + if cached != None: + return cached if server_repos: if not serverInstance: @@ -1496,8 +1496,8 @@ class EquoInterface(TextInterface): valid_repos = server_repos[:] else: valid_repos = self.validRepositories - if matchRepo and (type(matchRepo) in (list,tuple,set)): - valid_repos = list(matchRepo) + if matchRepo and (type(matchRepo) in (list,tuple,set)): + valid_repos = list(matchRepo) def open_db(repoid): if server_repos: @@ -1517,7 +1517,7 @@ class EquoInterface(TextInterface): # search dbconn = open_db(repo) - use_cache = True + use_cache = useCache while 1: try: query = dbconn.atomMatch( @@ -2752,22 +2752,34 @@ class EquoInterface(TextInterface): # check against broken entries, or removed during iteration if mystrictdata == None: continue - try: - match = self.atomMatch( - mystrictdata[0], - matchSlot = mystrictdata[1], - matchBranches = (branch,), - extendedResults = True - ) - except dbapi2.OperationalError: - # ouch, but don't crash here - continue + use_match_cache = True + do_continue = False + while 1: + try: + match = self.atomMatch( + mystrictdata[0], + matchSlot = mystrictdata[1], + matchBranches = (branch,), + extendedResults = True, + useCache = use_match_cache + ) + except dbapi2.OperationalError: + # ouch, but don't crash here + do_continue = True + break + try: + idpackage = match[0][0] + except TypeError: + if not use_match_cache: raise + use_match_cache = False + continue + break + if do_continue: continue # now compare # version: mystrictdata[2] # tag: mystrictdata[3] # revision: mystrictdata[4] - if (match[0][0] != -1): - idpackage = match[0][0] + if (idpackage != -1): repoid = match[1] version = match[0][1] tag = match[0][2] @@ -6005,6 +6017,14 @@ class RepoInterface: mytxt = _("A valid Equo instance or subclass is needed") raise exceptionTools.IncorrectParameter("IncorrectParameter: %s" % (mytxt,)) + self.supported_download_items = ( + "db","rev","ck", + "lock","mask","dbdump", + "dbdumpck","lic_whitelist","make.conf", + "package.mask","package.unmask","package.keywords","profile.link", + "package.use","server.cert","ca.cert", + "notice_board" + ) self.big_socket_timeout = 25 self.Entropy = EquoInstance self.dbapi2 = dbapi2 @@ -6055,8 +6075,8 @@ class RepoInterface: port = etpRepositories[repository]['service_port'] try: - self.eapi3_socket = RepositorySocketClientInterface( - self.Entropy, EntropyRepositorySocketClientCommands, output_header = "\t" + self.eapi3_socket = SystemSocketClientInterface( + self.Entropy, RepositorySocketClientCommands, output_header = "\t" ) self.eapi3_socket.socket_timeout = self.big_socket_timeout self.eapi3_socket.connect(dburl, port) @@ -6119,27 +6139,17 @@ class RepoInterface: def __construct_paths(self, item, repo, cmethod): - supported_items = ( - "db","rev","ck", - "lock","mask","dbdump", - "dbdumpck","lic_whitelist","make.conf", - "package.mask","package.unmask","package.keywords","profile.link", - "package.use","server.cert","ca.cert", - ) - if item not in supported_items: - mytxt = _("Supported items: %s") % (supported_items,) + if item not in self.supported_download_items: + mytxt = _("Supported items: %s") % (self.supported_download_items,) raise exceptionTools.InvalidData("InvalidData: %s" % (mytxt,)) - - if item == "db": - if cmethod == None: + if (item in ("db","dbdump", "dbdumpck",)) and (cmethod == None): mytxt = _("For %s, cmethod can't be None") % (item,) raise exceptionTools.InvalidData("InvalidData: %s" % (mytxt,)) + + if item == "db": url = etpRepositories[repo]['database'] + "/" + etpConst[cmethod[2]] filepath = etpRepositories[repo]['dbpath'] + "/" + etpConst[cmethod[2]] elif item == "dbdump": - if cmethod == None: - mytxt = _("For %s, cmethod can't be None") % (item,) - raise exceptionTools.InvalidData("InvalidData: %s" % (mytxt,)) url = etpRepositories[repo]['database'] + "/" + etpConst[cmethod[3]] filepath = etpRepositories[repo]['dbpath'] + "/" + etpConst[cmethod[3]] elif item == "rev": @@ -6149,8 +6159,6 @@ class RepoInterface: url = etpRepositories[repo]['database'] + "/" + etpConst['etpdatabasehashfile'] filepath = etpRepositories[repo]['dbpath'] + "/" + etpConst['etpdatabasehashfile'] elif item == "dbdumpck": - if cmethod == None: - raise exceptionTools.InvalidData("InvalidData: for db, cmethod can't be None") url = etpRepositories[repo]['database'] + "/" + etpConst[cmethod[4]] filepath = etpRepositories[repo]['dbpath'] + "/" + etpConst[cmethod[4]] elif item == "mask": @@ -6192,6 +6200,9 @@ class RepoInterface: elif item == "ca.cert": url = etpRepositories[repo]['database'] + "/" + etpConst['etpdatabaseservercertfile'] filepath = etpRepositories[repo]['dbpath'] + "/" + etpConst['etpdatabaseservercertfile'] + elif item == "notice_board": + url = etpRepositories[repo]['notice_board'] + filepath = etpRepositories[repo]['dbpath'] + "/" + os.path.basename(etpRepositories[repo]['notice_board']) return url, filepath @@ -7398,6 +7409,16 @@ class RepoInterface: darkgreen(etpConst['spm']['global_make_profile_link_name']), red("..."), ) + ), + ( + "notice_board", + os.path.basename(etpRepositories[repo]['notice_board']), + True, + "%s %s %s" % ( + red(_("Downloading Notice Board")), + darkgreen(os.path.basename(etpRepositories[repo]['notice_board'])), + red("..."), + ) ) ] @@ -12642,7 +12663,7 @@ class SocketHostInterface: import entropyTools - def __init__(self, HostInterface): + def __init__(self, HostInterface, *args, **kwargs): self.valid_auth_types = [ "plain", "shadow", "md5" ] SocketAuthenticatorSkel.__init__(self, HostInterface) @@ -13410,7 +13431,7 @@ class SocketHostInterface: if logged_in != None: uid = logged_in gid = etpConst['entropygid'] - return self.entropyTools.spawnFunction(self._do_fork, authenticator, f, uid, gid, *args, **kwargs) + return self.entropyTools.spawnFunction(self._do_fork, f, authenticator, uid, gid, *args, **kwargs) def _do_fork(self, f, authenticator, uid, gid, *args, **kwargs): authenticator.set_exc_permissions(uid,gid) @@ -13431,7 +13452,7 @@ class SocketHostInterface: 'auth': False, # does it need authentication ? 'built_in': True, # is it built-in ? 'cb': self.docmd_begin, # function to call - 'args': ["self.transmit", "self.client_address"], # arguments to be passed before *args and **kwards + 'args': ["self.transmit", "self.client_address"], # arguments to be passed before *args and **kwards, in SocketHostInterface.do_spawn() 'as_user': False, # do I have to fork the process and run it as logged user? # needs auth = True 'desc': "instantiate a session", # description @@ -13458,17 +13479,6 @@ class SocketHostInterface: 'syntax': " session_config