All posts by Andrew Bennett

Issue installing pyinstaller

Recently while running:

pip install pyinstaller

I encountered the following error:

Failed to build pyinstaller
Skipping wheel build for altgraph, due to binaries being disabled for it.
Skipping wheel build for pefile, due to binaries being disabled for it.
ERROR: Could not build wheels for pyinstaller which use PEP 517 and cannot be installed directly

It turns out that Windows Defender (the built in AV in Windows 10) was blocking runw.exe

The real error was a few lines above:

error: could not open 'PyInstaller\bootloader\Windows-32bit\runw.exe': Invalid argument

A quick unblock from Windows Defender and it worked.

Thanks to: https://github.com/pyinstaller/pyinstaller/issues/3813#issuecomment-575319940 for the hint.

Adding Headset to LG Phones

Recently I added some headsets (Jabra PRO 9450) to a range of LG LIP-8012D and LG LIP-8024D phones.

  1. The electronic hook switch plugs into the back of the handset, with the coloured strip (usually indicating pin 1) facing up. It’s best to remove the power, add the accessory, then plug it back in, otherwise, the phone won’t recognize the accessory.
    A second cable for audio is required from the headset port on the back of the phone to the base use of the headset. (only control signals are sent down the electronic hook switch cable)
  2. The handset requires programming to be told to use the handset and not the speakerphone.
    Trans PGM > 6 > 1.
    Select 0 for headset then Hold/Save.
  3. The handset requires programming to be told to ring in the headset:
    Trans PGM > 6 > 2
    Select 2 for headset or 3 for both, then Hold/Save
  4. That’s about it. Enjoy

Upgrading requests_toolbelt in Zato 2.0.8

After failing with pip and easy_install I came across this post again:

https://forum.zato.io/t/what-is-the-canonical-way-to-add-extra-python-packages-to-my-zato-server/580?source_topic_id=586

There is another way, that of updating versions.cfg and buildout.cfg files but if you are more familiar with pip than buildout then pip install package-name is perfectly fine.

So it turns out it is as easy as:

nano ~/current/versions.cfg
update the version from 0.2.0 to 0.8.0 then run
cd ~/current
buildout

And buildout will do it’s magic.

Sorting 404s in Nginx access Logs

The default Nginx logs can be combined and sorted to gather some useful stats.

  1. Make a working directory and copy current logs over (optional):
    mkdir ~/accesslogs
    sudo cp /var/log/nginx/access.log* ~/accesslogs
    cd ~/accesslogs
  2. Extract logs compressed by log rotate:
    ungzip *.gz
  3. Make a big combined log:
    sudo cat access.log* >> log.combined
  4. Parse the combined log and count the 404’s
    sudo awk '($9 ~ /404/)' log.combined | awk '{print $7}' | sort | uniq -c | sort -rn >> 404sC.txt

Let’s encrypt certbot – moving vps

Sometimes you need to move VPS’s, and you don’t want downtime with the SSL certs.

Well it turns out that you can easily run Let’s Encrypt in standalone mode and use DNS verification to do a once-off cert prior to moving the VPS. – Read the Certbot docs.

But once the migration has taken place, you may also want to return to the validation method that you had been using previously. Two options exist, either a) modify the config files by hand (strongly advised against) or to return to the certbot and get it to update the config itself.

For example here is how I generally get a SSL cert on a particular box:

certbot certonly --webroot -w=/var/www/letsencrypt -d [www.URL.com] -d [URL.com]

And here is how I update to the new config

sudo certbot certonly --cert-name [www.URL.com] --force-renewal -a webroot -w=/var/www/letsencrypt

Thanks to @schoen on this post: https://community.letsencrypt.org/t/how-to-change-certbot-verification-method/56735/3

Installing a Canon Image Runner Advance Printer on a Mac OS

For some reason installing the UFR II/UFRII based printer on Mac OS is strangely complex.

Here’s what to do:
1) Download the correct driver for the Canon Machine / Mac OS from the canon site (I install C2020’s a lot: https://www.canon.com.au/multifunction-devices/imagerunner-advance-c2020/support)
2) Install the Package
3) Within System Preferences > Printers > Add a New Printer.
4) Select ‘IP’ from the top tab. Fill the form in as follows:
Address: IP Address of the Printer
Protocol: Change to Line Printer Daemon
Queue: Insert ‘LP’ < this is the part I always forget. Name: A logical name for the user Location: A logical location for the user. Use: Select the Driver from the one that you just installed, in my case I selected 'Canon iR-ADV C2020/2030 Click Add. Canon Printer Mac OS X Settings

It now should now be setup to print.

If you want to setup the default settings on the printer, you need to use the CUPS web interface.
Visit: http://localhost:631/printers/ on the machine.
You’ll probably get a message about CUPS Web interface not being enabled, follow the prompts to open up ‘terminal’ and paste in
cupsctl WebInterface=yes

Then you’ll be able to access the printer UI.
From here you can select the printer, and change the default printer settings.

I always change from 2 sided printing to 1 sided, and from Color to B/W

There you go, installing a Canon Printer or Canon Photocopier on Mac OS X.

Zato: Add MSSQL to Outgoing SQL Options

To Connect with MSSQL or SQL Server via Zato 3:

#sudo su - zato
$/opt/zato/current/bin/pip install pymssql
(More info: http://pymssql.org/en/stable/intro.html)
$nano /opt/zato/env/qs-1/server1/config/repo/sql.conf

Add the following lines at the end:
[mssql+pymssql]
display_name=MSSQL
sqlalchemy_driver=mssql+pymssql
ping_query=SELECT 1

???I don’t know if this is required or not, but I still do it.
Deploy to other servers in the cluster:
$cp /opt/zato/env/qs-1/server1/config/repo/sql.conf /opt/zato/env/qs-1/server2/config/repo/

Restart your cluster and MSSQL should appear as an option under SQL Outgoing connections.

LG iPECS Least Cost Routing (LCR)

Recently I had a bunch of trouble with some SIP trunks (read about it at: LG IPECS SIP Trunk Issue) and needed to edit the Least Cost Routing (or Least Call Cost Routing).

The system is pretty basic, landline calls go out of one CO group, calls to mobiles go to another CO group.
There are a couple of tables that control how LCR works: LCR LDT (PGM 221) and LCR DMT (PGM 222).

LCR LDT – Leading Digit Table – PGM 221
This is where the ‘patterns’ are setup, so that the phone system knows what to do with the call, based on the starting digit(s).
Check out this screenshot for a full view:

These are setup under Index 1,
Then in subindex 0-6 are setup for landlines, 7 is setup for the mobile calls.
For each of the Subindex 0-6, it looks at DMT 01
For the Subindex 07 (Mobile calls), it looks at DMT 02

LCR DMT – Digit Modification Table – PGM 222
[To be honest, I have no idea what is actually happening here, except for the reference to the CO/IP Group].
Index 1 routes via CO/IP Group 1
Index 2 routes via CO/IP Group 2
– Index 2 also has an Alternative DMT Index (3) – This is used when all the lines in CO/IP Group 2 are busy
Index 3
– Routes via CO/IP Group 1.

Check out this screen for a full view:

Seems to work alright.