Skip to content

Commit

Permalink
append the date to the output file's name
Browse files Browse the repository at this point in the history
...to make it work on OS X without restarting the dock.
  • Loading branch information
boramalper committed Aug 16, 2016
1 parent 6da41e5 commit b154663
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 2 additions & 6 deletions himawaripy/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os.path

import appdirs

# Increases the quality and the size. Possible values: 4, 8, 16, 20
Expand All @@ -13,10 +11,8 @@
auto_offset = True
hour_offset = 0

# Path to the output file
output_file = os.path.join(appdirs.user_cache_dir(appname="himawaripy",
appauthor=False),
"latest.png")
# Path to the output directory
output_dir = appdirs.user_cache_dir(appname="himawaripy", appauthor=False)

# Deadline for the whole download process in minutes
dl_deadline = 6
11 changes: 8 additions & 3 deletions himawaripy/himawaripy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
from itertools import product
from json import loads
from multiprocessing import Pool, cpu_count, Value
from os import makedirs
from os.path import dirname
from os import makedirs, remove
from os.path import dirname, join
from time import strptime, strftime, mktime
from urllib.request import urlopen
from socket import timeout as TimeoutException
from glob import iglob

from PIL import Image
from pytz import timezone
from dateutil.tz import tzlocal

from .config import level, output_file, auto_offset, hour_offset , dl_deadline
from .config import level, output_dir, auto_offset, hour_offset , dl_deadline
from .utils import set_background, get_desktop_environment

counter = None
Expand Down Expand Up @@ -101,6 +102,10 @@ def main():
tile = Image.open(BytesIO(tiledata))
png.paste(tile, (width * x, height * y, width * (x + 1), height * (y + 1)))

for file in iglob(join(output_dir, "himawari-*.png")):
remove(file)

output_file = join(output_dir, strftime("himawari-%Y%m%dT%H%M%S.png", requested_time))
print("\nSaving to '%s'..." % (output_file))
makedirs(dirname(output_file), exist_ok=True)
png.save(output_file, "PNG")
Expand Down

0 comments on commit b154663

Please sign in to comment.