Skip to content

Commit

Permalink
Fixed to reuse forever the same image in case of failure.
Browse files Browse the repository at this point in the history
 - Fixed to reuse the same image forever, creating overlapped info
   over it.
  • Loading branch information
helioloureiro committed Jun 26, 2016
1 parent 75176f5 commit 6ff6c1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion weather-twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from picturequality import brightness
import re
from random import randint
import shutil

# stop annoying messages
# src: http://stackoverflow.com/questions/11029717/how-do-i-disable-log-messages-from-the-requests-library
Expand Down Expand Up @@ -52,6 +53,7 @@
mypid = os.getpid()
lockfile = "%s/%s.%d" % (LOCKDIR, LOCKPREFIX, mypid)
plock = threading.Lock() # control print
failed_img = "%s.failed_img.jpg" % sys.argv[0]

def debug(msg):
if DEBUG:
Expand Down Expand Up @@ -137,7 +139,9 @@ def getfailedimg():
IMGS.append("%s/%s" % (FAILDIR, filename) )
# get a randomic one
pos = randint(0, len(IMGS) - 1)
return IMGS[pos]
chosen_one = IMGS[pos]
shutil.copy(chosen_one, failed_img)
return failed_img

def ReadConfig():
global cons_key, cons_sec, acc_key, acc_sec, wth_key, wth_loc
Expand Down

0 comments on commit 6ff6c1c

Please sign in to comment.