Skip to content

Commit

Permalink
Add upload flag
Browse files Browse the repository at this point in the history
  • Loading branch information
theresnotime committed Dec 2, 2024
1 parent c6b7322 commit 349c74e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
FTP_HOST = ""
FTP_USER = ""
FTP_PASS = ""
DONT_UPLOAD_LOGS = True
20 changes: 14 additions & 6 deletions gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ def clear_used(thing: str) -> None:
log.info("Cleared used %s list", thing)


def upload_logs(filename: str):
def upload_logs(filename: str) -> None:
"""Upload a file to the FTP server"""
# Check if filename exists
if not os.path.isfile(filename):
log.error(f"File {filename} does not exist")
return
session = ftplib.FTP(config.FTP_HOST, config.FTP_USER, config.FTP_PASS)
ftplib.FTP.cwd(session, "as-a-treat")
file = open(filename, "rb")
Expand Down Expand Up @@ -218,8 +223,11 @@ def upload_logs(filename: str):
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")
if config.DONT_UPLOAD_LOGS:
print("Not uploading logs as DONT_UPLOAD_LOGS is True")
else:
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 349c74e

Please sign in to comment.