Monthly Archives: April 2021

Automatically Creating Readable Python Codes

In order to create code, that can be traceable and readable for everyone comments are essential. But there are also style guides to follow in order to create a consistent environment in your code. In Python language, this is regulated with a style guide known as PEP 8. I recommend you to check it out, it has some interesting insights. But if you clicked the link, you will see that it is actually pretty long. To read all of it and to be able to write code as it is intended in this guideline seems to be too much work.

But autopep8 comes to help! It is an automatic formatter to make your code conform with the PEP8. In order to install;

$ pip install --upgrade autopep8

To fix your code with autopep8;

$ autopep8 --in-place <filename>

This one will only fix the whitespace issues. But in order to fix other type of style issues –aggressive option should be used.

$ autopep8 --in-place --aggressive --aggressive <filename>

Multiple usage leads to more aggressive fix. Further options and more comments on the type of issues can be seen in the project page.

Headless Raspberry Pi 4 with 3.5inch RPi Display

Even though it sounds contradictory, one needs to configure a headless raspberry pi in order to make use of these type of display without a HDMI cable or connector(or even an external screen) laying around. We will follow official RasPi sources to configure the SSH and wifi connection. By default, SSH is not available on raspberry pi. To make it available:

  • add an empty file without an extension named ‘ssh’ to /boot

Now we will add the wifi connection. If you have an ethernet cable together with a switch that you can connect your host, this part is not necessary.

  • create a file named wpa_supplicant.confand inside of it fill:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}
  • country code can be find in wikipedia. For example, for Germany, it is DE. For example, if your wifi name is Berliner_Kindl and your password is bier. Than conf file should look like this:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE

network={
 ssid="Berliner_Kindl"
 psk="bier"
}
  • Now we need to insert the SD Card to raspberry and wait for it to connect to wifi network(around 5min). One can check from the modem’s connection page and under DHCP Clients List. I would like to add nmap method to here also but I can not make it work again these days…
  • Install nmap fwith the command:
$ sudo apt-get install nmap
  • check the ip address of your device with command:
$ ip a
  • This should give you an address like 123.00.0.00. Than use this command to map all the devices connected to your network:
$ nmap -sP 123.00.0.00/24
  • This will sometimes give a list of ip address together with names, but sometimes not. I believe this depends on the network settings. In case, nmap can not resolve the request than you can try to list the ips before connecting the raspberry pi and after connecting it.

After you get the ip, now it is time to connect to the raspberry pi. Write this on terminal of your host computer(of course changing to ip address of raspberry pi):

$ ssh pi@123.00.0.00
  • The default username is pi and default password is raspberry. Probably, it is a good idea to change this after log in.

Now it is time to configure the RPi 3.5inch display. Write this commands on your raspberry pi SSH window:

sudo rm -rf LCD-show
git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./LCD35-show

To calibrate the screen, follow the code down:

cd LCD-show/
sudo dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb

I would like to install OBS on Raspberry Pi but it is not supported by default unfortunately. I would like to build following this and this pages to see if it is possible. Having a higher memory and better cooling option seems to be a must.

Installing ffmpeg from testing(Bullseye) on Debian 10 Buster[failed]

So one of the problems I am encountering these days is that I want to use this nice package spotDL in my Debian 10 Buster system. But unfortunately spotDL depends on the fmmpeg version of 4.2 but Debian Buster stable is currently only supporting 4.1.6.

To tackle this issue first I made a horrible mistake of trying to add the testing repositories to my sources.list file as suggested in several sources. Of course, mixing testing and stable is something only a beginner such as me will do. As soon as, I run upgraded my upgrade list, I prompted with a question. One should REALLY REALLY read and know what these questions are asking, especially if you are dealing with your sources.list. This was not the case with me and my system starts a full update from testing repositories! Certainly I already created a FrankenDebian. Let’s check what the authors on this infamous page says:

First of all, apt-get upgrade default behavior is to upgrade any installed package to the highest available version. If, for example, you configure the bullseye archive on a buster system, APT will try to upgrade almost all packages to bullseye.

Smart people. I will update later on how I was able to not totally break up my system but I downgraded most of the packages with the command:

$ sudo apt-get install <package-name>/buster

I learned my lesson in hard way. Then, I come across with very nice thing called backports. I added up the the repository for backports

$ deb http://deb.debian.org/debian buster-backports main
$ sudo apt-get update

And run the command for installation of backports version of ffmpeg, only to find ou that it just doesn’t exists.

$ sudo apt-get install ffmpeg/buster-backports

Now the next step was to decide if I should fully upgrade to bullseye, testing version. I thought probably it will be way too hard and it will be the case that my non-Debian packages will/can be gone. As this is not a server but a personal computer, I rely heavily on my kind of non-Debian packages. I really do not have any idea, how server side deals with this, but that is not the issue here.

So I come across with the idea, that you can backport packages my yourself. I will try this in near future, even though it looks pretty complicated.

Edit:

So it was way much more easy than I understand. In this thread, the solution is given:

sudo apt remove ffmpeg
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt install ffmpeg
ffmpeg -version