Docker automatically stopped

Docker automatically stopped

This morning I found that the Docker service on one our linux servers for no apparent reason had stopped. From the entries in syslog I could see that Docker had been going up and down since about 06:34 in the morning. Extract from syslog: I came across https://www.claudiokuenzler.com/blog/689/rancher-error-response-from-daemon-dockerd-deleted-no-such-file-or-directory, and from the comment section there I was led to check what the unattended upgrades had been doing this morning, and found this: On this particular linux server we don’t really wish…

Read More Read More

openpyxl’s “load_workbook” return empty list of sheets

openpyxl’s “load_workbook” return empty list of sheets

Consider this code: When using one of my xlsx-files as input, my code produced the output Sheet names: [] followed by this expection: After some investigating, I found that the file had been saved as “Strict Open XML Spreadsheet (xlsx)” instead of “Excel Workbook (xslx)”. Both files for some reason have the same file extension, but the former was not supported by the openpyxl library. Saving the file as “Excel Workbok (xslx)” got the code working again.

Adding “–version” parameter to “python3 setup.py”

Adding “–version” parameter to “python3 setup.py”

When building Python packages using setuptools, you typically manually set the upcoming package version in setup.py. For my use case, I found it better to provide the version number on the command line such as this: setuptools isn’t very fond of command line parameters, so I made a quick-n-dirty hack to work around this limitation:

Python: Writing test to verify command line arguments

Python: Writing test to verify command line arguments

I wrote a small Python script that will be executed from the command line. After finishing the tests to verify the business logic, I decided to test the command line arguments as well, just to make sure they’re parsed correctly and passed to their appropriate places in the business logic code. Initially I was thinking I needed to write a test that executes the actual command line such as python3 myscript.py –argument=value, but as this is neither appropriate nor really…

Read More Read More

SQLAlchemy + Database Link => ORA-04054

SQLAlchemy + Database Link => ORA-04054

I’ve got this SQLAclhemy table definition that describes a table I’ll be accessing over an Oracle database link: I first created a database link such as this: In SQLAlchemy, access a table column (in a query) via that link would look like tihs I turns out that SQLAlchemy with Oracle database links isn’t a very good match, and easily results in errors such as this: To work around this issue, I created a synonym like this: Now, accessing the table…

Read More Read More

Running Oracle in Docker for development and testing

Running Oracle in Docker for development and testing

I’m working on a Python based microservice that needs to communicate with an Oracle database. My development environment consist only of my laptop, so to do some real testing I decided to spin up Oracle in a Docker container on my laptop. For me, the process of getting things up and running wasn’t very straight forward for an Oracle newbie as myself, so I though I’d share my setup in case others may benefit from it. Let’s start with my…

Read More Read More

Extending business logic functions in unit tests

Extending business logic functions in unit tests

We have a database view, from now on referred to as View, that lists users we need to send an email to, and when we’ve sent the user an email we acknowledge this by updating the corresponding user in a database table (which is one of the tables the above mentioned database view is build from), from now on referred to as Table. For my unit tests I needed to emulate this behavior. I found that by extending the database…

Read More Read More

Using the factory pattern to create different emails based on input parameters

Using the factory pattern to create different emails based on input parameters

I wrote a small service that takes an MQ message as input, and based on the contents of the message creates and sends an email. The different types of incoming MQ messages require different types of emails to be created, so I needed a maintainable way to create different emails. For my use case, I found that the factory pattern was a good fit. Consider this code: My business logic code that uses this code then get to be as…

Read More Read More