Skip to content

Commit

Permalink
Update base.py for issue #182, #186 (#183)
Browse files Browse the repository at this point in the history
* Update base.py

Changed the way `sum` was computed in `getImagesTotal()` to avoid black screen with "no (new) images could be found" in the warning log.

* Update display.py

Fix Fill and Do Nothing image handling.

* Update base.py

Addresses #186
  • Loading branch information
Tom Anschutz committed Jun 27, 2021
1 parent 9ddcf45 commit af9881a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions modules/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ def image(self, filename):
args = [
'convert',
filename + '[0]',
'-resize',
'%dx%d' % (self.width, self.height),
'-background',
'black',
'-gravity',
Expand Down
6 changes: 4 additions & 2 deletions services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ def getId(self):

def getImagesTotal(self):
# return the total number of images provided by this service
sum = 0
if self.needKeywords():
for keyword in self.getKeywords():
if keyword not in self._STATE["_NUM_IMAGES"] or keyword not in self._STATE['_NEXT_SCAN'] or self._STATE['_NEXT_SCAN'][keyword] < time.time():
logging.debug('Keywords either not scanned or we need to scan now')
self._getImagesFor(keyword) # Will make sure to get images
self._STATE['_NEXT_SCAN'][keyword] = time.time() + self.REFRESH_DELAY
return sum([self._STATE["_NUM_IMAGES"][k] for k in self._STATE["_NUM_IMAGES"]])
sum = sum + self._STATE["_NUM_IMAGES"][keyword]
return sum

def getImagesSeen(self):
count = 0
Expand Down Expand Up @@ -694,7 +696,7 @@ def requestUrl(self, url, destination=None, params=None, data=None, usePost=Fals
break
except:
logging.exception('Issues downloading')
time.sleep(tries / 10) # Back off 10, 20, ... depending on tries
time.sleep(tries * 10) # Back off 10, 20, ... depending on tries
tries += 1
logging.warning('Retrying again, attempt #%d', tries)

Expand Down

0 comments on commit af9881a

Please sign in to comment.