Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download images for "Schlaflos im Ländle" geocache as described at <http://www.geocaching.com/seek/cache_details.aspx?guid=3052c599-c8bb-4bff-a209-7b23b98bdb1c>. To obtain the required images, start the program sometime around 21:45 CET and let it run until 05:30 CET. You can start it earlier or stop it later but then you might have to ignore so…
'''
Download images for "Schlaflos im Ländle" geocache as described at
<http://www.geocaching.com/seek/cache_details.aspx?guid=3052c599-c8bb-4bff-a209-7b23b98bdb1c>.
To obtain the required images, start the program sometime around 21:45 CET and let it run
until 05:30 CET. You can start it earlier or stop it later but then you might have to ignore
some of the images.
'''
import logging
import os
import time
import urllib2
from contextlib import closing
_log = logging.getLogger('schlaflos')
def _download_image():
temp_path = os.environ.get('TEMP', os.environ.get('TMPDIR', os.environ.get('TMP')))
target_path = os.path.join(temp_path, time.strftime('schlaflos_%H_%M_%S.jpg'))
_log.info('download "%s"', target_path)
with closing(urllib2.urlopen('http://www.auwe.at/Bild_Default.jpg')) as stream:
with open(target_path, 'wb') as target_file:
target_file.write(stream.read())
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
while True:
_download_image()
time.sleep(30*60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.