Just my blog
Blog about everything, mostly about tech stuff I made. Here is the list of stuff I'm using at my blog. Feel free to ask me about implementations.
- Mobaxterm SSH RDP FTP...
- Thunderbird Email client
- Filezilla FTP client/server
- Nirsoft Win utils
- Sysinternals Win utils
- Pi-Hole AD block by DNS
- NUT UPS manager
- Rpi MON Raspberry monitoring
- Free CAD 3D modelling
- Free Commander Far-like filemanager
- Bitwarden Password manager
- Django web framework
- celery multi-tasking
- celery-beat Celery + Django
- celery-results Celery + Django
- Pillow Python image lib
- wsgi mod Apache + Python
- requests best in WEB requests
- openpyxl make Excell docs
- p4python Perforce + Python
- paramiko SSH + Python
- pyvmomi ESXi Vcenter + Python
I'm using these libraries so you can ask me about them.
Raspberry 5 test-to-speech using Piper
How to make your Raspberry 5 talking with python lib Piper?
I wanted to make my Raspberry tell me about power outages and air alerts near my location.
The setup is pretty simple and described ar the repo:
I didn't want to waste my time making yet another Python venv and that's why I've chosen a simple binary mode.
Setup
Now about the setup:
- Raspberry 5.
- USB sound card with 3.5 jack.
- USB-powered speaker with a 3.5 jack.
Sound
CMD to change the volume programmatically:
amixer set Master 80% >> /dev/null
Sound devices and controls
You may have a problem with playing generated WAV files and making voice directly. So you need to choose devices for a different output.
To list devices run:
# List devices
aplay -L
# I only have USB card:
hw:CARD=Audio,DEV=0
USB Audio, USB Audio
Direct hardware device without any conversions
plughw:CARD=Audio,DEV=0
USB Audio, USB Audio
Hardware device with all software conversions
sysdefault:CARD=Audio
USB Audio, …
Installing NUT - Network Ups Tool Notifications and emails
Installing NUT - Network Ups Tool Notifications and emails
Notifications and email
Just a simple work log of installing NUT and configuring email notifications from it.
- Start here: Installing NUT
Simple
Go to file:
sudo vi /etc/nut/upsmon.conf
# Email script for NOTIFYCMD
# Simple
NOTIFYCMD "/etc/nut/notifycmd.sh"
# Notification events
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
Simple notification script
sudo vi /etc/nut/notifycmd.sh
#!/bin/bash
EMAIL='to@YOYR_EMAIL.com'
echo -e "Subject: UPS ALERT Basic: $NOTIFYTYPE\n\nUPS: $UPSNAME\r\nAlert type: $NOTIFYTYPE\n\n\nThis is a basic notification!" | msmtp $EMAIL
# Change group to nut
sudo chown :nut /etc/nut/notifycmd.sh
# Add execution
sudo chmod 774 /etc/nut/notifycmd.sh
# Restart the NUT services
sudo systemctl restart nut-server.service
sudo systemctl restart nut-driver.service
sudo systemctl restart nut-monitor.service
Extra notification script by Scheduler
Installing NUT - Network Ups Tool
Install and use Network Ups Tool - an open source Uninterruptible Power Supply software
- UPS with connected devices:
- LG TV
- Soundbar
- NUC as a media centre (with NUT monitor for Windows)
- RPi5 as brain unit with NUT, Pi-Hole and DHCP.
- TP-Link Router.
In case of a power-loss event, PRi will notify me via email, NUC will power off on its own, TV can be powered off manually.
Powered-off TV and soundbar are neglectable in total power usage on battery, so I have about 1,5 to 2 hours of running Raspberry 5 and TP-Link to keep my internet on.
Centos Python Installation Guide with no Pain
Old me installing Python
Centos 7 + Python 3(4,5,6,7,8) installation guide with no pain. As for me.
I can't even say how many times I have to update my python executables for web servers and how much pain I feel during this routine.
Usual Google\StackOverflow advice only describes one particular problem. But there're few of them, and they're different so you spent hours trying to collect them all and pick the right decision.
Then you just drop it and use yum for any latest python version available!
Here I'll show you and make a reminder for myself about how to install modern python in the best way, once, without pain.
I use Centos 7 typical install as for WebServer (minimal install could require to install tonnes of dev-libs and yum, be sure you prepared them before)
1. Preparations:
You need to install some compil libs.
yum …
!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->
Read...
Test design and implementation.
Old stuff, very old
Test design
Our test system has a pretty simple configuration, so I do not want to bother you with the detailed description of it. Simply - it's just a standalone execution of a test.py file with all requirements (test setup and tear down) in local internal test utility. Helper local utility has a usual amount of preparation functions, test data loading and some other configurations. In the very end of test loading, it just compares a node-set result of "real" scan (software and hardware nodes in a database after the scan) with predefined node-set (from test.py). Node set we usually expect at the end of the test should be added by the developer when product discovery pattern is ready or have a new feature or fix.
Now I'm trying to implement entirely new and somewhere different test design because current is not …
!-->!-->!-->!-->!-->!-->!-->!--> Read...Test automation or: How I Learned to Stop Worrying and Love Async __init__
Old stuff
Morning everybody…
I recommend reading this part of the blog only in the morning with a cup of dark and strong coffee.
I'll show you some new cases, and howto's to help you automate routines in the developer's life. There will be an example of my fails and win on different scenarios. The poor code I'll include also.
Very beginning
Firstly - I'll try to make this thread in English. And maybe later when I have time - to make Ukrainian and Russian translations, I'll make them.
"Octopus" story has started from a small plugin for Sublime Text editor. Later it will be ported to Atom.
I've started developing "Octopus" on spring-summer 2016, and I've not finished it yet! New functions and features were implemented continuously. Product transforms into a framework.
Now all processes executed automatically and simultaneously for 24/7. "Octopus" has …
!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!-->!--> Read...Oh my gosh BACULA config
Recently finished bacula config and run first one successfully! I'm really do not understand now, why does this tool have a complicated system with batch of daemons and modules. For my opinion, backup tool just should know from where to wherever make a backup and how often. But for further usage and remember this config, I'll add it here. [caption id="" align="alignnone" width="428"] Bacula config[/caption] Is is just a reminder, not a how-to, just want to not forget this. Job configs is not so complicate, intuitively understandable.
Director
bacula-dir.conf
[su_spoiler title="Code" icon="chevron"]
Director { # define myself Name = tet-redmine-dir DIRport = 9101 QueryFile = "/etc/bacula/scripts/query.sql" WorkingDirectory = /var/lib/bacula PidDirectory = "/var/run/bacula" Maximum Concurrent Jobs = 1 Password = "tet-redmine-director" # Console password Messages = Daemon DirAddress = 127.0.0.1 } Storage { Name = File # Do not use "localhost" here Address = 127.0.0.1 SDPort = 9103 Password = tet-redmine-storage Device …Read...
Install Bacula on debian systems
Failed to load the database DBI driver SQLite at ./bacula-backup-lib.pl line 45 Based on:
- https://nklug.org.ua/node/23
- http://www.microhowto.info/howto/connect_to_a_sqlite_database_using_perl_dbi.html
- https://ru.wikibooks.org/wiki/Bacula/Быстрый_старт
- http://help.ubuntu.ru/wiki/руководство_по_ubuntu_server/резервное_копирование/bacula
- https://www.digitalocean.com/community/tutorials/how-to-install-bacula-server-on-ubuntu-14-04
The main problem was:
Failed to load the database DBI driver SQLite at ./bacula-backup-lib.pl line 45
this ultra fast fix can help:
apt-get install libdbd-sqlite3-perl
You can install any needed module based on SQL you use: MySQL, PostrgeSQL etc.
Read...python script as centos service
Task completed! I made a vkontakte Bot which delete all comments are not from group members! But I do not want to run it by cron, because it will SPAM all my system with cron emails. But I found resolution:
- make a worker.py
- allow worker to run delete scripts on time periods
- add worker as centos service
- have fun!
Maybe later I'll add more code, but now just for example I'll show only worker and bash script:
#!/usr/local/bin/python3 # coding=utf-8 from time import strftime, sleep import schedule from vk_del_comments import * from vk_del_comments_older import * import os pid = os.getpid() op = open("/var/us.pid","w") op.write("%s" % pid) op.close() token = '' tk_owner_id = "-000000000" tk_group_id = "000000000" tk_domain = "group_domain" curr_date = strftime("%d-%m-%Y - %H:%M:%S") logFile = 'comments_deleter_log.txt' # print("Start Comments Bot Worker!") def del_comments_30_sec(): del_comments_regular(logFile, token, tk_owner_id, tk_group_id, tk_domain) def del_comments_5_min(): delete_comments_older(logFile, token, tk_owner_id, tk_group_id, tk_domain) # schedule.every(30).seconds.do(del_regular_comments_19) schedule.every(30).seconds.do(del_comments_30_sec) schedule.every(5).minutes.do(del_comments_5_min) while …Read...
Allow Apache run python scripts
This is a simple ex. to allow apache run .py
# Python site at /var/www/py_site LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so <VirtualHost *:80> ServerName test.www.trianglesis.org.ua ServerAlias www.www.trianglesis.org.ua ServerAdmin test@test.com DocumentRoot /var/www/py_site/ <Directory /var/www/py_site> Order allow,deny Require all granted Allow from all </Directory> <Directory /var/www/py_site/cgi-bin> Options +ExecCGI Require all granted Allow from all Options +ExecCGI AddHandler cgi-script .cgi .pl .py AddHandler cgi-script .py </Directory> </VirtualHost>
Read...