Changed version update logik

This commit is contained in:
piair 2024-04-26 14:32:01 +02:00
parent 9bcbc81c2f
commit 127d16afea
3 changed files with 24 additions and 12 deletions

12
V6.py
View File

@ -642,19 +642,23 @@ def fidelity():
pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]')
pause.click()
except Exception as e:
error(f"Error while clicking pause. Probably no cards. {e}")
return "no cards"
debug("No pause button.")
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
nb_cartes = len(cartes)
if nb_cartes == 0:
warning("No fidelity cards detected")
return "No cards."
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
for i in range(nb_cartes):
cartes[i].click()
checked_txt = checked_list_all[i].get_attribute("innerHTML")
ok = checked_txt.count("StatusCircleOuter checkmark")
total = checked_txt.count("StatusCircleOuter")
if (ok != total):
if ok != total:
elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i]
if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card
# legacy code. Should be removed
if "moviesandtv" not in elm.get_attribute("innerHTML"): # not the film card
elm.click()
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sub_fidelity()

View File

@ -22,7 +22,8 @@ class Config:
proxy = json.load(inFile)
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
config = json.load(inFile)
with open("/app/MsRewards-reborn/user_data/version", "r") as inFile:
version = inFile.readline()
"""
setup standalone stuff
"""
@ -34,7 +35,7 @@ class Config:
self.version = args.update_version
self.WebDriver = Driver()
self.display = None
self.version = version
"""
setup UserCredential
"""
@ -81,4 +82,10 @@ class Config:
self.display = display
def has_been_updated(self):
return self.version != "None"
with open('/app/MsRewards-Reborn/version', "r") as inFile:
if self.version != inFile.readline():
self.version = inFile.readline()
with open('/app/MsRewards-Reborn/user_data/version', "w") as outFile:
outFile.write(self.version)
return True
return False

1
user_data/version Normal file
View File

@ -0,0 +1 @@
0.0.0