100 Days of Code: Day 1 – App Tracker

Yesterday, I posted about starting the #100DaysOfCode challenge. That was Day 0. The beginning. The introduction. Today marks the first official day of writing code as part of this challenge.

What’d we do today?

Today, I wrote a basic app tracker in Python to track the time I use different applications on my computer. Right now, it currently only supports Windows – but this is an iterative process, so stay tuned. You can check out the project at GitHub under the project app-tracker. At a basic level, the program tracks the time, in seconds, you spend on your active window. It then calls a REST API to update that information on a server. The server then stores it in a basic text file in JSON format.

It includes the following components:

  • app-tracker.py – the local file that runs on your computer and does the main tracking.
  • app-tracker-server.py – a server side REST API written in Python and utilizing flask. This is a REST API which stores/retrieves the information in a local apps.json file. (Note: this can technically run anywhere – I currently run it inside a Docker container.
  • Dockerfile – This is the definition of the Docker image which hosts the server side (app-tracker-server.py). This allows for extremely easy deployment of the server side. Technically, this allows you to host it anywhere you can host a Docker container. Dockerfiles are essentially the definition of your Docker image that you then run your Docker container from.
  • startup.bat – just a basic startup script that builds the app-tracker-server docker image using the Dockerfile and then starts the image up as a new container.

While I’ve used Python before and knew the basics of what I wanted to do and how to do it, this was still a fun exercise getting back into the groove of writing Python code again. And while I’ve used Docker containers and created my own Docker images previously, this was the first time I’ve hosted a Python application inside a Docker container. This has also been something I’ve been wanting to do for a while, especially ever since Wakoopa went away for free, personal use.

The above also wasn’t just me whipping something together that I already knew how to do and with no help. I definitely looked up a few items – either for remembering how to do something (writing a flask server), or plain trying something new (running Python in a Docker container). This is part of the adventure of software development though, you need to do something, you learn how to do that something, and then apply what you learn to your code.

What’s Next?

At best, this is a very rudimentary implementation. There’s a lot more that I’d like to add to it as I continue this adventure. Some items include:

  • Support multiple OSes (MacOS + Linux)
  • Add a UI.
  • Add robustness to the code. It’s currently fairly lackluster in this department given the short time I’ve spent on it so far.
  • Further testing. Similar to robustness of the code – I’d need to test this further for a variety of ways – one does it handle basic error conditions? But further, is it performant? (Probably not based on my little usage of it and seeing how I wrote some pieces, it could be written more performant.
  • Numerous other items…

That’s it?

That’s it. Day 1, complete. I’ll be back tomorrow with a further update and further changes for app-tracker.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s