I’ve started this series of posts about general programming in whatever language I happen to feel like. I decided to make it a separate series of posts from my game development dev log series of posts. This one is focusing on some ideas I have for a couple of different utilities in Python specifically.
I learned a lot about getting Python and associated environment setup and working under Windows so in all likelihood I will dedicate an entire post just to setting up Python and adopting a workflow. It may not be a user friendly guide but it will accurate. For me. Probably.
All of these Programming Journey posts can be found in the associated category.
I’m not sure why I decided to stop the GameMaker tutorial I had been working through and go over to this other thing in a completely different language. But I’ve learned when these types of things come up (my attention span staying on a thing) I should just go with it. And I am trying to stay with it this time.
Namely, I decided to take advantage of a Udemy course I had purchased a while back called Automate the Boring Stuff with Python. I know, the book is free online in every possibly format including a friendly web site so there probably wasn’t a lot of reason to buy the course.
I had very little Python experience to start with and I thought maybe this bare-basics followed by lets-automate approach might help keep my interest. And I think it did.
Except one minor thing: the videos in the course are of from 2015 so there’s a few things that didn’t work. I ended finding some interesting documentation on what wasn’t working and I succeeded in the main goal of learning just enough Python to be dangerous. Also, the first 15 videos of the Udemy course are on the author’s YouTube channel anyway.
I worked my way through the course section by section in order and got pretty far. In fact if I never see another regular expression again it’ll be too soon. Something about those series of characters seems to short circuit my brain. I have a reference now though.
For this entry I would like to brain storm a couple of ideas I think I have to knowledge to do now. Or will given the proper references to documentation and videos etc. I think it’s certainly within my knowledge base now. I’m sure I’ll think of other thing and expand on these ideas as I go along.
Idea 1: Steam game database
I’ve fallen behind on the upkeep of my spreadsheet with all my games lately for some reason. Being incredibly tedious might be related. Note I made a two part post about about organizing steam library games using Google Sheets a few years ago.
What I would like to do is some web scraping: start with my steam profile page that contains the list of all my games. I realize I could use a third party site to just give me a list along with game UUIDs and other info but there’s a reason I want to do it myself.
Actually I could probably use an API to talk to steam directly instead of going through web scraping. But I need the practice.
Anyway, I idea is to go through my library and collect the UUIDs all the games in the whole thing then save them to a text file, one per line.
Note: since originally writing this I have learned that the data on that steam game list page is actually there in JSON format and the whole table is generated programmatically (with JavaScript and the DOM). So I wouldn't be scraping the page but capturing the convenient JSON formatted data for manipulation. The JSON data includes a storage URL in fact. I'll dedicate a whole post to his Steam idea eventually.
I would do this because the store page URLs come in the form
https://store.steampowered.com/app/255710/Cities_Skylines/
But after some experimenting I can also load the above page with
https://store.steampowered.com/app/255710/
Which I means all I need is the UUID and the rest of that URL is the same. And what this means is that I can do a test against all my UUIDs in combination with the URL and collect a list of games that no longer have storage pages:
https://store.steampowered.com/app/ + [UUID here}
Just concatenate these two strings together and I have two more text files: a list of UUIDs that that don’t have store pages and a list that does. And why do I need those you ask?
So I can load in the list of the ones that do have store pages and and not bother with the ones that don’t when I go through my next step: attempting to collect the store page “tags” for each game.
I also need a way to extract the name of the games. The game names are actually in the HTML neighboring the UUID. But they’re also in the URL. I mean once
https://store.steampowered.com/app/255710/
for instance finishes loading it will have Cities_Skylines in it. So maybe I just need to replace underscores with spaces? The problem with getting the name for the HTML is that some game names include special symbols like the TM or (R) (for instances: Batman™: Arkham Origins is in the HTML). So using the URL may actually suffice.
When I was working on my spreadsheet a few years ago I was kind of trying to do that part manually. But it might be possible to automate at least a part of that. If nothing else I can find tags like “utility” and “application” and make them a separate list. I mean if I just wanted to re-verify a list of games I owned, ignoring the applications (and sound tracks, servers, beta builds and whatever other randomness somehow ended up in my library).
What’s the real main goal? Well automating the boring stuff, obviously. I mean when I buy a group of new steam games stick the UUIDs into a text file and hit the Python script with said text file and…it’s in the database for me. The title, the storage page link, the genre information and so on. Should probably attempt to collect how if it all much gamepad support each game has while I’m at it. Metadata is I guess what I’m saying. Select meta data.
I could probably do this from within an actual google sheet maybe but it’s nice to have practice and the process documented for when I inevitably need to use the same skills for some other project…
Idea 2: collection information on network worth of PCs
I should start out with I don’t actually want to directly query Active directory for this idea.
Instead, I would export a list of PC names to a text file and load that in so I can go through it line by line.
I mean I could do this in PowerShell. In fact I’m fairly certain this is why PowerShell was made in the first place. And perhaps I will still do this in PowerShell some day. But I’m on kind of a Python kick right now so I’ll just go with it.
First, though it could be redundant, I would want to check and make sure there were no servers or other irrelevant devices listed. Just filter those out and save them in a separate text file for separate tracking. This separate list can then be used to filter those device names out when I get a new list of PCs exported.
Then the script would do something like go through and find which ones are currently online and ping-able. This would be in a “currently powered on” text file list.
Next, against those “currently powered on” PCs, I would do a test WMI query against each one. Assuming a query like this could return as a true/false I would have another list of PCs. This list would be different each time the script is because different PCs get powered on and off not to mention laptops.
With this powered on and query-able “master list” available the real work could start: collecting information on each PC.
Well at the moment I’m just talking about a Windows 10 environment. In fact I could probably skip any Windows 7 machines left as those are special anyway. There’s only a few Windows 11 PCs and those are in the IT department. So I would want to go through all the windows 10 machines and see if I can return a build number, like 1903 or 21h1. I think that’d be helpful.
Then there would be the more normal information for day to day work: How much RAM the machine has, how long since the last windows reboot, and if possible if the device is a laptop or a desktop (or other/special device). Actually which network printers are installed and what if any network drives are mapped would also be nice.
I would want all these listed out in a convenient format. Perhaps CSV so it could be viewed in a spreadsheet and/or an offline database format like JSON.
Developing such a program would likely take a while but it’d really just be a utility program for the real program I need: getting such meta data on one or more specific PCs in a friendly format that can be used in the notes required for a work order.
I’ve done a little research and it appears it wouldn’t be at all different to do WMI queries with Pyhon which means retrieving think like the service tag of a PC would be easy. I had a side idea of auto-downloading the latest BIOS from Dell based on service tag as that’s something I seem to do manually quite a lot.
Idea 3: ticket notes auto-writer
I worked briefly doing tech support at a call center around 2004/2005. They had grouped together in these “open concept” cubicles two at a time.
My cubicle mate was much more of a pro than I was in that he had already been doing the exact job for the past several years and it was pretty much second nature to him.
I noted over his should that he had used a provided macro software package to pretty much write out his notes for him.
I mean he had 3 – 5 character short strings he could type to that expand out to sentences. Depending on what direction the calls would take he would hit different key combos and the notes would write themselves.
He didn’t seem very enthused to share the details of how this worked or how he came up with standard sentences to expand out to. It did allow him to get through several order of magnitude more calls per day than I (or pretty much anybody else in the call center) ever did.
Going back to 2004 I’ve always wanted to try and figure out how to reproduce that. Well I don’t think I’m really going to reproduce that. But I’d like to at least get kind of close.
So my rough idea is not only have something of a constantly update offline data base of PCs on the network but something of history of them. Date stamps of when the were and were not on for instance and maybe associating them with users and ticket numbers.
Well our ticketing system sort of has a way of doing that but it’s more indirect. What I’m envisioning is more of an offline database with very specific historic information.
I’m hoping this information will go into my further idea of bringing data to “generate” a friendly formatted series of notes that can be put into a work order. And a modified version of context-specific notes manipulation might be possible from there as well.
This is kind of vague at the moment so I’m going to take it step by step. Of course the main problem would probably be that it wouldn’t have a GUI. Well not a windows GUI anyway. I guess I could use curses to write a console based GUI.
If you’re wondering why it’s because I don’t want a framework to be required to run. I don’t want any prerequisites at all. And being able to easily “view source” would also be nice.
Again, PowerShell actually has a solution for that (loading in a XAML file) but I’m going to practice Python for now.
Reference links:
- Automate the Boring Stuff (free book via web site)
- Automate the Boring Stuff 15 part YouTube playlist (from 2015 but still good for basics)
I've made a "clearing house" repo for random python programming projects on GitHub: https://github.com/tildesarecool/ReallyHadtoPython
One thought on “Programming Journey Entry 1: Lets do Python”