Skip to content

Commit

Permalink
fix code smell issues
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmazzeschi committed May 15, 2023
1 parent 09494ec commit 183373d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions BG-from-NASA.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
from linuxdesktop import linuxdesktop
import subprocess

def doBGfromNASA():
def do_bg_from_nasa():
url = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
jsonData = urllib.request.urlopen(url).read()
contents = json.loads(jsonData)
imgUrl = contents['hdurl']
json_data = urllib.request.urlopen(url).read()
contents = json.loads(json_data)
img_url = contents['hdurl']
title = contents['title']
print('found ' + title + " at " + imgUrl)
print('found ' + title + " at " + img_url)
f = tempfile.NamedTemporaryFile(delete=True, suffix='.jpg')
f.write(urllib.request.urlopen(imgUrl).read())
f.write(urllib.request.urlopen(img_url).read())
f.flush()
img = Image.open(f)

Expand All @@ -31,7 +31,7 @@ def doBGfromNASA():
if (factor < 1):
factor = 1.0 /factor
img = img.resize((int(w / factor), int(h/factor)), Image.Resampling.LANCZOS)
f2 = tempfile.NamedTemporaryFile(delete=True, suffix='.jpg')
#f2 = tempfile.NamedTemporaryFile(delete=True, suffix='.jpg')
f2 = open("/tmp/test.jpg", mode="w")
# make a blank image for the text, initialized to transparent text color
txt = Image.new("RGBA", img.size, (255,255,255,0))
Expand Down Expand Up @@ -66,4 +66,4 @@ def doBGfromNASA():
lde.set_wallpaper(file_loc=f2.name, first_run=1)
print("done")
if __name__ == "__main__":
doBGfromNASA()
do_bg_from_nasa()

0 comments on commit 183373d

Please sign in to comment.