• 3 Posts
  • 85 Comments
Joined 2 years ago
cake
Cake day: February 17th, 2024

help-circle


  • No apologies necessary! This is incredibly helpful! I found in the documentation how to format the message with the basicConfig, so I’m going to get rid of the logDateTime, move the logger out of main (didn’t even think about how that would limit it to only main and not the other functions.), and test output to stdout vs the file defined in basicConfig.

    Gotta go to work, but will implement this later. Thank you!!





  • So, if I understand what you mean correctly, with logger, drop the function, and in the main script body (which is now under an if __name__ == "__main__": check, call logger directly something like:

    if __name__ == "__main__":
        load_dotenv()
        
        logDateTime = datetime.today().strftime("%Y-%m-%d %H:%M:%S")
        logger = logging.getLogger(__name__)
    
        currentForwardedPort = get_current_forwarded_port()
        currentListeningPort = get_current_listening_port()
    
        if currentForwardedPort != currentListeningPort:
            update_qbittorrent_listen_port(currentPort)
            logger.info(f"[{logDateTime}] qbittorrent listen port set to {currentForwardedPort}")
        else:
            loger.info(f"[{logDateTime}] forwarded port and listen port are a match")
    

    And then in the crontab I can do:

    0 * * * * /path/stuff/python script.py > /path/to/log/file.txt

    Thanks!












  • I don’t know the specifics but forgejo is a gitea fork. There was/is some controversy around gitea governance and movent towards prioritizing a closed source paid/private versions of gitea.

    Again, I don’t know details, just very broad strokes. I chose forgejo because it’s under active Foss development and I didnt want to deal with potentially going with gitea and then having to abandon it later for whatever reason might develop.