Skip to content

Commit

Permalink
Fix SSL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
abelfodil committed Dec 9, 2024
1 parent e93c62a commit 7c828b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13
python-version: 3.12
- run: python -m pip install -r requirements.txt
- run: python -m PyInstaller --onefile --noconsole randwall
- uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions connection.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from urllib.request import urlopen, Request
from requests import get
from log import get_logger
from time import sleep

logger = get_logger(__name__)

def _is_connected():
try:
urlopen(Request("https://1.1.1.1", headers={"User-Agent": "randwall/1.0"}))
get("https://1.1.1.1")
return True
except:
logger.warning("Failed to connect to the internet.")
Expand Down
13 changes: 5 additions & 8 deletions wallpaper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import json
import platform
import os

from requests import get
from log import get_logger
from urllib.request import urlopen, Request
from urllib.parse import urlencode
from config import config
import subprocess
import tempfile
Expand Down Expand Up @@ -89,9 +88,8 @@ def _get_random_wallpaper():
logger.info(f"Fetching random wallpaper from https://wallhaven.cc")

try:
with urlopen(Request(api_url + urlencode(params), headers={"User-Agent": "randwall/1.0"})) as f:
response = f.read().decode("utf-8")
data = json.loads(response)
response = get(api_url, params=params, headers={"User-Agent": "randwall/1.0"})
data = response.json()
image_data = data["data"][0]
return {
"id": image_data["id"],
Expand All @@ -110,8 +108,7 @@ def _download_wallpaper(wallpaper):
logger.info(f"Downloading {wallpaper['url']} at {image_path}")

try:
with urlopen(Request(wallpaper["path"], headers={"User-Agent": "randwall/1.0"})) as f:
image = f.read()
image = get(wallpaper["path"]).content
except:
return

Expand Down

0 comments on commit 7c828b9

Please sign in to comment.