Skip to content

Commit

Permalink
better scheduling and more robust secret reading
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann committed Aug 20, 2022
1 parent f60bc22 commit 88ac294
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
secret.txt
pics
ENV
*.log
6 changes: 4 additions & 2 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
account = account[1:]

with open(secret) as f:
secret = f.read()
secret = f.read().strip()

mastodon = Mastodon(
access_token = secret,
Expand Down Expand Up @@ -49,7 +49,9 @@
file = os.path.join(destination, str(img["id"]) + ext)
if not os.path.exists(file):
urlretrieve(url, file)

print("downloaded", url, file)
else:
print("downloaded", file, "exists.")



Expand Down
3 changes: 2 additions & 1 deletion schedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ secret="secret.txt"
log="$0.log"

( (
date
cd "`dirname \"$0\"`"

source "ENV/bin/activate"
Expand All @@ -23,7 +24,7 @@ log="$0.log"
exit
fi

python3 ./download.py "$dst" "$server" "$user" "$decret"
python3 ./download.py "$dst" "$server" "$user" "$secret"
)
echo "Exit status $?"

Expand Down

0 comments on commit 88ac294

Please sign in to comment.