Skip to content

Commit

Permalink
Merge pull request #427 from XayOn/Matrix
Browse files Browse the repository at this point in the history
fix: #426 time.clock() deprecated since python3.3
  • Loading branch information
maloep committed Sep 9, 2020
2 parents fbaccd7 + ef82f82 commit ea55684
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions resources/lib/dbupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def updateDB(self, gdb, gui, romCollections, isRescrape):
#Give kodi a chance to interrupt the process
#HACK: we should use monitor.abortRequested() or monitor.waitForAbort()
#but for some reason only xbmc.abortRequested returns True
if monitor.abortRequested() or xbmc.abortRequested:
if monitor.abortRequested():
log.info("Kodi requests abort. Cancel Update.")
break

Expand Down Expand Up @@ -229,7 +229,7 @@ def updateDB(self, gdb, gui, romCollections, isRescrape):
#Give kodi a chance to interrupt the process
#HACK: we should use monitor.abortRequested() or monitor.waitForAbort()
#but for some reason only xbmc.abortRequested returns True
if monitor.abortRequested() or xbmc.abortRequested:
if monitor.abortRequested():
log.info("Kodi requests abort. Cancel Update.")
break

Expand Down
6 changes: 3 additions & 3 deletions resources/lib/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def showGames(self):

showFavoriteStars = self.Settings.getSetting(util.SETTING_RCB_SHOWFAVORITESTARS).upper() == 'TRUE'

timestamp1 = time.clock()
timestamp1 = time.process_time()

likeStatement = self._getGamesListQueryStatement()
order_by = "ORDER BY %s COLLATE NOCASE %s" %(self.sortMethod, self.sortDirection)
Expand All @@ -843,7 +843,7 @@ def showGames(self):
self.selectedMaxPlayers, self.selectedRating, self.selectedRegion,
isFavorite, likeStatement, order_by, maxNumGames)

timestamp2 = time.clock()
timestamp2 = time.process_time()
diff = (timestamp2 - timestamp1) * 1000
print ("showGames: load %d games from db in %d ms" % (len(games), diff))

Expand Down Expand Up @@ -950,7 +950,7 @@ def showGames(self):
elif int(view_mode) in VIEWS_HORIZONTAL:
self.writeMsg(util.localize(32209))

timestamp3 = time.clock()
timestamp3 = time.process_time()
diff = (timestamp3 - timestamp2) * 1000
Logutil.log("showGames: load %i games to list in %d ms" % (self.getListSize(), diff), util.LOG_LEVEL_INFO)

Expand Down
10 changes: 5 additions & 5 deletions resources/tests/test_db_gameview.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ def test_GetGamesByFilter(self):
gdb.cursor.execute("PRAGMA cache_size = 20000")

import time
timestamp1 = time.clock()
timestamp1 = time.process_time()
games = GameView(gdb).getFilteredGames(0, 0, 0, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0)
#games = Game(gdb).getAll()
timestamp2 = time.clock()
timestamp2 = time.process_time()
diff = (timestamp2 - timestamp1) * 1000
print ("load %d games from db in %d ms" % (len(games), diff))

timestamp1 = time.clock()
timestamp1 = time.process_time()
#Game(gdb).getGameById(5000)
row = GameView(gdb).getGameById(5000)
timestamp2 = time.clock()
timestamp2 = time.process_time()
diff = (timestamp2 - timestamp1) * 1000
print ("load 1 game from db in %d ms" % diff)


if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
unittest.main()
10 changes: 5 additions & 5 deletions resources/tests/test_imageloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ def _matchImagePattern(self, imagelist, gamenameFromFile):
pathToSearch = re.escape(os.path.normpath(pathnameFromFile.replace('.*', '')))
foundImage = ''

timestamp1 = time.clock()
timestamp1 = time.process_time()
pattern = re.compile('%s\..*$' %re.escape(gamenameFromFile))
for image in imagelist:
match = pattern.search(image)
if match:
foundImage = image

timestamp2 = time.clock()
timestamp2 = time.process_time()
diff = (timestamp2 - timestamp1) * 1000
print ('pattern.search took %s ms' %diff)

Expand All @@ -374,10 +374,10 @@ def _matchImageFilter(self, imagelist, gamenameFromFile):
pathToSearch = re.escape(os.path.normpath(pathnameFromFile.replace('.*', '')))
foundImage = ''

timestamp1 = time.clock()
timestamp1 = time.process_time()
pattern = re.compile('%s\..*$' %pathToSearch)
foundImage = list(filter(pattern.match, imagelist))
timestamp2 = time.clock()
timestamp2 = time.process_time()
diff = (timestamp2 - timestamp1) * 1000
print ('filter took %s ms' %diff)

Expand All @@ -386,4 +386,4 @@ def _matchImageFilter(self, imagelist, gamenameFromFile):

if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
unittest.main()

0 comments on commit ea55684

Please sign in to comment.