def calcCurrHash(): treeHash = githash.tree_hash(addonDir).hexdigest() logger.info('tree hash: ' + treeHash) commits = loadCommits() lastCommitSha = commits[0]['sha'] page = 1 while commits and page <= maxPage: found = False for n, c in enumerate(commits): if c['commit']['tree']['sha'] == treeHash: localCommitFile = open(os.path.join(addonDir, trackingFile), 'w') localCommitFile.write(c['sha']) localCommitFile.close() found = True break else: page += 1 commits = loadCommits(page) if found: break else: logger.info( 'Non sono riuscito a trovare il commit attuale, scarico lo zip') hash = updateFromZip() # se ha scaricato lo zip si trova di sicuro all'ultimo commit localCommitFile = open( os.path.join(xbmc.translatePath("special://home/addons/"), 'plugin.video.kod', trackingFile), 'w') localCommitFile.write(hash if hash else lastCommitSha) localCommitFile.close()
def calcCurrHash(): from lib import githash treeHash = githash.tree_hash(addonDir).hexdigest() commits = loadCommits() page = 1 while commits and page <= maxPage: found = False for n, c in enumerate(commits): if c['commit']['tree']['sha'] == treeHash: localCommitFile = open(addonDir + trackingFile, 'w') localCommitFile.write(c['sha']) localCommitFile.close() found = True break else: page += 1 commits = loadCommits(page) if found: break else: logger.info( 'Non sono riuscito a trovare il commit attuale, scarico lo zip') updateFromZip() calcCurrHash()