Feeds

Real Python: Socket Programming in Python (Guide)

Planet Python - Sat, 2024-12-07 09:00

Socket programming is essential for network communication, enabling data exchange across different devices. In Python, sockets allow for inter-process communication (IPC) over networks. This tutorial provides a comprehensive guide on creating socket servers and clients, handling multiple connections, and managing errors in Python’s socket module.

By the end of this tutorial, you’ll understand that:

  • A socket in Python is an endpoint for sending or receiving data across a network using the socket API.
  • Socket programming in Python involves using sockets to establish communication between a server and clients over a network.
  • A simple echo server in Python can be created using sockets to listen for client connections and echo back received messages.
  • Handling multiple clients with Python sockets can be achieved using non-blocking sockets and the selectors module for concurrent connections.
  • Connection errors in socket programs in Python can be managed by implementing error handling and using exceptions like OSError.

Along the way, you’ll learn about the main functions and methods in Python’s socket module that let you write your own client-server applications based on TCP sockets. You’ll learn how to reliably send messages and data between endpoints and handle multiple connections simultaneously.

Networking and sockets are large subjects. Literal volumes have been written about them. If you’re new to sockets or networking, it’s completely normal if you feel overwhelmed with all of the terms and pieces. To get the most out of this tutorial, it’s best to download the source code and have it on hand for reference while reading:

Get Your Code: Click here to get the free sample code you’ll use to learn about socket programming in Python.

Take the Quiz: Test your knowledge with our interactive “Socket Programming in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Socket Programming in Python

In this quiz, you'll test your understanding of Python sockets. With this knowledge, you'll be able to create your own client-server applications, handle multiple connections simultaneously, and send messages and data between endpoints.

Historical Background

Sockets have a long history. Their use originated with ARPANET in 1971 and later became an API in the Berkeley Software Distribution (BSD) operating system released in 1983 called Berkeley sockets.

When the Internet took off in the 1990s with the World Wide Web, so did network programming. Web servers and browsers weren’t the only applications taking advantage of newly connected networks and using sockets. Client-server applications of all types and sizes came into widespread use.

Today, although the underlying protocols used by the socket API have evolved over the years, and new ones have developed, the low-level API has remained the same.

The most common type of socket applications are client-server applications, where one side acts as the server and waits for connections from clients. This is the type of application that you’ll be creating in this tutorial. More specifically, you’ll focus on the socket API for Internet sockets, sometimes called Berkeley or BSD sockets. There are also Unix domain sockets, which can only be used to communicate between processes on the same host.

Python Socket API Overview

Python’s socket module provides an interface to the Berkeley sockets API. This is the module that you’ll use in this tutorial.

The primary socket API functions and methods in this module are:

  • socket()
  • .bind()
  • .listen()
  • .accept()
  • .connect()
  • .connect_ex()
  • .send()
  • .recv()
  • .close()

Python provides a convenient and consistent API that maps directly to system calls, their C counterparts. In the next section, you’ll learn how these are used together.

As part of its standard library, Python also has classes that make using these low-level socket functions easier. Although it’s not covered in this tutorial, you can check out the socketserver module, a framework for network servers. There are also many modules available that implement higher-level Internet protocols like HTTP and SMTP. For an overview, see Internet Protocols and Support.

TCP Sockets

You’re going to create a socket object using socket.socket(), specifying the socket type as socket.SOCK_STREAM. When you do that, the default protocol that’s used is the Transmission Control Protocol (TCP). This is a good default and probably what you want.

Why should you use TCP? The Transmission Control Protocol (TCP):

  • Is reliable: Packets dropped in the network are detected and retransmitted by the sender.
  • Has in-order data delivery: Data is read by your application in the order it was written by the sender.

In contrast, User Datagram Protocol (UDP) sockets created with socket.SOCK_DGRAM aren’t reliable, and data read by the receiver can be out-of-order from the sender’s writes.

Why is this important? Networks are a best-effort delivery system. There’s no guarantee that your data will reach its destination or that you’ll receive what’s been sent to you.

Network devices, such as routers and switches, have finite bandwidth available and come with their own inherent system limitations. They have CPUs, memory, buses, and interface packet buffers, just like your clients and servers. TCP relieves you from having to worry about packet loss, out-of-order data arrival, and other pitfalls that invariably happen when you’re communicating across a network.

Read the full article at https://realpython.com/python-sockets/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Real Python: How to Round Numbers in Python

Planet Python - Sat, 2024-12-07 09:00

Rounding numbers in Python is an essential task, especially when dealing with data precision. Python’s built-in round() function uses the rounding half to even strategy, which rounds numbers like 2.5 to 2 and 3.5 to 4. This method helps minimize rounding bias in datasets. To round numbers to specific decimal places, you can use the round() function with a second argument specifying the number of decimals.

For more advanced rounding strategies, you can explore Python’s decimal module or use NumPy and pandas for data science applications. NumPy arrays and pandas DataFrames offer methods for rounding numbers efficiently. In NumPy, you can use functions like np.round(), np.ceil(), np.floor(), and np.trunc() to apply different rounding strategies. For pandas, the df.round() method allows rounding of entire DataFrames or specific columns.

By the end of this tutorial, you’ll understand that:

  • Python uses the rounding half to even strategy, where ties round to the nearest even number.
  • Python’s default rounding strategy minimizes rounding bias in large datasets.
  • You can round numbers to specific decimal places using Python’s round() function with a second argument.
  • Different rounding strategies can be applied using Python’s decimal module or custom functions for precision control.
  • NumPy and pandas provide methods for rounding numbers in arrays and DataFrames, offering flexibility in data manipulation.

You won’t get a treatise on numeric precision in computing, although you’ll touch briefly on the subject. Only a familiarity with the fundamentals of Python is necessary, and the math should feel familiar if you’ve had high school algebra.

You’ll start by looking at Python’s built-in rounding mechanism.

Take the Quiz: Test your knowledge with our interactive “Rounding Numbers in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Rounding Numbers in Python

Test your knowledge of rounding numbers in Python.

Get Your Code: Click here to download the free sample code you’ll use to learn about rounding numbers in Python.

Python’s Built-in round() Function

Python has a built-in round() function that takes two numeric arguments, n and ndigits, and returns the number n rounded to ndigits. The ndigits argument defaults to zero, so leaving it out results in a number rounded to an integer. As you’ll see, round() may not work quite as you expect.

The way most people are taught to round a number goes something like this:

  • Round the number n to p decimal places by first shifting the decimal point in n by p places. To do that, multiply n by 10ᵖ (10 raised to the p power) to get a new number, m.

  • Then look at the digit d in the first decimal place of m. If d is less than 5, round m down to the nearest integer. Otherwise, round m up.

  • Finally, shift the decimal point back p places by dividing m by 10ᵖ.

It’s an algorithm! For example, the number 2.5 rounded to the nearest whole number is 3. The number 1.64 rounded to one decimal place is 1.6.

Now open up an interpreter session and round 2.5 to the nearest whole number using Python’s built-in round() function:

Python >>> round(2.5) 2 Copied!

Gasp!

Check out how round() handles the number 1.5:

Python >>> round(1.5) 2 Copied!

So, round() rounds 1.5 up to 2, and 2.5 down to 2!

Before you go raising an issue on the Python bug tracker, rest assured you that round(2.5) is supposed to return 2. There’s a good reason why round() behaves the way it does.

In this tutorial, you’ll learn that there are more ways to round a number than you might expect, each with unique advantages and disadvantages. round() behaves according to a particular rounding strategy—which may or may not be the one you need for a given situation.

You might be wondering, Can the way I round numbers really have that much of an impact? Next up, take a look at just how extreme the effects of rounding can be.

How Much Impact Can Rounding Have?

Suppose you have an incredibly lucky day and find $100 on the ground. Rather than spending all your money at once, you decide to play it smart and invest your money by buying some shares of different stocks.

The value of a stock depends on supply and demand. The more people there are who want to buy a stock, the more value that stock has, and vice versa. In high-volume stock markets, the value of a particular stock can fluctuate on a second-by-second basis.

Read the full article at https://realpython.com/python-rounding/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Real Python: Python GUI Programming With Tkinter

Planet Python - Sat, 2024-12-07 09:00

Tkinter is Python’s standard GUI framework, making it convenient for developing graphical user interfaces. As a cross-platform library, Tkinter ensures your applications appear native across Windows, macOS, and Linux. Despite criticisms of its outdated appearance, Tkinter remains a practical choice for quickly creating functional and cross-platform GUI applications.

By the end of this tutorial, you’ll understand that:

  • GUI refers to graphical user interfaces, and Tkinter is Python’s built-in library for creating them.
  • Tkinter is included with most Python installations, so separate installation is often unnecessary.
  • Tkinter is still a relevant choice for building simple, cross-platform GUI applications.
  • Widgets in a Tkinter application can be arranged using geometry managers like .pack(), .place(), and .grid().
  • Interactive GUI applications with Tkinter are created by binding events, such as button clicks, to Python functions.

You’ll cover getting started with Tkinter, managing widgets, and creating interactive applications. Once you’ve mastered these skills by working through the exercises at the end of each section, you’ll tie everything together by building two applications. The first is a temperature converter, and the second is a text editor. It’s time to dive right in and learn how to build an application with Tkinter!

Note: This tutorial is adapted from the chapter “Graphical User Interfaces” of Python Basics: A Practical Introduction to Python 3.

The book uses Python’s built-in IDLE editor to create and edit Python files and interact with the Python shell. In this tutorial, references to IDLE have been removed in favor of more general language.

The bulk of the material in this tutorial has been left unchanged, and you should have no problems running the example code from the editor and environment of your choice.

Free Bonus: 5 Thoughts On Python Mastery, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.

Take the Quiz: Test your knowledge with our interactive “Python GUI Programming With Tkinter” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Python GUI Programming With Tkinter

In this quiz, you'll test your understanding of Python GUI Programming With Tkinter, the de facto Python GUI framework. Check your knowledge of GUI programming concepts such as widgets, geometry managers, and event handlers.

Building Your First Python GUI Application With Tkinter

The foundational element of a Tkinter GUI is the window. Windows are the containers in which all other GUI elements live. These other GUI elements, such as text boxes, labels, and buttons, are known as widgets. Widgets are contained inside of windows.

First, create a window that contains a single widget. Start up a new Python shell session and follow along!

Note: The code examples in this tutorial have all been tested on Windows, macOS, and Ubuntu Linux 20.04 with Python version 3.10.

If you’ve installed Python with the official installers available for Windows and macOS from python.org, then you should have no problem running the sample code. You can safely skip the rest of this note and continue with the tutorial!

If you haven’t installed Python with the official installers, or there’s no official distribution for your system, then here are some tips for getting up and going.

Python on macOS with Homebrew:

The Python distribution for macOS available on Homebrew doesn’t come bundled with the Tcl/Tk dependency required by Tkinter. The default system version is used instead. This version may be outdated and prevent you from importing the Tkinter module. To avoid this problem, use the official macOS installer.

Ubuntu Linux 20.04:

To conserve memory space, the default version of the Python interpreter that comes pre-installed on Ubuntu Linux 20.04 has no support for Tkinter. However, if you want to continue using the Python interpreter bundled with your operating system, then install the following package:

Shell $ sudo apt-get install python3-tk Copied!

This installs the Python GUI Tkinter module.

Other Linux Flavors:

If you’re unable to get a working Python installation on your flavor of Linux, then you can build Python with the correct version of Tcl/Tk from the source code. For a step-by-step walk-through of this process, check out the Python 3 Installation & Setup Guide. You may also try using pyenv to manage multiple Python versions.

With your Python shell open, the first thing you need to do is import the Python GUI Tkinter module:

Python >>> import tkinter as tk Copied!

A window is an instance of Tkinter’s Tk class. Go ahead and create a new window and assign it to the variable window:

Python >>> window = tk.Tk() Copied!

When you execute the above code, a new window pops up on your screen. How it looks depends on your operating system:

Throughout the rest of this tutorial, you’ll see Windows screenshots.

Adding a Widget

Now that you have a window, you can add a widget. Use the tk.Label class to add some text to a window. Create a Label widget with the text "Hello, Tkinter" and assign it to a variable called greeting:

Python >>> greeting = tk.Label(text="Hello, Tkinter") Copied!

The window you created earlier doesn’t change. You just created a Label widget, but you haven’t added it to the window yet. There are several ways to add widgets to a window. Right now, you can use the Label widget’s .pack() method:

Python >>> greeting.pack() Copied!

The window now looks like this:

Read the full article at https://realpython.com/python-gui-tkinter/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Real Python: When to Use a List Comprehension in Python

Planet Python - Sat, 2024-12-07 09:00

List comprehensions in Python provide a concise way to create lists by embedding a loop and optional conditional logic in a single line. You use a list comprehension to transform and filter elements from an iterable efficiently. It allows you to replace complex loops and map() functions with more readable and often faster expressions. By understanding list comprehensions, you can optimize your code for better performance and clarity.

You can add conditional logic to a list comprehension in Python by appending an if statement to the end of the expression. This allows you to filter elements based on a condition, effectively replacing the need for filter() in many cases. Additionally, you can use conditional expressions at the beginning to choose between different outcomes, enhancing the versatility of your list comprehensions.

By the end of this tutorial, you’ll understand that:

  • A list comprehension in Python is a tool for creating lists by iterating over an iterable and optionally applying a condition.
  • You should use list comprehensions instead of loops when you want concise, readable code that performs transformations or filtering.
  • You add conditional logic to a list comprehension by including an if statement within the comprehension.
  • A list comprehension can be faster than a for loop because it’s optimized for performance by Python’s internal mechanisms.
  • A Python list comprehension is not lazy—it generates and stores the entire list in memory eagerly.
  • The difference between list comprehensions and map() is that the former creates a list, while the latter returns a map object, which is iterable.
  • To optimize performance with list comprehensions, use them for small to medium-sized lists and profile different approaches to choose the fastest one.

In this tutorial, you’ll explore how to leverage list comprehensions to simplify your code. You’ll also gain an understanding of the trade-offs that come with using them so that you can determine when other approaches are preferable.

Get Your Code: Click here to download the free code that shows you how and when to use list comprehensions in Python.

Take the Quiz: Test your knowledge with our interactive “When to Use a List Comprehension in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

When to Use a List Comprehension in Python

In this quiz, you'll test your understanding of Python list comprehensions. You'll revisit how to rewrite loops as list comprehensions, how to choose between comprehensions and loops, and how to use conditional logic in your comprehensions.

Transforming Lists in Python

There are a few different ways to create and add items to a lists in Python. In this section, you’ll explore for loops and the map() function to perform these tasks. Then, you’ll move on to learn about how to use list comprehensions and when list comprehensions can benefit your Python program.

Use for Loops

The most common type of loop is the for loop. You can use a for loop to create a list of elements in three steps:

  1. Instantiate an empty list.
  2. Loop over an iterable or range of elements.
  3. Append each element to the end of the list.

If you want to create a list containing the first ten perfect squares, then you can complete these steps in three lines of code:

Python >>> squares = [] >>> for number in range(10): ... squares.append(number * number) ... >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] Copied!

Here, you instantiate an empty list, squares. Then, you use a for loop to iterate over range(10). Finally, you multiply each number by itself and append the result to the end of the list.

Work With map Objects

For an alternative approach that’s based in functional programming, you can use map(). You pass in a function and an iterable, and map() will create an object. This object contains the result that you’d get from running each iterable element through the supplied function.

As an example, consider a situation in which you need to calculate the price after tax for a list of transactions:

Python >>> prices = [1.09, 23.56, 57.84, 4.56, 6.78] >>> TAX_RATE = .08 >>> def get_price_with_tax(price): ... return price * (1 + TAX_RATE) ... >>> final_prices = map(get_price_with_tax, prices) >>> final_prices <map object at 0x7f34da341f90> >>> list(final_prices) [1.1772000000000002, 25.4448, 62.467200000000005, 4.9248, 7.322400000000001] Copied!

Here, you have an iterable, prices, and a function, get_price_with_tax(). You pass both of these arguments to map() and store the resulting map object in final_prices. Finally, you convert final_prices into a list using list().

Leverage List Comprehensions

List comprehensions are a third way of making or transforming lists. With this elegant approach, you could rewrite the for loop from the first example in just a single line of code:

Python >>> squares = [number * number for number in range(10)] >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] Copied!

Rather than creating an empty list and adding each element to the end, you simply define the list and its contents at the same time by following this format:

Python Syntax new_list = [expression for member in iterable] Copied! Read the full article at https://realpython.com/list-comprehension-python/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

The Drop Times: Meet the Speakers: DrupalCon Singapore 2024 Part III

Planet Drupal - Sat, 2024-12-07 07:33
The excitement is palpable as DrupalCon Singapore 2024 kicks off tomorrow! In the final episode of our "Meet the Speakers" series, discover how Owen Lansbury of PreviousNext is redefining profitability through open-source business models, and learn from Aastha Shrivastava of QED42 as she spotlights Drupal’s role as a Digital Public Good. Get ready for three action-packed days of innovation, insights, and community from December 9-11, 2024. This is the moment the APAC Drupal community has been waiting for – don’t miss it!
Categories: FLOSS Project Planets

LostCarPark Drupal Blog: Drupal Advent Calendar day 7 - Base Recipe

Planet Drupal - Sat, 2024-12-07 04:00
Drupal Advent Calendar day 7 - Base Recipe james Sat, 12/07/2024 - 09:00

Today we are looking at one of the central elements of Starshot, but also one of the easiest to overlook.

Drupal CMS will come preinstalled with a set of base modules and themes, as the basis on which other recipes will be built. The base theme track is responsible for this. Not only does this provide essential functionality to make a new Drupal site much more usable, it also provides an important baseline for the other tracks to build upon.

Some of the functionality either already implemented, or planned past Drupal CMS 1.0, is listed below.

Pathauto is now installed by default. This is a small…

Tags
Categories: FLOSS Project Planets

Russ Allbery: Review: Dark Minds

Planet Debian - Sat, 2024-12-07 00:22

Review: Dark Minds, by Michelle Diener

Series: Class 5 #3 Publisher: Eclipse Copyright: 2016 ISBN: 0-6454658-5-2 Format: Kindle Pages: 328

Dark Minds is the third book in the self-published Class 5 science-fiction romance series. It is a sequel to Dark Deeds and should not be read out of order, but as with the other books of the series, it follows new protagonists.

Imogen, like another Earth woman before her, was kidnapped by a Class 5 for experimentation by the Tecran. She was subsequently transferred to a research facility and has been held in cages and secret military bases for over three months. As the story opens, she had been imprisoned in a Tecran transport for a couple of weeks when the transport is taken by the Krik who kill all of the Tecran crew. Next stop: another Class 5.

That same Class 5 is where the Krik are taking Camlar Kalor and his team. Cam is a Grih investigator from the United Council, sent to look into reports of a second Earth woman rescued from a Garmman ship. (The series reader will recognize this as the plot of Dark Deeds.) Now he's trapped with the crews of a bunch of other random ships in the cargo hold of a Class 5 with Krik instead of Tecran roaming the halls, apparently at the behest of the ship's banned AI, and a mysterious third Earth woman already appears to be befriending it.

Imogen is the woman Fiona saw signs of in Dark Deeds. She's had a rougher time than the protagonists of the previous two books in this series, and she's been dropped into a less stable situation. The Class 5 she's brought to at the start of the story is far more suspicious (with quite a lot of cause) and somewhat more hostile than the AIs we've encountered previously. The rest of the story formula is roughly the same, though: hunky Grih officer with a personality completely indistinguishable from the hunky Grih officers in the previous two books, an AI with a sketchy concept of morality that desperately needs an ally, the Grih obsession with singing, the eventual discovery of useful armor and weaponry that Imogen can use to surprise people, and more political maneuvering over the Sentient Beings Agreement.

This entry in the series mostly abandons the Grih shock and horror at how badly the Earth women have been treated. This makes sense, given how dangerous Earth women have proven over the course of this series, and I like that Diener is changing the political dynamics as the story develops. I do sometimes miss that appalled anger of Dark Horse, but Dark Minds focuses more on the politics and corridor fighting of a tense multi-sided stand-off.

I found the action more gripping in Dark Minds than in Dark Deeds, and I liked Imogen more as a character than Fiona. She doesn't have the delightfully calm competence of Rose from Dark Horse, but she's a bit more hardened, a bit more canny, and is better at taking control of situations. I also like that Diener avoids simplistically pairing Earth women off with Class 5s. The series plot is progressing faster than I had expected, and that gives this book a somewhat different shape than the previous ones.

Cam is probably the least interesting of the men in this series so far and appears to exist solely to take up the man-shaped hole in the plot. This is not a great series for gender roles; thankfully, the romance is a small part of the plot and largely ignorable. The story is about the women and the AIs, and all of the women and most of the AIs of the previous books make an appearance. It's clear they're forming an alliance whether the Grih like it or not, and that part of the story was very satisfying.

Up to this book, this series had been all feel-good happy endings. I will risk the small spoiler and warn that this is not true to the same degree here, so you may not want to read this one if you want something entirely fluffy, light, and positive (inasmuch as a series involving off-screen experimentation on humans can be fluffy, light, and positive). That caught me by surprise in a way I didn't entirely like, and I wish Diener had stuck with the entirely positive tone.

Other than that, though, this was fun, light, readable entertainment. It's not going to win any literary awards, it's formulaic, the male protagonist comes from central casting, and the emphasis by paragraph break is still a bit grating in places, but I will probably pick up the next book when I'm in the mood for something light. Dark Minds is an improvement over book two, which bodes well for the rest of the series.

Followed by Dark Matters.

Rating: 7 out of 10

Categories: FLOSS Project Planets

This Week in Plasma: Oodles of features!

Planet KDE - Fri, 2024-12-06 23:00

I promised new features soon, and here they are! There are plenty of positive UI changes too. Hopefully what this week's post lacks in quantity will be made up by depth, because these are some nice changes that have been in development for quite some time. Have a look:

Notable New Features

It's now possible to clone a panel! (Niccolò Venerandi, 6.3.0. Link)

KWin's Custom Tiling system now remembers tile arrangement on a per-virtual-desktop basis. (Marco Martin, 6.3.0. Link)

You can now set keyboard shortcuts to move windows between Custom Tiling (as opposed to Quick Tiling) tile zones based on directionality. No default shortcuts were set up for now because all the obvious Modifier+Arrow combinations were already taken. This is an avenue to ponder further in the future. (Akseli Lahtinen, 6.3.0. Link)

It's now possible to limit the upper and lower ranges for tablet pen pressure, not just the shape of the pressure curve. (Joshua Goins, 6.3.0. Link)

Notable UI Improvements

Categories in Kickoff no longer automatically switch on hover by default; they have to be clicked like all other list items elsewhere. This fixes a host of issues related to unexpected category switching and freezes when moving the pointer rapidly over categories. Those who preferred switch-on-hover can turn it back on if they like. (Noah Davis, 6.3.0. Link)

The way Quick Tiling (i.e. with Meta+Arrow keys) works has been slightly changed; now when trying to tile a window in a direction it can't be tiled in anymore because it has hit a screen edge with nothing beyond it, it will simply sit there, rather than un-tiling and teleporting to a potentially unexpected place. (Vlad Zahorodnii, 6.3.0. Link)

System Settings' Display & Monitor page now shows a slider for normal/SDR brightness for each screen, just in case you expected to find it there rather than in the System Tray's Brightness and Color widget. (Xaver Hugl, 6.3.0. Link)

When you hold down Alt+Tab to open the window switcher and then keep those keys held down, the selection highlight will now go all the way to the end, but will no longer hilariously wrap around infinitely until you release the keys again. (Ismael Asensio, 6.3.0. Link)

The active virtual desktop is now remembered per activity. (Xaver Hugl, 6.3.0. Link)

Notable Bug Fixes

Fixed a bug that could cause placeholder and typed text to overlap in KRunner's search field under certain circumstances. (Jack Xu, 6.2.5. Link)

Metadata displayed for Bing picture of the day wallpapers is now displayed correctly. (George Travelbacon, 6.2.5. Link)

When you copy images from Plasma notifications, they can now be pasted into sandboxed apps. (Alessandro Astone, 6.2.5. Link)

After using an application that goes through the input capture portal (e.g. Input Leap) and it quits unexpectedly, you now regain full control of your pointer and keyboard immediately. (David Redondo, 6.2.5 Link)

Keyboard navigation between a filtered subset of windows in the Overview effect now works as you expect it to. (Niccolò Venerandi, 6.3.0. Link)

When you delete a panel but haven't yet dismissed the option to unto this, the deleted panel no longer inappropriately and surprisingly responds to any keyboard shortcuts that toggle any of their widgets. (Niccolò Venerandi, 6.3.0. Link)

Other bug information of note:

Notable in Performance & Technical

Slightly increased the performance of every app and window that uses KWindowStateSaver. (David Edmundson, Frameworks 6.9, Link)

How You Can Help

KDE has become important in the world, and your time and contributions have helped us get there. As we grow, we need your support to keep KDE sustainable.

Thankfully, thousands of you have stepped up in the past week to do just that financially, donating a record-breaking amount of money to KDE e.V., which is just incredible, awe-inspiring even.

So that's a great way to help out. But if you've got more time than money or want to make a difference more directly, then you can help KDE by becoming an active community member and getting involved somehow. Each contributor makes a huge difference in KDE — you are not a number or a cog in a machine!

You don’t have to be a programmer, either. Many other opportunities exist:

To get a new Plasma feature or a bugfix mentioned here, feel free to push a commit to the relevant merge request on invent.kde.org.

Categories: FLOSS Project Planets

Louis-Philippe Véronneau: lintian.debian.org: Episode IV – A New Hope

Planet Debian - Fri, 2024-12-06 20:45

After weeks – dare I say months – of work, it is finally done. lintian.debian.org is back online!

Many, many thanks to everyone who worked hard to make this possible:

  • Thanks to Nicolas Peugnet, the author of lintian-ssg, who handed us this custom static site generator on a silver platter. I'm happy I didn't have to code this myself :)
  • Thanks to Otto Kekäläinen, maintainer of the lintian-ssg package in Debian, who worked in tandem with Nicolas to iron out problems.
  • Thanks to Philipp Kern, who did the work on the DSA side to put the website back online.

All in all, I did very little (mostly coordinating these fine folks) and they should get the credit for this very useful service being back.

Categories: FLOSS Project Planets

KPhotoAlbum 6.0.0 released

Planet KDE - Fri, 2024-12-06 19:00

This time, it’s a short one: We ported KPhotoAlbum to Qt6/KF6. That’s it ;-)

The port itself has been done by Johannes and me, additional commits have been contributed by Randall Rude and Fabian Würfl. Thanks for working on KPA with us!

One thing that’s worth mentioning is: For the map/geodata functionality, we need Marble. The Qt5/KF5 version of Marble can’t be co-installed with the Qt6/KF6 version, and this one is not released yet. But Marble 24.12.0 (which will be the first official Qt6/KF6 release) will be released in a few days. So just wait until it's out before upgrading to KPA 6, to not lose the map parts.

Maybe, the Qt6/KF6 version contains some regressions. The codebase is quite well advanced in years in some parts, and we had to mess with quite some legacy issues to make the whole thing fit for Qt6/KF6. So if you notice anything, please file a respective bug report and/or contact us via our mailing list or Matrix channel (cf. User support → Communication). Thanks for your participation (hopefully, it won’t be necessary too much).

Have a lot of fun with KPhotoAlbum 6 :-)

— Tobias

Categories: FLOSS Project Planets

Plasma Wayland Protocols 1.15.0

Planet KDE - Fri, 2024-12-06 19:00

Plasma Wayland Protocols 1.15.0 is now available for packaging. It is needed for the forthcoming KDE Frameworks.

URL: https://download.kde.org/stable/plasma-wayland-protocols/
SHA256: e5aedfe7c0b2443aa67882b4792d08814570e00dd82f719a35c922a0993f621e Signed by: E0A3EB202F8E57528E13E72FD7574483BB57B18D Jonathan Riddell jr@jriddell.org

Full changelog:

  • Add a request to create a virtual output stream with description
  • Add alpine CI
  • Add modifier information to keystate
  • gitignore: use same as KWin
  • Add a destructor to appmenu manager
  • Add protocol tests
  • Add CI for static builds on Linux
Categories: FLOSS Project Planets

Bálint Réczey: Firebuild 0.8.3 is out with 100+ fixes and experimental macOS support!

Planet Debian - Fri, 2024-12-06 16:53

The new Firebuild release contains plenty of small fixes and a few notable improvements.

Experimental macOS support

The most frequently asked question from people getting to know Firebuild was if it worked on their Mac and the answer sadly used to be that well, it did, but only in a Linux VM. This was far from what they were looking for. 🙁

Linux and macOS have common UNIX roots, but porting Firebuild to macOS included bigger challenges, like ensuring that dyld(1), macOS’s dynamic loader initializes the preloaded interceptor library early enough to catch all interesting calls, and avoid using anything that uses malloc() or thread local variables which are not yet set up then.

Preloading libraries on Linux is really easy, running LD_PRELOAD=my_lib.so ls just works if the library exports the symbols to be interposed, while macOS employs multiple lines of defense to prevent applications from using unknown libraries. Firebuild’s guide for making DYLD_INSERT_LIBRARIES honored on Macs can be helpful with other projects as well that rely on injecting libraries.

Since GitHub’s Arm64 macOS runners don’t allow intercepting binaries with arm64e ABI yet, Firebuild’s Apple Silicon tests are run at Bitrise, who are proud to be first to provide the latest Xcode stacks and were also quick to make the needed changes to their infrastructure to support Firebuild (thanks! ).

Firebuild on macOS can already accelerate simple projects and rebuild itself with Xcode. Since Xcode introduces a lot of nondeterminism to the build, Firebuild can’t shine in acceleration with Xcode yet, but can provide nice reports to show which part of the build is the most time consuming and how each sub-command is called.

If you would like to try Firebuild on macOS please compile it from the GitHub repository for now. Precompiled binaries will be distributed on the Mac App Store and via CI providers. Contact us to get notified when those channels become available.

Dealing with the ‘Epochalypse’

Glibc’s API provides many functions with time parameters and some of those functions are intercepted by Firebuild. Time parameters used to be passed as 32-bit values on 32-bit systems, preventing them to accurately represent timestamps after year 2038, which is known as the Y2038 problem or the Epochalypse.

To deal with the problem glibc 2.34 started providing new function symbol variants with 64-bit time parameters, e.g clock_gettime64() in addition to clock_gettime(). The new 64-bit variants are used when compiling consumers of the API with _TIME_BITS=64 defined.

Processes intercepted by Firebuild may have been compiled with or without _TIME_BITS=64, thus libfirebuild now provides both variants on affected systems running glibc >= 34 to work safely with binaries using 64-bit and 32-bit time representation.

Many Linux distributions already stopped supporting 32-bit architectures, but Debian and Ubuntu still supports armhf, for example, where the Y2038 problem still applies. Both Debian and Ubuntu performed a transition rebuilding every library (and their reverse dependencies) with -D_FILE_OFFSET_BITS=64 set where the libraries exported symbols that changed when switching to 64-bit time representation (thanks to Steve Langasek for driving this!) . Thanks to the transition most programs are ready for 2038, but interposer libraries are trickier to fix and if you maintain one it might be a good idea to check if it works well both 32-bit and 64-bit libraries. Faketime, for example is not fixed yet, see #1064555.

Select passed through environment variables with regular expressions

Firebuild filters out most of the environment variables set when starting a build to make the build more reproducible and achieve higher cache hit rate. Extra environment variables to pass through can be specified on the command line one by one, but with many similarly named variables this may become hard to maintain. With regular expressions this just became easier:

firebuild -o 'env_vars.pass_through += "MY_VARS_.*"' my_build_command

If you are not interested in acceleration just would like to explore what the build does by generating a report you can simply pass all variables:

firebuild -r -o 'env_vars.pass_through += ".*"' my_build_command Other highlights from the 0.8.3 release
  • Fixed and nicer report in Chrome and other WebKit based browsers
  • Support GLibc 2.39 by intercepting pidfd_spawn() and pidfd_spawnp()
  • Even faster Rust build acceleration

For all the changes please check out the release page on GitHub!

(This post is also published on The Firebuild blog.)

Categories: FLOSS Project Planets

Centarro: Drupal Commerce support for CPQ and product customization

Planet Drupal - Fri, 2024-12-06 16:48

Drupal Commerce is an open source eCommerce platform that natively extends Drupal to sell any type of product to anyone in the world. This includes sales of products that are customized at the point of sale, like an engraved piece of jewelry or an event registration. It also includes sales to B2B customers and others who require a configure, price, quote (CPQ) workflow to review and authorize a purchase.

This post explains the feature set at a high level with an example configuration.

Drupal's data architecture

Supporting this feature set is Drupal's data architecture, which lets the Commerce modules define new data types for entities like products, orders, order items, and more. These are defined with sets of base fields, and they can be extended further with custom fields as needed. (Read more about this subject at Drupalize.Me.)

For example, one of our merchants sells scuba equipment. While product variations include price and SKU base fields by default, this merchant added custom fields for the specifications of different models. This structured product information is then rendered to PDPs, displayed in product comparison charts, and exposed as facets in search interfaces to help customers find the right product.

When you add custom fields to an entity, you don't just get to determine where and how they are displayed but also the form interface(s) used to input field data. You can control the number of values a field supports and the type of form element used to set those values (e.g., checkboxes, select list, free tagging textfield, etc.). For data types that support multiple form modes, like order items, you can also determine the context in which a particular field will be editable by a user.

Read more
Categories: FLOSS Project Planets

FSD meeting recap 2024 12 06

FSF Blogs - Fri, 2024-12-06 15:44
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

FSF Blogs: FSD meeting recap 2024 12 06

GNU Planet! - Fri, 2024-12-06 15:44
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

Bojan Mihelac: Finding Blocks Across a Wagtail Site

Planet Python - Fri, 2024-12-06 14:37
Discover how to efficiently locate and update specific blocks across your Wagtail site, even when they're deeply nested.
Categories: FLOSS Project Planets

Dirk Eddelbuettel: RcppArmadillo 14.2.2-1 on CRAN: Small Upstream Fixes

Planet Debian - Fri, 2024-12-06 13:34

Armadillo is a powerful and expressive C++ template library for linear algebra and scientific computing. It aims towards a good balance between speed and ease of use, has a syntax deliberately close to Matlab, and is useful for algorithm development directly in C++, or quick conversion of research code into production environments. RcppArmadillo integrates this library with the R environment and language–and is widely used by (currently) 1197 other packages on CRAN, downloaded 37.5 million times (per the partial logs from the cloud mirrors of CRAN), and the CSDA paper (preprint / vignette) by Conrad and myself has been cited 605 times according to Google Scholar.

Conrad released a minor version 14.2.2 yesterday. This followed a bit of recent work a few of us did in the ensmallen and mlpack repositories following the [14.2.0 release]. Use of (member functions) .min(index) and .max(index) was deprecated in Armadillo in favor of .index_mix() and .index_max(). By now ensmallen and mlpack have been updated at CRAN. To add some spice, CRAN emailed that the (very much unreleased as of now, but coming likely next spring) gcc-15 was unhappy with RcppArmadillo due to some Armadillo code. This likely related to the listed gcc-15 C++ change about “Qualified name lookup failure into the current instantiation”. Anyway, Conrad fixed it within days and that change too is part of this new version (as is a small behaviour normalization between the two indexing methods that matters in case of ties, this was in 14.2.1).

The changes since the last CRAN release are summarised below.

Changes in RcppArmadillo version 14.2.2-1 (2024-12-05)
  • Upgraded to Armadillo release 14.2.2 (Smooth Caffeine)

    • Workarounds for regressions in pre-release versions of GCC 15

    • More selective detection of symmetric/hermitian matrices by various functions

Changes in RcppArmadillo version 14.2.1-1 (2024-11-24) (GitHub Only)
  • Upgraded to Armadillo release 14.2.1 (Smooth Caffeine)

    • Fix for index_min() and index_max() to ensure that the first index of equal extremum values is found

Courtesy of my CRANberries, there is a diffstat report relative to previous release. More detailed information is on the RcppArmadillo page. Questions, comments etc should go to the rcpp-devel mailing list off the Rcpp R-Forge page.

If you like this or other open-source work I do, you can sponsor me at GitHub.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

Aten Design Group: Drupal 11 is Here! What you Need to Know about New Development Features

Planet Drupal - Fri, 2024-12-06 12:25
Drupal 11 is Here! What you Need to Know about New Development Features jenna Fri, 12/06/2024 - 10:25 Drupal

Your organization may use Drupal as a CMS, application framework, site builder, or all of the above. Within the context of this article about new features in the latest version, I'd like you to think about Drupal as a system.

It provides some standard pieces—things like content types, users and roles, taxonomies—and standard ways of connecting them to one another. But out of the box, it's sort of a jumble of pieces, and requires putting those pieces together for it to be meaningful.

A lot of the features that you'll see in Drupal 11.0 are developer-focused, and mostly benefit people who are building or maintaining sites, and your end users won't necessarily notice anything different. But there are some new features that can impact content administrators.

Content Admin

There's a new admin menu available using the Navigation module, which was brought into Drupal core as an experimental module. It's been a long time coming, and I think it's wonderful. It works well with the default Claro admin theme, and makes working in Drupal admin UI feel more modern and friendly. If you've used the Gin admin theme, the new menu will feel familiar, because it shares many of the same ideas.

There are some cool things in CKEditor 5 like markdown shortcuts similar to those we’re used to in Slack and Google Docs. For example, if you start typing something like 1-period-space, those tools automatically start creating a numbered list for you. It also supports other shortcuts like asterisks for bold, underscores for italics, or number-signs for heading levels. I prefer keyboard shortcuts wherever possible, and this makes working within CKEditor significantly faster. 

Recipes

Recipes are a way of packaging up configurations and settings that deliver a certain kind of functionality. In Drupal 11 core, there are recipes for things like the basic page content type, document media type, and editorial workflow. These are site features that previously were created during site installation using the Standard profile, which then became a permanent part of your project.

Recipes are applied rather than installed, so they don't end up becoming a dependency of your site, and therefore, you don't get locked in. You can remove modules or update configuration without changing the original recipe. And if the recipe changes, it doesn't change your site unless you reapply it.

Unlike configuration management, recipes aren't all-or-nothing – meaning you can make a recipe for broad, general functionality or something super specific. Because recipes are so flexible and don't create dependencies to themselves, they can be easily combined and shared, or adapted to fit your own needs.

For site owners, recipes will be really useful because it will make adding new features considerably faster because you can apply one or more recipes, rather than having to build everything up yourself. Because recipes are easily shareable, you'll also be able to find recipes created by others. In fact there's already a “Recipes Cookbook” on drupal.org with various site starters and functionality-specific recipes.

At Aten, our Drupal developers will be able to use recipes to quickly recreate commonly-needed features that our projects require. For example: installing Aten's Mercury Editor module, standing up our default Single Directory Components, configuring our QA service and module, or setting up search functionality. And they'll allow us to share our work with others in a way that doesn't bind them to all the parts of our standard processes.

Single Directory Components

Speaking of Single Directory Components, that module is now stable in Drupal 11.

Here we're using the term component as a piece of a web page that's modular and needs to be reusable. These are generic building blocks of pages that will appear throughout your site such as an accordion, call to action, banners, and slideshows.

Single Directory Components (SDC) are a way of organizing the files needed to display a single component (the Twig template, CSS, and JavaScript) into a folder. If you follow the naming conventions, Drupal will automatically generate a library to combine all of these for you. When you add an SDC to a page, Drupal will load the CSS and JavaScript for the components automatically.

Because SDCs are essentially self-contained, it's fairly easy to reuse them across different projects and entity types—things like Paragraphs or custom block types.

SDCs make the implementation of component libraries or design systems much easier because you can change Drupal's output to match whatever structure is needed.  Aten makes heavy use of Single Directory Components for projects using Mercury Editor, our drag-and-drop content authoring experience that allows editors to preview content changes in real time. 

Workspaces

The Workspaces module is stable in Drupal 11. Workspaces allow you to create multiple copies of your live site and within these copies, you can work on changes like content edits or structural changes, and then deploy those changes to the live workspace.

It can allow you to do things like test out menu changes, completely reorganize a section of your site; or maybe you have seasonal content that all needs to go live at the same time. You could work on those within a new workspace (or in multiple workspaces). And then when those changes are ready to go live, they all happen at once.

Currently, we can do that with individual pages using content moderation and workflow, but it's always been hard to work on a big set of changes over time and preview them. 

I've experimented with Workspaces in the past and with this stable release. Although I think it's a fantastic idea, because it's a different way of handling content changes, it may be incompatible with your content model or modules you're using.

If you're already doing anything with content moderation, layouts, or translations, Workspaces is going to add a new layer of complexity. It may require a lot of training and continued support before content administrators are comfortable with a new workflow. 

Time to upgrade

Now that I’ve laid out all of the new features of Drupal 11, it’s time to determine when and how to best upgrade your Drupal site. Get in touch with us for upgrade help.
 

Seth Hill
Categories: FLOSS Project Planets

Drupalize.Me: Understanding the Difference Between Cache Keys and Cache Tags in Drupal

Planet Drupal - Fri, 2024-12-06 12:16
Understanding the Difference Between Cache Keys and Cache Tags in Drupal

Have you ever wondered "What is the difference between cache keys and cache tags?" One of our Drupalize.Me members wrote in asking about it, and the answer provides insight into how Drupal's Cache API works.

joe Fri, 12/06/2024 - 11:16
Categories: FLOSS Project Planets

MidCamp - Midwest Drupal Camp: MidCamp 2025 Planning Meetings Now on Wednesdays!

Planet Drupal - Fri, 2024-12-06 11:00
MidCamp 2025 Planning Meetings Now on Wednesdays!

We’ve got an important scheduling update for all our MidCamp 2025 organizers! Starting in December 2024, our bi-weekly planning meetings will be moving from Mondays to Wednesdays.

Why the change?

We’re shifting to Wednesdays to better accommodate everyone’s schedules and keep our planning momentum strong. These meetings are crucial for getting everything in place for MidCamp 2025, and we want as many voices as possible in the conversation.

What to Expect:
  • New Meeting Time: Every other Wednesday at 3:00 PM CT.
  • First Meeting: Our first Wednesday meeting will be on December 11, 2024.

We appreciate everyone’s flexibility and can’t wait to keep the MidCamp 2025 planning energy high! If you have any questions or can’t make the new time, reach out in Slack or email us. We’re here to make sure you’re involved!

How to Join:

All planning details will continue to be shared in our MidCamp Slack, so keep an eye on the #midcamp-organizers channel for updates and links. Not yet in Slack? Join the MidCamp Slack here!

Categories: FLOSS Project Planets

Pages