Skip to main content

Posts

Install python and opencv on the raspberry

Setup Conda and Python and opencv Setup venv python -m venv ocv2-env ocv2-env/bin/pip install opencv-python  Try python script import cv2 # Open the default camera cam = cv2.VideoCapture(0) # Get the default frame width and height frame_width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT)) # Define the codec and create VideoWriter object fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (frame_width, frame_height)) while True:     ret, frame = cam.read()     # Write the frame to the output file     out.write(frame)     # Display the captured frame     cv2.imshow('Camera', frame)     # Press 'q' to exit the loop     if cv2.waitKey(1) == ord('q'):         break # Release the capture and writer objects cam.release() out.release() cv2.destr...

Setting up my new raspberry

What did i buy? Raspberry Pi-C 8g vormontiert RASP PI-C 8GB Raspberry Pi-C mit Raspberry Pi 5B 8GB, vormontiert 142.95€ Camera  RASP CAM 2 Raspberry Pi - Kamera, 8MP, 67°, v2 18.95€ Cable to camera needed for raspberry pi-5 Raspberry Pi 5 Kamera Adapterkabel, offizielles Kamera Adapterkabel für Raspberry Pi 5, 300mm 2.35€ Hdmi mini to hdmi cable  Mini-Displayport Kabel, Mini-DP-HDMI, 1080p, 2,0 m Keyboard  Rii i8 Mini Tastatur Wireless 16.99€ the box unpacked connected booting configure What will i configure? Wifi network New user with sudo rights; at configuration menu Setup remote desktop Find my ip nmcli device show IP4.ADDRESS[1]: 192.168.180.111/24 Activate ssh and vnc In raspberry config, activate ssh and vnc. Next install tigervnc and ssh on client PC, and connect to IP address above.    vncviewer 192.168.180.111 user jan

Push image to Docker https registry

 Setup remote https registry docker container stop registry docker container rm -v registry ls /var/lib/ cd mkdir certs cd certs openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt cd .. openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt ls -ltr ls cd certificate_authority history | grep import ls -ltr ../ ls -ltr ../certs cd docker run -d   --restart=always   --name registry   -v "$(pwd)"/certs:/certs   -e REGISTRY_HTTP_ADDR=0.0.0.0:5443   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt   -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key   -p 5443:5443   registry:2 docker container ls history | grep allow sudo ufw al...

Certbot https certificate

 Install https certificate for apache sudo apt install certbot python3-certbot-apache cd /etc/apache2/sites-available/ ls sudo cp 000-default.conf jankester-com.conf sudo vi jankester-com.conf sudo a2ensite jankester-com.conf sudo a2dissite 000-default.conf sudo apache2ctl configtest cd /var/www/ ls ls -l sudo mkdir jankester-com sudo mkdir jankester-com/public_html sudo cp html/* jankester-com/public_html/. sudo apache2ctl configtest sudo systemctl restart apache2 sudo ufw status sudo certbot --apache sudo apt-get install certbot python-certbot-apache sudo apt-get install certbot python3-certbot-apache sudo certbot --apache sudo apt install certbot python3-certbot-apache certbot --version sudo apt install snapd sudo snap install --classic certbot /snap/bin/certbot --version sudo /snap/bin/certbot --apache cd jankester-com/public_html/

Install tileserver

Install Postgis  sudo apt-get install -y postgresql postgis sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start locale git --version # to verify whether git is already installed sudo apt-get install -y git sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start echo $USER locale -c locale createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 sudo -u postgres createuser -s $USER createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 psql -d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;' psql -d gis -c "create user jan;grant all privileges on database gis to postgres;" psql -d gis -c "grant all privileges on database gis to postgres;" psql -d g...

Create a groovy console and bind to selenium

Required groovy files In the previous posting we defined the pom file that we need for our build environment. Now we will setup some groovy files to get selenium and groovy running interactively. ConsoleWaiter.groovy The idea of Groovy Console I found on some other sides. Honour goes for instance too: http://josefbetancourt.wordpress.com/tag/eclipse-2/ I copied some code of this, and put it under src/test/groovy/com/jankester/selenium/test/utils: package com.jankester.selenium.test.utils /** * File: ConsoleWaiter.groovy */ import groovy.lang.Binding; import groovy.ui.Console; /** * Provides a wrapper for the console. * * Based on source by John Green * Adapted from: http://www.oehive.org/files/ConsoleWaiter.groovy * Released under the Eclipse Public License * http://www.eclipse.org/legal/epl-v10.html * * I added methods to allow use from Java. * * The run() method launches the console and causes this thread * to sleep until the console's window is closed....

Setting up maven project to do first interactive test

The pom file A basic pom file that sets up all dependencies for your interactive selenium-groovy testing contains following: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.jankester.selenium</groupId> <artifactId>selenium-groovy-public</artifactId> <version>2012.03-SNAPSHOT</version> <packaging>jar</packaging> <name>selenium-groovy</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.selenium.version>2.20.0</project.selenium.version> <log.root>./target</log.root> </properties> <dependencies...

Interactive selenium testing

The problem Location of elements When I started using selenium, I noticed that it is not easy to do it right. First you start with IDE, but you notice, that the IDE does not really record a lot. In a next step I added firebug, and started analyzing how the elements where to be located: either by tag, id, class etc. Junit testcase With this information I could then create my junit testcase: @Test public void testMapView() throws Exception { //assert that we cannot see submenu of MapCreator elem = driver.findElement(By.className(SeleniumConstants.MAP_SUB_MENU)); String style = elem.getAttribute("style"); assertTrue("Element must have style display off.",style.matches("display: none.*")); logger.debug("Located element " + SeleniumConstants.MAP_SUB_MENU); //find menu and click on mapview elem = driver.findElement(By.id(SeleniumConstants.MAP_CONTROL)); actions.moveToElement(elem).click().perform(); //assert su...

Logging in selenium

For some time I am trying to get more out of Selenium. Lot has changed here: selenium2 is a big improvement, and since 2.15 google also contributed its Advanced User Interactions API to the selenium code base, which seems to be a big improvement for mouse handling. To get a better understanding of what is happening, and especially why my test scripts are failing, I wanted to control the logging of my webdriver. I noticed that this was a bit of a pain. Selenium firefox driver is using java.util.logging. So you are bound to the mechanisms that java.util.logging offers you for log configuration. This is the approach I ended up with. Before I startup my Firefox Webdriver, I used the setLogLevel method to set the Level of logging that is used for all driver logs. When you set this to WARNING, all logs that the driver makes, are considered to be WARNING logs, when you set them to FINE, all logs are considered to be FINE logs. So dependent on the settings inside your logging.properties,...

Junit4 running parallel junit classes

To run junit testcases parallel, you can create your own class to run junit with: Add this tag to your class declaration. @RunWith(Parallelized.class) Implementation of this class looks like: package mypackage; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.runners.Parameterized; import org.junit.runners.model.RunnerScheduler; public class Parallelized extends Parameterized {         private static class ThreadPoolScheduler implements RunnerScheduler     {         private ExecutorService executor;                 public ThreadPoolScheduler()         {             String threads = System.getProperty("junit.parallel.threads", "16");    ...

Run jmeter from eclipse

Download jmeter source and binaries: http://archive.apache.org/dist/jakarta/jmeter/binaries/jakarta-jmeter-2.3.4.zip http://archive.apache.org/dist/jakarta/jmeter/source/jakarta-jmeter-2.3.4_src.zip Unpack jmeter source file, and rename eclipse.classpath into .classpath. Add a .project file to the same directory: <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>jakarta-jmeter-2.3.4</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> Now import the source code as eclipse project. Add all libs of binary distribution (lib/*.jar) to the new project's lib dir....

Debugging against jmeter

Inside jmeter startup script, add: set DEBUGJDWP=-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=y set ARGS=%DUMP% %HEAP% %NEW% %SURVIVOR% %TENURING% %EVACUATION% %RMIGC% %PERM% %DDRAW% %DEBUGJDWP% Now start jmeter. It will hang and wait for debugger. In eclipse, add a new remote java application debug configuration. Add jmeter source code to it. Connect. Jmeter will start now. Attach jmeter source code. Lookup class: org.apache.jmeter.engine.StandardJMeterEngine Set debug point in runTest() method and start your script.

Good principles of test automation

Core principles of good tests When you start automating your tests, there a few important principles to stick to. Reliable First your tests must be reliable. This means that they must repeatable and always give the same results. They should not contain any environment dependencies, and be executable on any environment. To get this working, all hard-coded settings must be configurable, a maven or ant script is required to build and configure the test environment, and all code, test date and configuration scripts must be checked in source code repository. Having reliable tests that run everywhere and always, also means that your tests must take care to setup necessary test data, and clean it afterward again. Fast Next, it would be nice when your tests are fast. In the lifetime of a project you will build up ever more tests; with every next sprint you will need to run more tests. You can't run all your tests on check-in, and for certain groups of tests need to schedule test exe...

Test automation in agile

Test automation importance With our change to agile, we have made an important paradigm shift. In the old days we would stick to our planned roadmap, and compromise either on delivery dates or software quality. In Agile software development we are willing to compromise on scope, but not on software quality or delivery dates. This means in short: no code goes out untested.   What tests to execute? It is nearly impossible to test everything. There are so many types of tests, like: regression, story acceptance, developer, integration, usability, performance, security, upgrade, user acceptance etc. In our release planning, we must make a conscious decision which of those types we want to execute. Some of the test types may require additional experts, some of the tests may not be relevant, some may be just too costly.   The usual scrum tests Within our sprints, we tend to stick to regression tests, story acceptance tests, developer tests and integration tests. Developer...

SSL handshake failed: Secure connection truncated

Got this problem on Ubuntu 9.10 and 10.10. svn co --username=xx https:/yy zz “SSL handshake failed: Secure connection truncated” According to this link bug-ubuntu The solution is: sudo apt-get install libneon27 cd /usr/lib/ sudo rm libneon-gnutls.so.27 sudo ln -s /usr/lib/libneon.so.27 libneon-gnutls.so.27

Grinderstone under linux

I am using Ubuntu 9.10 jan@albotek:~/development/eclipse$ more /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.10 DISTRIB_CODENAME=karmic DISTRIB_DESCRIPTION="Ubuntu 9.10" I installed new eclipse 3.5.2, and inside eclipse used jdk 1.6.0.20 as default JRE, and jython 2.5.1 for my jython. Still I did not manage to get my grinder scripts with proxy working. The failure I was getting: Java exception initialising test script test1.record(grinder.getLogger().output) File "/home/jan/development/workspace-grinder/Grinder1/src/HelloWorld3.py", line 7, in Caused by: net.grinder.script.NonInstrumentableTypeException: Failed to wrap at net.grinder.engine.process.instrumenter.MasterInstrumenter.instrument(MasterInstrumenter.java:114) at net.grinder.engine.process.TestData.instrument(TestData.java:100) at net.grinder.script.Test.record(Test.java:114) In my output log I was seeing: 6/5/10 10:22:09 a.m. (process albotek-0): The Grinder version 3.4 6/5/10 10:2...

Grinderstone and instrumentation

At least I got my office PC (windows) working now. Script is: # A simple example using the HTTP plugin that shows the retrieval of a # single page via HTTP. from net.grinder.script import Test from net.grinder.script.Grinder import grinder from net.grinder.plugin.http import HTTPRequest test1 = Test(1, "Request resource") request1 = test1.wrap(HTTPRequest()) class TestRunner: def __call__(self): result = request1.GET("http://emeafraippqa08:80/") I used to get failures that had to do with instrumentation. In the end I added a new jdk6 (1.6.0.20) to eclipse, renewed my jython 2.5.1 reference so that it is using these libs, and now got it working. In my console I see the following path: 04.06.10 17:03:42 (agent): The Grinder 3.4 04.06.10 17:03:42 (agent): Worker process command line: java '-javaagent:C:\development\grinder-3.4\lib\grinder-agent.jar' -classpath 'C:\development\jython2.5.1\jython.jar;C:\Dokumente und Einstellungen\jan.keste...