Saturday, December 21, 2024

Using environment variables in Flask vs. Gunicorn

Problem:

 I recently built an app that sent mail in Flask / Flask_Mail via smtp.gmail.com.

After moving it to production using nginx and gunicorn rather than the flask development server I found the emails attempts were rejected by GMail and the logs stated authentication was required.

I was using the same .env file in production that held the mail credentials and was reading that file the same way with load_dotenv().  After stopping nginx and starting the flask server in production I found the mail was sent normally so there was no firewall or permission issues in production.

Fix:

create a gunicorn.config.py and load the .env file there. This is the extent of my file:

import os

from dotenv import load_dotenv

load_dotenv('.env')







Saturday, September 28, 2024

Extract the Contents of Cisco COP Files

 This is simply a partial repost of :

How to Extract the Contents of Cisco COP Files

at https://ipcommute.co.uk/technical-articles/19--how-to-extract-the-contents-cisco-cop-files.html

All credit goes to  Aaron Harrison Development Engineer at IPCommute UK

I found it so useful today I wanted to make sure Aaron's post lives on.  Thanks Aaron!


Cisco Option files (COP Files) are released for Cisco Unified Communications Manager (CUCM) to add new functionality, fixes, and other optional components such as locales or phone firmware.


Each COP file is essentially an archive of files - some are copied to the CUCM server, some are used as data to import to the database, others might be scripts.


Occasionally it might be useful to be able to look at the files that make up a COP file. This has been most useful for me when working with National Dial Plans (NDP); these aren't as well documented as they might be, and I find it useful to look into the files and see exactly what each of the clauses in the NDP actually mean in terms of dialled numbers.

So - here is how to do it.

The COP file is basically a gzip, with an encryption header that makes it unrecognisable to archive packages such as 7-ZIP. You'll need two pieces of software:

Once you have downloaded and installed these, grab your COP file of choice. I'll use a Dial Plan from the UK (dp-ffr.3-1-18.GB.cop.sgn).

Run HXD, and open the .cop.sgn file. You'll be presented with a screen that looks like this:



Note above that I’ve highlighted in red the name of the file. Where you see this, highlight it with the mouse, and you should see the hex pattern ‘1F 8B 08’ just after it. This is a Magic Number that marks the start of a GZip file (see http://en.wikipedia.org/wiki/Magic_number_(programming) for more information on Magic Numbers).

What we need to do is highlight everything before that Magic Number, and remove it. Highlight is so that it looks like the following picture, and then click the Edit/Cut menu option. Accept the file size warning.

Once removed, your file should start with the hex values 1F 8B 08. Click the File/Save As menu option and save the file with an additional .gz on the end – e.g. dp-ffr.3-1-18.GB.cop.sgn.gz

Now you can run 7-ZIP, and open the dp-ffr.3-1-18.GB.cop.sgn.gz file. 

Monday, June 24, 2024

PI Meeting / Program Increment Planning

PI Planning stands for Program Increment Planning.

PI Planning sessions are regularly scheduled events held throughout the year where multiple teams within the same Agile Release Train (ART) meet to align to a shared vision, discuss features, plan the roadmap, and identify cross-team dependencies.


Agile Release Train (ART)

An Agile release train (ART) is a team of several Agile Teams working towards a common goal.