Gettor code refactor with Python Twisted
Code refactor
Gettor needs some love. It should be more robust to make it: easier to maintain (by me or somebody else), to know when it is working or not, and to allow more developers to contribute to it.
For the above, I propose to refactor the current code and turn it into a twisted daemon [1, 2]. This would preserve the main logic of the current system and add all the benefits of having a daemonized application. This service approach considers two main parts:
- Distribution channels. Whenever gettor receives a request or sends a reply it uses a channel (e.g. e-mail). Each channel could be handled by one or more services. These services would be constantly fetching and updating information in a SQLite database to know how to proceed.
In the case of e-mail, there should be a script that receives messages forwarded by the MTA, process them, and add a request with a given status to the SQLite database. On the other hand, a service running on background will be fetching ready-to-be-sent requests from the database and send e-mails with the requested information.
For a twitter bot, a single service that receives DMs, process them and send replies would be enough.
- Tor Browser sync. A service constantly checking new Tor Browser releases, downloading the new packages and updating the SQLite database with the new links.
The logging system provided by twistd is easy to use and works very well. This will solve one of the problems with the current code and the use of logging, also providing useful information for debugging and statistics. Log rotation is automatic.
I have developed a similar service using twistd. Adapting it to gettor would be fairly easy and it would take me a few weeks of spare time.
Twisted is not installed on getulum, so I will collect all the needed packages and ask for them to be installed.
1: https://twistedmatrix.com/documents/current/core/howto/application.html. 2: https://twistedmatrix.com/documents/current/core/howto/basics.html#twistd