rename pull functions to fetch and add new pull function

This commit is contained in:
fram3d 2024-04-08 00:40:43 +02:00
parent 334716f370
commit e19fc234f4
Signed by: fram3d
GPG Key ID: 938920E709EEA32A

43
lgit.py
View File

@ -256,8 +256,8 @@ l dc values from base
return basecopy return basecopy
def pullfrom(self, source)->int: def fetchfrom(self, source)->int:
pulled = 0 fetched = 0
basecopy = self.getbasecopy(source) basecopy = self.getbasecopy(source)
self.refreshtotal(basecopy) self.refreshtotal(basecopy)
@ -273,9 +273,9 @@ l dc values from base
attributes = log['attributes'] attributes = log['attributes']
self.setlog(attributes, basecopy) self.setlog(attributes, basecopy)
pulled += 1 fetched += 1
return pulled return fetched
def applyfrom(self, source)->int: def applyfrom(self, source)->int:
basecopy = self.getbasecopy(source) basecopy = self.getbasecopy(source)
@ -284,6 +284,12 @@ l dc values from base
return appliedlogs return appliedlogs
def pullfrom(self, source)->int:
self.fetchfrom(source)
applied = self.applyfrom(source)
return applied
def lastpwchangenow(self): def lastpwchangenow(self):
''' '''
Return time of last password change for the user set to current time Return time of last password change for the user set to current time
@ -304,22 +310,22 @@ class lgit():
self.servers.remove(log_server) self.servers.remove(log_server)
return self.servers return self.servers
def pullfromall(self, log_server: logserver)->int: def fetchfromall(self, log_server: logserver)->int:
pulledlogs = 0 fetchedlogs = 0
for source in self.servers: for source in self.servers:
if source != log_server: if source != log_server:
pulledlogs += log_server.pullfrom(source) fetchedlogs += log_server.fetchedfrom(source)
return pulledlogs return pulledlogs
def pull(self)->int: def fetch(self)->int:
pulledlogs = 0 fetchedlogs = 0
for server in self.servers: for server in self.servers:
pulledlogs += self.pullfromall(server) fetchedlogs += self.fetchfromall(server)
return pulledlogs return fetchedlogs
def applyfromall(self, log_server: logserver)->int: def applyfromall(self, log_server: logserver)->int:
appliedlogs = 0 appliedlogs = 0
@ -338,8 +344,19 @@ class lgit():
return appliedlogs return appliedlogs
def pullfromall(self, log_server: logserver)->int:
self.fetchfromall(log_server)
pulled = self.applyfromall(log_server)
return pulled
def pull(self)->int:
self.fetch()
pulled = self.apply()
return pulled
def sync(self)->int: def sync(self)->int:
pulledlogs = self.pull() pulledlogs = self.pull()
appliedlogs = self.apply()
return appliedlogs return pulledlogs