Lateo.net - Flux RSS en pagaille (pour en ajouter : @ moi)

🔒
❌ À propos de FreshRSS
Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierInformatique & geek

This Raspberry Pi–powered setup improves home brewing

We spied New Orleans–based Raspberry Pi–powered home brewing analysis and were interested in how this project could help other at-home brewers perfect their craft.

Raspberry Pi in a case with fan, neatly tucked away on a shelf in the Danger Shed

When you’re making beer, you want the yeast to eat up the sugars and leave alcohol behind. To check whether this is happening, you need to be able to track changes in gravity, known as ‘gravity curves’. You also have to do yeast cell counts, and you need to be able to tell when your beer has finished fermenting.

“We wanted a way to skip the paper and pencil and instead input the data directly into the software. Enter the Raspberry Pi!”

Patrick Murphy

Patrick Murphy and co. created a piece of software called Aleproof which allows you to monitor all of this stuff remotely. But before rolling it out, they needed somewhere to test that it works. Enter the ‘Danger Shed’, where they ran Aleproof on Raspberry Pi.

The Danger Shed benefits from a fancy light-changing fan for the Raspberry Pi

A Raspberry Pi 3 Model B+ spins their Python-based program on Raspberry Pi OS and shares its intel via a mounted monitor.

Here’s what Patrick had to say about what they’re up to in the Danger Shed and why they needed a Raspberry Pi:

The project uses PyCharm to run the Python-based script on the Raspberry Pi OS

“I am the founder and owner of Arithmech, a small software company that develops Python applications for brewers. Myself and a few buddies (all of us former Army combat medics) started our own brewing project called Danger Shed Ales & Mead to brew and test out the software on real-world data. We brew in the shed and record data on paper as we go, then enter the data into our software at a later time.”

Look how neat and out of the way our tiny computer is

“We wanted a way to skip the paper and pencil and instead input the data directly into the software. Enter the Raspberry Pi! The shed is small, hot, has leaks, and is generally a hostile place for a full-size desktop computer. Raspberry Pi solves our problem in multiple ways: it’s small, portable, durable (in a case), and easily cooled. But on top of that, we are able to run the code using PyCharm, enter data throughout the brewing process, and fix bugs all from the shed!”

The Raspberry Pi in its case inc. fan

“The Raspberry Pi made it easy for us to set up our software and run it as a stand-alone brewing software station.”

Productivity may have slowed when Patrick, Philip, and John remembered you can play Minecraft on the Raspberry Pi

The post This Raspberry Pi–powered setup improves home brewing appeared first on Raspberry Pi.

Debugging Django Management Commands in PyCharm

My favorite editor for Python projects is PyCharm. Besides editing code, it allows you to inspect the database, work with Git repositories, run management commands, execute bash commands and Python scripts, and debug code just in the same window. In this article, I will show you how to set breakpoints and debug Django management commands visually in PyCharm.

Django management commands are scripts that can be executed on your Django project to do something with the project database, media files, or code. Django itself comes with a bunch of commands like: migrate, runserver, collectstatic, makemessages, and clearsessions. Management commands can be executed like this:

(myproject_env)$ python manage.py clearsessions

If you want to create a custom management command in your project, you can find how to do that in the official Django documentation. Also you can find some practical examples in the Chapter 9, Data Import and Export of the Web Development with Django Cookbook - Second Edition.

In this example, I won't create any new management command, but will debug the clearsessions command that is coming from Django and is located at django/contrib/sessions/management/commands/clearsessions.py.

First of all, let's click on "Edit Configurations..." in the top toolbar just before the Run button (with the Play icon). In the opened dialog box "Run/Debug Configurations" click on the "Add New Configuration" button (with the Plus icon) and choose "Python".

Let's fill in the configuration with these values:

Name: Clear Outdated Sessions
Script: /Users/me/DjangoProjects/myproject_env/project/myproject/manage.py
Script paramethers: clearsessions --traceback --verbosity=2
Python interpreter: Python 2.7.6 virtualenv at ~/DjangoProjects/myproject_env
Working directory: /Users/me/DjangoProjects/myproject_env/project/myproject/

Then open the file with the definition of the management command django/contrib/sessions/management/commands/clearsessions.py. Click on the left padding of the editor to add a breakpoint (marked with a red circle) where the script should stop executing for inspection.

Normally to run this script, you could click on the Run button (with the Play icon). But as we want to debug the script, we will click on the Debug button (with the Bug icon) in the toolbar.

The script will start executing and will stop temporarily at the breakpoint you made. You will be able to inspect all local variables in the debug panel that is opened at the bottom of your window by default.

You can navigate through code execution with the arrow buttons "Step Over", "Step Into", etc. To evaluate local or global variables or values, click on the "Evaluate Expression" button (with the Calculator icon) and enter some Python code.

Click on the "Resume Program" button (with the Fast Play icon) to continue execution of the script, when you are ready.

Analogously, you can debug your models, views, forms, or middlewares by running a development server ("Django server") in debug mode.


Cover photo by Jill Heyer

❌