Skip to content

Commit

Permalink
Upload logs to FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
theresnotime committed Dec 2, 2024
1 parent 825f068 commit c6b7322
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config.example.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
API_URL = ""
ACCESS_TOKEN = ""
FTP_HOST = ""
FTP_USER = ""
FTP_PASS = ""
18 changes: 18 additions & 0 deletions gen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import config
import ftplib
import logging
import os
import random
Expand Down Expand Up @@ -128,6 +129,16 @@ def clear_used(thing: str) -> None:
log.info("Cleared used %s list", thing)


def upload_logs(filename: str):
session = ftplib.FTP(config.FTP_HOST, config.FTP_USER, config.FTP_PASS)
ftplib.FTP.cwd(session, "as-a-treat")
file = open(filename, "rb")
session.storbinary(f"STOR {filename}", file)
file.close()
session.quit()
log.info(f"Uploaded {filename}")


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Generate a string in the format "{folx} can have {treats}, as a treat" and post it to fedi'
Expand Down Expand Up @@ -205,3 +216,10 @@ def clear_used(thing: str) -> None:

status = f"{folx} can have {treat}, as a {treat_or_threat}"
write_status(status, args.dry_run, args.visibility)

# Upload logs
log.info("Uploading logs...")
upload_logs("used_folx")
upload_logs("used_treats")
upload_logs("as-a-treat.log")
log.info("Finished uploading logs")

0 comments on commit c6b7322

Please sign in to comment.