Feeds
LN Webworks: How To Use Cron Jobs For Task Automation In Drupal
The efficiency of any website is a must in this fast-paced world of web development. One of the most important tools to maximize the efficiency of your Drupal site is cron jobs.
Cron jobs are powerful tools that automate any kind of routine tasks of the website which decreases the big load of a developer or site administrator. In this article, I will give you important insights about cron jobs and how we can use them within Drupal, followed by how we customize the tasks by overriding services of the ultimate cron job module.
What is Cron Jobs in Drupal?Cron in Drupal works quite well as it coordinates all the backstage tasks. It handles everything from clearing caches to checking for updates of any kind of content and executing scheduled tasks set by your modules.
Zato Blog: Enterprise Python: Integrating with Salesforce
Salesforce connections are one of the newest additions to Zato 3.2, allowing you to look up and manage Salesforce records and other business data. To showcase it, the article will create a sample Salesforce marketing campaign in a way that does not require the usage of anything else except for basic REST APIs combined with plain Python objects, such as dicts.
If you have not done it already, you can download Zato here.
Basic workflowThe scope of our works will be:
- Creating Salesforce credentials for our integration project
- Defining a Salesforce connection in Zato
- Authoring a service that will map input data to the format that Salesforce expects
- Creating a Zato REST channel that will be invoked through curl during tests
- Testing the integration
To be able to create as connection to Salesforce in the next step, we need a few credentials. There is a full article about how to prepare them and this section is the gist of it.
In runtime, based on this information, Zato will obtain the necessary authentication and authorization tokens itself, which means that you will only focus on the business side of the integrations, not on the low-level aspects of it.
The process of obtaining the credentials needs to be coordinated with an administrator of your organization. To assist in that, the screenshots below explain where to find them.
The credentials are:
- Username and password
- Consumer key
- Consumer secret
The username and password are simply the same credentials that can be used to log in to Salesforce:
Consumer key and secret are properties of a connected app - this is a term that Salesforce uses for API clients that invoke its services. If you are already an experienced Salesforce REST API user, you may know the key and secret under their aliases of "client_id" and "client_secret" - these are the same objects.
Note that when a connected app already exists and you would like to retrieve the key and secret, they will be available under the "View" menu option for the app, not under "Edit" or "Manage".
Defining a Salesforce connection in ZatoWith all the credentials in place, we can create a new Salesforce connection in Zato Dashboard, as below.
Authoring an integration service in PythonAbove, we created a connection definition that lets Zato obtain session tokens and establish connections to Salesforce. Now, we can create an API service that will make use of such connections.
In the example below, we are using the POST REST method to invoke an endpoint that creates new Salesforce campaigns. In your own integrations, you can invoke any other Salesforce endpoint, using any REST method as needed, by following the same pattern, which is, create a model with input fields, build a Python dict for the request to Salesforce, invoke it and map all the required from the response from Salesforce to that which your own service returns to its own callers.
Note that we use a datamodel-based SimpleIO definition for the service. Among other things, although we are not going to do it here, this would let us offer definitions for this and other services.
# -*- coding: utf-8 -*- # stdlib from dataclasses import dataclass # Zato from zato.server.service import Model, Service # ########################################################################### if 0: from zato.server.connection.salesforce import SalesforceClient # ########################################################################### @dataclass(init=False) class CreateCampaignRequest(Model): name: str segment: str # ########################################################################### @dataclass(init=False) class CreateCampaignResponse(Model): campaign_id: str # ########################################################################### class CreateCampaign(Service): class SimpleIO: input = CreateCampaignRequest output = CreateCampaignResponse def handle(self): # This is our input data input = self.request.input # type: CreateCampaignRequest # Salesforce REST API endpoint to invoke - note that Zato # will add a prefix to it containing the API version. path = '/sobjects/Campaign/' # Build the request to Salesforce based on what we received request = { 'Name': input.name, 'Segment__c': input.segment, } # .. create a reference to our connection definition .. salesforce = self.cloud.salesforce['My Salesforce Connection'] # .. obtain a client to Salesforce .. with salesforce.conn.client() as client: # type: SalesforceClient # .. create the campaign now .. sf_response = client.post(path, request) # .. build our response object .. response = CreateCampaignResponse() response.campaign_id = sf_response['id'] # .. and return its ID to our caller. self.response.payload = response # ########################################################################### Creating a REST channelNote that we assign HTTP Basic Auth credentials to the channel. In this manner, it is possible for clients of this REST channel to authenticate using a method that they are already familiar which simplifies everyone's work - it is Zato that deals with how to authenticate against Salesforce whereas your API clients use the ubiquitous HTTP Basic Auth method.
Testing
The last step is to invoke the newly created channel:
$ curl http://api:password@localhost:17010/api/campaign/create -d '{"name":"Hello", "segment":"123"}' {"campaign_id":"8901Z3VHXDTebEJWs"} $That is everything - you have just integrated with Salesforce and exposed a REST channel for external applications to integrate with!
More blog posts➤Russ Allbery: Review: The Stars, Like Dust
Review: The Stars, Like Dust, by Isaac Asimov
Series: Galactic Empire #2 Publisher: Fawcett Crest Copyright: 1950, 1951 Printing: June 1972 Format: Mass market Pages: 192The Stars, Like Dust is usually listed as the first book in Asimov's lesser-known Galactic Empire Trilogy since it takes place before Pebble in the Sky. Pebble in the Sky was published first, though, so I count it as the second book. It is very early science fiction with a few mystery overtones.
Buying books produces about 5% of the pleasure of reading them while taking much less than 5% of the time. There was a time in my life when I thoroughly enjoyed methodically working through a used book store, list in hand, tracking down cheap copies to fill in holes in series. This means that I own a lot of books that I thought at some point that I would want to read but never got around to, often because, at the time, I was feeling completionist about some series or piece of world-building. From time to time, I get the urge to try to read some of them.
Sometimes this is a poor use of my time.
The Galactic Empire series is from Asimov's first science fiction period, after the Foundation series but contemporaneous with their collection into novels. They're set long, long before Foundation, but after humans have inhabited numerous star systems and Earth has become something of a backwater. That process is just starting in The Stars, Like Dust: Earth is still somewhere where an upper-class son might be sent for an education, but it has been devastated by nuclear wars and is well on its way to becoming an inward-looking relic on the edge of galactic society.
Biron Farrill is the son of the Lord Rancher of Widemos, a wealthy noble whose world is one of those conquered by the Tyranni. In many other SF novels, the Tyranni would be an alien race; here, it's a hierarchical and authoritarian human civilization. The book opens with Biron discovering a radiation bomb planted in his dorm room. Shortly after, he learns that his father had been arrested. One of his fellow students claims to be in Biron's side against the Tyranni and gives him false papers to travel to Rhodia, a wealthy world run by a Tyranni sycophant.
Like most books of this era, The Stars, Like Dust is a short novel full of plot twists. Unlike some of its contemporaries, it's not devoid of characterization, but I might have liked it better if it were. Biron behaves like an obnoxious teenager when he's not being an arrogant ass. There is a female character who does a few plot-relevant things and at no point is sexually assaulted, so I'll give Asimov that much, but the gender stereotypes are ironclad and there is an entire subplot focused on what I can only describe as seduction via petty jealousy.
The writing... well, let me quote a typical passage:
There was no way of telling when the threshold would be reached. Perhaps not for hours, and perhaps the next moment. Biron remained standing helplessly, flashlight held loosely in his damp hands. Half an hour before, the visiphone had awakened him, and he had been at peace then. Now he knew he was going to die.
Biron didn't want to die, but he was penned in hopelessly, and there was no place to hide.
Needless to say, Biron doesn't die. Even if your tolerance for pulp melodrama is high, 192 small-print pages of this sort of thing is wearying.
Like a lot of Asimov plots, The Stars, Like Dust has some of the shape of a mystery novel. Biron, with the aid of some newfound companions on Rhodia, learns of a secret rebellion against the Tyranni and attempts to track down its base to join them. There are false leads, disguised identities, clues that are difficult to interpret, and similar classic mystery trappings, all covered with a patina of early 1950s imaginary science. To me, it felt constructed and artificial in ways that made the strings Asimov was pulling obvious. I don't know if someone who likes mystery construction would feel differently about it.
The worst part of the plot thankfully doesn't come up much. We learn early in the story that Biron was on Earth to search for a long-lost document believed to be vital to defeating the Tyranni. The nature of that document is revealed on the final page, so I won't spoil it, but if you try to think of the stupidest possible document someone could have built this plot around, I suspect you will only need one guess. (In Asimov's defense, he blamed Galaxy editor H.L. Gold for persuading him to include this plot, and disavowed it a few years later.)
The Stars, Like Dust is one of the worst books I have ever read. The characters are overwrought, the politics are slapdash and build on broad stereotypes, the romantic subplot is dire and plays out mainly via the Biron egregiously manipulating his petulant love interest, and the writing is annoying. Sometimes pulp fiction makes up for those common flaws through larger-than-life feats of daring, sweeping visions of future societies, and ever-escalating stakes. There is little to none of that here. Asimov instead provides tedious political maneuvering among a class of elitist bankers and land owners who consider themselves natural leaders. The only places where the power structures of this future government make sense are where Asimov blatantly steals them from either the Roman Empire or the Doge of Venice.
The one thing this book has going for it — the thing, apart from bloody-minded completionism, that kept me reading — is that the technology is hilariously weird in that way that only 1940s and 1950s science fiction can be. The characters have access to communication via some sort of interstellar telepathy (messages coded to a specific person's "brain waves") and can travel between stars through hyperspace jumps, but each jump is manually calculated by referring to the pilot's (paper!) volumes of the Standard Galactic Ephemeris. Communication between ships (via "etheric radio") requires manually aiming a radio beam at the area in space where one thinks the other ship is. It's an unintentionally entertaining combination of technology that now looks absurdly primitive and science that is so advanced and hand-waved that it's obviously made up.
I also have to give Asimov some points for using spherical coordinates. It's a small thing, but the coordinate systems in most SF novels and TV shows are obviously not fit for purpose.
I spent about a month and a half of this year barely reading, and while some of that is because I finally tackled a few projects I'd been putting off for years, a lot of it was because of this book. It was only 192 pages, and I'm still curious about the glue between Asimov's Foundation and Robot series, both of which I devoured as a teenager. But every time I picked it up to finally finish it and start another book, I made it about ten pages and then couldn't take any more. Learn from my error: don't try this at home, or at least give up if the same thing starts happening to you.
Followed by The Currents of Space.
Rating: 2 out of 10
www-zh-cn @ Savannah: Welcome our new member - integral
Hi, All:
Please join me in welcoming our new member:
User Details:
-------------
Name:
Login: integral
Email: integral@member.fsf.org
I wish integral a wonderful journey in GNU CTT.
Happy Hacking
wxie
Go Deh: Searching OEIS tables
A few months ago I submitted a series to OEIS* that was accepted; yes, but OEIS does not seem to leave my series searchable!
*OEIS is the Online Encyclopedia of Integer Series. I guess table is not in the name, but...
(best viewed on larger than a portrait phone)
The documentation for OEIS, explains that if you have a 2D triangle or table of values rather than a one dimensional strict series, then one should antidiagonalise the data and submit the series produced.
They give as an example A003987 . This gives this table:
Table begins 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ... 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, ... 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, ... 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, ... 4, 5, 6, 7, 0, 1, 2, 3, 12, ... 5, 4, 7, 6, 1, 0, 3, 2, ... 6, 7, 4, 5, 2, 3, 0, ... 7, 6, 5, 4, 3, 2, ... 8, 9, 10, 11, 12, ... 9, 8, 11, 10, ... 10, 11, 8, ... 11, 10, ... 12, ... ...The above gets antidiagonalised to the series beginning:
0, 1, 1, 2, 0, 2, 3, 3, 3, 3, 4, 2, 0, 2, 4, 5, 5, 1, 1, 5, 5, 6, 4, 6, 0, 6, 4, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 6, 4, 6, 0, 6, 4, 6, 8, 9, 9, 5, 5, 1, 1, 5, 5, 9, 9, 10, 8, 10, 4, 2, 0, 2, 4, 10, 8, 10, 11, 11, 11, 11, 3, 3, 3, 3, 11, 11, 11, 11, 12, 10, 8, 10, 12, 2, 0, 2, 12, 10, 8, 10, 12, 13, 13, 9, 9, 13, 13, 1, 1, 13, 13, 9, 9, 13, 13Searching...If we search for a sub-sequence of the antidiagonalised table, we can find the correct entry.
If, however, we search for a row of the values from the table, A003987 is not found!
The values chosen: to search for: 5,4,7,6,1,0,3 appear near the end of the table which shows that that row of numbers should be followed by a 2.
The table shows 13*13 / 2 ~ 85 values. OEIS has a list of 104 values, so it has the data to search through.
It seems to me that the most intuitive way to search a table of values is by row, left to right. There are other ways to search a table, (assuming an origin at top left and the table extends to the right and down):
- By row, L2R. →, R2L ←
- By Column Top2Bottom, ↓, B2T ↑
- By 45 degree diagonals, ↘, ↖, ↙, ↗
OEIS doesn't seem to do these searches on tabular data.
I did play around and created some code to recreate a table as a list of row-lists, in Python, given an OEIS B-file. The options handling is a work in progress, but the main part was being able to generate the table.
# -*- coding: utf-8 -*-# %%"""adia_to_table.py fileGenerate 2D table from OEIS type anti-diagonalised sequence held in file
Created on Thu Apr 4 18:16:07 2024
@author: paddy3118"""
from itertools import zip_longestimport math# from pprint import ppfrom antidiagonals import antidiag_triangle_indices
def read_bfile(bfname: str) -> tuple[int | None, # first index list[int]]: # anti-diag values """Read B-file bfname
## B-File format:* Ref: https://oeis.org/SubmitB.html* Blank lines ignored* Lines beginning with # ignored* Lines of two, space-separated integers <index> <indexed-value>
It is assumed the index increments by one on subsequent lines. """ first_index, values = None, [] with open(bfname) as bfile: for line in bfile: ln = line.strip() if not ln or ln.startswith('#'): continue index, value = [int(field) for field in ln.split()[:2]] if first_index is None: first_index = index values.append(value)
return first_index, values
def antidiag_to_table(sequence: list[int]) -> list[list[int]]: """ Convert anti-diagonalised sequence back to infinite 2D table.
Parameters ---------- sequence : list[int] Anti-diagonalised values from table.
Returns ------- list[list[int]] Table of rows of ints.
Table rows will fill in from successive sequence values like this:
1 2 4 7 11 16 ... 3 5 8 12 17 6 9 13 18 10 14 19 15 20 21 . . . """
# 1, 3, 6, 10, 15, 21, ... rows*(rows+1) / 2
# min columns in triangular table generation. ~= min rows size = len(sequence) # = rows*(rows+1)/2 rows = math.ceil((-1 + math.sqrt(4 * 2 * size)) / 2) # solve for rows # cols = rows # last row may be deleted if last anti-diag is part filled. # print(f"{(size, cols) = }")
# Empty (triangular) table of None's table = [[None] * (rows - i) for i in range(rows)]
indices = antidiag_triangle_indices() col = 0 # for if sequence is empty for val, (row, col) in zip(sequence, indices): table[row][col] = val
# Remove unfilled part of last anti-diag of table while col > 0: row, col = next(indices) table[row].pop(-1) # remove last row if present and empty if table and not table[-1]: table.pop(-1)
return table
def pp_table(table: list[list[int]]) -> None: "Pretty-print table of differring row lengths" if not table: return col_width = max(max(len(str(val)) for val in row) for row in table) for row in table: print(''.join(f"{val:{col_width}}" for val in row))
def transpose(table: list[list[int]]) -> list[list[int]]: "Table of rows to x<>y transposed table of new rows" fv = math.nan tr = [list(new_row) for new_row in zip_longest(*table, fillvalue=fv)] # remove fillvalues in triangular transposition for row in tr: try: row[row.index(fv):] = [] except ValueError: continue
return tr
if __name__ == "__main__": print("# TEST FILL BY ANTI-DIAGONAL\n") for n in range(0, 8): print(f"{n = }:\n") ans = antidiag_to_table(list(range(1, n+1))) pp_table(ans) print()
fname, m = 'b365096.txt', 505 print(f"\n\n# Data from {fname}, first {m} values:\n") ad = read_bfile(fname) ans = antidiag_to_table(ad[1][:m]) pp_table(ans) print("\n## Transposed:\n") pp_table((tr:=transpose(ans)))
And antidiagonals.py is this:
# -*- coding: utf-8 -*-"""Anti-diagonals:0,0 0,1 0,2 0,31,0 1,1 1,2 1,32,0 2,1 2,2 2,33,0 3,1 3,2 3,3
Of Square:0,0 0,1 1,0 0,2 1,1 2,0 0,3 1,2 2,1 3,0 1,3 2,2 3,1 2,3 3,2 3,3
of Infinite table:0,0 0,1 1,0 0,2 1,1 2,0 0,3 1,2 2,1 3,0 0,4 1,3 2,2 3,1 4,0 ...
Created on Mon Aug 21 13:36:31 2023
@author: paddy
"""# %% Triangles
from itertools import islice
def antidiag_triangle_indices() -> tuple[int, int]: x = y = 0 while True: yield (x, y) x, y = (x+1, y-1) if y else (0, x+1)
list(islice(antidiag_triangle_indices(), 15))
# %% Rectangles
from itertools import islice
def antidiag_rectangle_indices(sizex: int=4, sizey: int=4) -> tuple[int, int]: x = y = 0 while True: yield (x, y) if (x, y) == (sizex - 1, sizey - 1): break x, y = (x+1, y-1) if x == sizex or y < 0: u = x + y + 1 x, y = (0, u) if u < sizey else (u - sizey + 1, sizey - 1)
list(antidiag_rectangle_indices(3, 4))
END.
gnulib @ Savannah: GNU gnulib: calling for beta-testers
If you are developer on a package that uses GNU gnulib as part of its build system:
gnulib-tool has been known for being slow for many years. We have listened to your complaints. A rewrite of gnulib-tool in another programming language (Python) is ready for beta-testing. It is between 8 times and 100 times faster than the original gnulib-tool.
Both implementations should behave identically, that is, produce the same generated files and the same output. You can help us ensure this, through the following steps:
1. Make sure you have Python (version 3.7 or newer) installed on your machine.
2. Update your gnulib checkout. (For some packages, it comes as a git submodule named 'gnulib'.) Like this:
$ git checkout master
$ git pull
Set the environment variable GNULIB_SRCDIR, pointing to this checkout.
If the package is using a git submodule named 'gnulib', it is also advisable to do
$ git commit -m 'build: Update gnulib submodule to latest.' gnulib
(as a preparation for step 5, because the --no-git option does not work as expected in all variants of 'bootstrap').
3. Set an environment variable that enables checking that the two implementations behave the same:
$ export GNULIB_TOOL_IMPL=sh+py
4. Clean the built files of your package:
$ make -k distclean
5. Regenerate the fetched and generated files of your package. Depending on the package, this may be a command such as
$ ./bootstrap --no-git --gnulib-srcdir=$GNULIB_SRCDIR
or
$ export GNULIB_SRCDIR; ./autopull.sh; ./autogen.sh
or, if no such script is available:
$ $GNULIB_SRCDIR/gnulib-tool --update
If there is a failure, due to differences between the 'sh' and 'py' results, please report it to <bug-gnulib@gnu.org>.
6. If this invocation was successful, you can trust the rewritten gnulib-tool and use it from now on, by setting the environment variable
$ export GNULIB_TOOL_IMPL=py
7. Continue with
$ ./configure
$ make
as usual.
And enjoy the speed! The rewritten gnulib-tool was implemented by Dmitry Selyutin, Collin Funk, and me.
KDE Gear 24.05 branches created
releases to them
Next Dates
- April 25 2024: 24.05 Freeze and Beta (24.04.80) tag & release
- May 9, 2024: 24.05 RC (24.04.90) Tagging and Release
- May 16, 2024: 24.05 Tagging
- May 23, 2024: 24.05 Release
https://community.kde.org/Schedules/KDE_Gear_24.05_Schedule
The Drop Times: Drupal's Innovation & Future: 2024 and Beyond—Part 2 | Industry Experts' Perspective
Bastian Venthur: Help needed: creating a WSDL file to interact with debbugs
I am upstream and Debian package maintainer of python-debianbts, which is a Python library that allows for querying Debian’s Bug Tracking System (BTS). python-debianbts is used by reportbug, the standard tool to report bugs in Debian, and therefore the glue between the reportbug and the BTS.
debbugs, the software that powers Debian’s BTS, provides a SOAP interface for querying the BTS. Unfortunately, SOAP is not a very popular protocol anymore, and I’m facing the second migration to another underlying SOAP library as they continue to become unmaintained over time. Zeep, the library I’m currently considering, requires a WSDL file in order to work with a SOAP service, however, debbugs does not provide one. Since I’m not familiar with WSDL, I need help from someone who can create a WSDL file for debbugs, so I can migrate python-debianbts away from pysimplesoap to zeep.
How did we get here?Back in the olden days, reportbug was querying the BTS by parsing its HTML output. While this worked, it tightly coupled the user-facing presentation of the BTS with critical functionality of the bug reporting tool. The setup was fragile, prone to breakage, and did not allow changing anything in the BTS frontend for fear of breaking reportbug itself.
In 2007, I started to work on reportbug-ng, a user-friendly alternative to reportbug, targeted at users not comfortable using the command line. Early on, I decided to use the BTS’ SOAP interface instead of parsing HTML like reportbug did. 2008, I extracted the code that dealt with the BTS into a separate Python library, and after some collaboration with the reportbug maintainers, reportbug adopted python-debianbts in 2011 and has used it ever since.
2015, I was working on porting python-debianbts to Python 3. During that process, it turned out that its major dependency, SoapPy was pretty much unmaintained for years and blocking the Python3 transition. Thanks to the help of Gaetano Guerriero, who ported python-debianbts to pysimplesoap, the migration was unblocked and could proceed.
In 2024, almost ten years later, pysimplesoap seems to be unmaintained as well, and I have to look again for alternatives. The most promising one right now seems to be zeep. Unfortunately, zeep requires a WSDL file for working with a SOAP service, which debbugs does not provide.
How can you help?reportbug (and thus python-debianbts) is used by thousands of users and I have a certain responsibility to keep things working properly. Since I simply don’t know enough about WSDL to create such a file for debbugs myself, I’m looking for someone who can help me with this task.
If you’re familiar with SOAP, WSDL and optionally debbugs, please get in touch with me. I don’t speak Pearl, so I’m not really able to read debbugs code, but I do know some things about the SOAP requests and replies due to my work on python-debianbts, so I’m sure we can work something out.
There is a WSDL file for a debbugs version used by GNU, but I don’t think it’s official and it currently does not work with zeep. It may be a good starting point, though.
The future of debbugs’ APIWhile we can probably continue to support debbugs’ SOAP interface for a while, I don’t think it’s very sustainable in the long run. A simpler, well documented REST API that returns JSON seems more appropriate nowadays. The queries and replies that debbugs currently supports are simple enough to design a REST API with JSON around it. The benefit would be less complex libraries on the client side and probably easier maintainability on the server side as well. debbugs’ maintainer seemed to be in agreement with this idea back in 2018. I created an attempt to define a new API (HTML render), but somehow we got stuck and no progress has been made since then. I’m still happy to help shaping such an API for debbugs, but I can’t really implement anything in debbugs itself, as it is written in Perl, which I’m not familiar with.
ListenData: 4 Ways to Use ChatGPT API in Python
In this tutorial, we will explain how to use ChatGPT API in Python, along with examples.
Steps to Access ChatGPT APIPlease follow the steps below to access the ChatGPT API.
- Visit the OpenAI Platform and sign up using your Google, Microsoft or Apple account.
- After creating your account, the next step is to generate a secret API key to access the API. The API key looks like this -sk-xxxxxxxxxxxxxxxxxxxx
- If your phone number has not been associated with any other OpenAI account previously, you may get free credits to test the API. Otherwise you have to add atleast 5 dollars into your account and charges will be based on the usage and the type of model you use. Check out the pricing details in the OpenAI website.
- Now you can call the API using the code below.
ListenData: How to Build ChatGPT Clone in Python
In this article, we will see the steps involved in building a chat application and an answering bot in Python using the ChatGPT API and gradio.
Developing a chat application in Python provides more control and flexibility over the ChatGPT website. You can customize and extend the chat application as per your needs. It also help you to integrate with your existing systems and other APIs.
To read this article in full, please click hereThis post appeared first on ListenDataPython Morsels: Multiline comments in Python
Python does not have multiline comments. But you can use alternatives like docstrings, editor shortcuts, and conventional commenting methods, depending on your requirements.
Table of contents
- Does Python have multi-line comments?
- What about triple quotes?
- Docstrings versus comments
- What if I want to comment-out a whole block of code?
- How to comment multiple lines
- Use docstrings, your code editor, or version control
For single-line comments, Python uses the octothorpe character (#), also known as pound, number sign, crunch, and of course, the hashtag character:
# This is a comment this = "is not a comment"But what if you want to comment out a whole block of code?
Unlike some programming languages, Python does not have multi-line comments.
What about triple quotes?You might be thinking, wait, …
Read the full article: https://www.pythonmorsels.com/multiline-comments/Louis-Philippe Véronneau: Montreal's Debian & Stuff - March 2024
Time really flies when you are really busy you have fun! Our Montréal Debian User Group met on Sunday March 31st and I only just found the time to write our report :)
This time around, 9 of us we met at EfficiOS's offices1 to chat, hang out and work on Debian and other stuff!
Here is what we did:
pollo:
- did some clerical work for the DebConf videoteam
- tried to book a plane ticket for DC24
- triaged #1067620 (dependency problem with whipper)
- closed #1067121 (flaky test in supysonic)
- closed #1065514 (qpdfview crossbuilding)
tvaz:
- organized his custom Application Manager stuff in a private repo
- did some coding for the New Maintainers website to make sure applicants agree with the Debian Code of Conduct alongside the SC/DFSG/DMUP
- closed #1057910 (new apticron upload)
tassia:
- planned & brainstormed for the upcoming Debian usability tests
- mentored a student/new contributor (justin)
- babysat a future contributor!
- closed #1067649
- learnt about fabre.debian.net & element.debian.social (thanks, pollo!)
viashimo:
- uploaded puppet-strings 4.1.2-1 to unstable
- updated various services in personal infra
- cleaned vagrant-hostmanager and worked on packaging the new upstream release (1.8.10)
- extended GPG key expiry
- looked at options for a new backup machine
lavamind:
- updated puppetdb to 8.4.1
justin:
PicturesHere are pictures of the event. Well, one picture (thanks Tassia!) of the event itself and another one of the crisp Italian lager I drank at the bar after the event :)
This week in KDE: sprints, enhancements, and kebabs
This week I’m attending two sprints: a KDE e.V. Board sprint which is already done, and a KDE Goals mega-sprint, which begins today! My “Automate and systematize internal processes” goal is represented there and I’m hoping we have a great time brainstorming and fixing stuff. And also that we eat lots of Döner kebabs. So many Döner kebabs. All the Döner kebabs.
New FeaturesSpectacle regains its “blur factor” feature, so now if you want your blurred areas to be even blurrier, you can do that without having to draw a blur over the same area multiple times (Noah Davis, Spectacle 24.05. Link)
You can now copy the text of a column in System Monitor (Joshua Goins, Plasma 6.1. Link)
UI ImprovementsThe Plasma Digital Clock’s Islamic calendar feature now respects the locale-specific numbering system, which means for example that people living in Arabic-speaking countries that use western-style Arabic numerals will now see those rather than eastern-style Arabic numerals (Fushan Wen, Plasma 6.0.5. Link)
Removed the “Clear all” button on the fingerprint authorization enrollment UI, because it was a big obvious footgun you could use to destroy all your work to enroll fingerprints (Arthur Zamarin, Plasma 6.1. Link)
Normally I don’t mention changes to Welcome center, but this is a fairly large one: the “Simple by default” page is no longer a big dumb picture of System Settings, but rather shows you a nice mock desktop where you can hover or click on elements to learn what they are and what they do. System Settings is now mentioned on the “Powerful When Needed” page (me: Nate Graham and Oliver Beard, Plasma 6.1. Link):
On System Settings’ Night Light page, the time input fields for manual time mode are no longer a nightmare, because they’ve been replaced with a set of spinboxes (Natalie Clarius, Plasma 6.1. Link):
Yes, ideally these would use a dedicated time picker UI component, but one thing at a timeInformation about Night Light transition times is now shown in the tooltip for the Brightness and Color widget (Natalie Clarius, Plasma 6.1. Link):
System Settings’ Screen Locking page has also now adopted the “buttons in the header” paradigm, this time for its “Configure Appearance” button (Jakob Petsovits, Plasma 6.1. Link):
Bug FixesFixed a number of issues in various pieces of KDE software caused by changes in Qt 6.7 (Felix Ernst, Noah Davis, and Fushan Wen, Dolphin & Spectacle 24.05 and Plasma 6.0.4. Link 1, link 2, and link 3)
Spectacle no longer badly misbehaves when asked to take a screenshot of a screen with a scale factor of less than 100% (Noah Davis, Spectacle 24.05. Link)
Fixed an issue whereby Spectacle’s feature to save screenshots with an increasing number sequence would number the screenshots incorrectly in certain circumstances (Noah Davis, Spectacle 24.05. Link)
Closing your laptop’s lid with the keyboard backlight illuminated now correctly restores its brightness level when you open the lid again (Anthony Vital, Plasma 6.0.4. Link)
Fixed multiple issues whereby parts of Plasma would fail to save changed settings if Plasma quickly crashed, exited unexpectedly, or was terminated in an unclean way (David Edmundson, Plasma 6.0.5. Link)
Plasma no longer crashes when removing standalone launcher widgets for apps with no “Open With” context menu action (Fushan Wen, Plasma 6.0.5. Link)
Fixed multiple issues with keyboard focus and selection with search results in Plasma’s Application Dashboard widget—which you may notice is visibly on life support, but this constitutes some of that support (Marco Martin, Plasma 6.0.5. Link)
Plasma’s screen chooser OSD once again works as expected on X11 (Fushan Wen and David Redondo, Plasma 6.0.5. Link 1 and link 2)
The Grid layout for System Monitor sensors once again looks good in constrained spaces, such as a thick Plasma panel (Akseli Lahtinen, Plasma 6.0.5. Link)
Fixed a major regression that prevented LUKS-encrypted disks from being decrypted by KDE software using the Solid framework (Kai Uwe Broulik, Frameworks 6.2, but distros should be backporting it to their 6.1 packages too. Link)
Those increasingly ubiquitous contextual help buttons that open explanatory tooltips when clicked no longer have a weird empty space on the right side of their tooltips (Shubham Arora, Frameworks 6.2. Link):
Fixed a Breeze icon that was not changing its color properly when using non-default color schemes (Evgeniy Harchenko, Frameworks 6.2. Link)
Other bug information of note:
- 3 Very high priority Plasma bugs (same as last week). Current list of bugs
- 38 15-minute Plasma bugs (up from 36 last week). Current list of bugs
- 137 KDE bugs of all kinds fixed over the last week Full list of bugs
Kolourpaint has been ported to Qt6 (Carl Schwan, Kolourpaint 24.05. Link)
On Wayland, implemented support for the remote desktop portal’s ConnectToEIS method. This enables applications like Synergy and Barrier that have Wayland support for sending emulated input events to do so in a more convenient way than using the existing methods. Full support for input-leap is pending, but in progress (David Redondo, Plasma 6.1. Link)
System Settings’ Keyboard page has been ported to QML, retaining most of its prior styling but with a modern and extensible codebase (Evgeny Chesnokov, Plasma 6.1. Link)
…And Everything ElseThis blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.
How You Can HelpThe KDE organization has become important in the world, and your time and labor have helped to bring it there! But as we grow, it’s going to be equally important that this stream of labor be made sustainable, which primarily means paying for it. Right now the vast majority of KDE runs on labor not paid for by KDE e.V. (the nonprofit foundation behind KDE, of which I am a board member), and that’s a problem. We’ve taken steps to change this with paid technical contractors—but those steps are small due to growing but still limited financial resources. If you’d like to help change that, consider donating today!
Otherwise, visit https://community.kde.org/Get_Involved to discover other ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!
The Drop Times: DrupalTO Meetup: Glimpses from the Event—Strategies for a Seamless Transition to Drupal 10
Web Review, Week 2024-16
Let’s go for my web review for the week 2024-16.
The invisible seafaring industry that keeps the internet afloatTags: tech, internet, infrastructure
Very fascinating piece. This shows the underappreciated job of maintaining the subsea cables needed for the Internet to function and how extreme the conditions can be. Definitely a peculiar life for the folks in that trade… also shows the repairs are clearly underfunded and that not enough people are embracing this career. And now, add geopolitics to the mix, it should make you wonder how all of this work at all and for how long it’ll keep working.
https://www.theverge.com/c/24070570/internet-cables-undersea-deep-repair-ships
Tags: tech, ssh, security
Interesting study on the brute force attacks against SSH. It gives plenty of insights and leads to a potential approach to detect most of them.
https://www.flux.utah.edu/paper/singh-nsdi24
Tags: tech, email, tools, command-line
Looks like a nice tool to backup and restore emails. Probably to check out next time you migrate your emails to another server.
https://pimalaya.org/neverest/cli/latest/
Tags: tech, c++, memory
Interesting case… even though honestly we shouldn’t need to dig out this kind of details.
https://blomqu.ist/posts/2024/move/
Tags: tech, library, dependencies
Neat little tool. Since I had to do this kind of work a few times, this is indeed a good idea to have a public and maintained script for it.
https://github.com/stolk/sotrace
Tags: tech, dependencies, javascript, tools
Looks like a nice tool to explore dependencies in JS based projects.
https://github.com/pahen/madge
Tags: tech, tests, performance, databases, postgresql
Interesting use of database templates and memory disks to greatly speed up test executions.
https://gajus.com/blog/setting-up-postgre-sql-for-running-integration-tests
Tags: tech, web, 3d, xr
Funny side project. This shows well many of the challenges one should expect when working on mixed reality projects. It’s also nice to see how the ecosystem matured for such features in the browser.
https://www.dompajak.com/blog/webxr-beeb-virtual-beeb/index.html
Tags: tech, 3d, art, physics
Interesting approach to have a ray tracer which doesn’t quite follow physics for artistic purposes.
https://larswander.com/writing/spectral-ray-tracing/
Tags: tech, failure, project-management, product-management
This is definitely an ambiguous term. You need to know where stand the people employing it in order to figure out the exact meaning of “root cause”.
https://github.com/readme/guides/root-cause
Tags: management, coaching, learning, organization
Definitely this. Listen and write down issues before you start to complain. There might be reasons why things are as they are. Take the time to understand them and refine to have a better feedback.
https://www.simplermachines.com/why-you-need-a-wtf-notebook/
Tags: tech, work, life, management, burnout, health
A good reminder that mental health can be hard to keep in check in our profession. Pay attention to how you feel, anxiety is a sneaky foe. Lots can be done to improve if taken care of early enough.
https://vadimkravcenko.com/shorts/mental-health-in-software-engineering/
Tags: sociology, politics, data-visualization
Excellent visualization which shows how adverse experiences during childhood shape our lives as adults.
https://pudding.cool/2024/03/teenagers/
Bye for now!
Golems GABB: Boosting Productivity in Drupal with Composer 2
Composer 2 is an effective solution for increasing productivity when working with Drupal. Everyone knows the situation when simple operations take a lot of time. Using Composer in Drupal makes developers' lives easier.
To speed up workflows, web developers often use the same code many times in many projects. This code can be written not only by other people; that's not the point. Regarding programming, rewriting code is a concern for many developers. Composer allows you to get rid of this problem. You can save parts of PHP code and use them for other projects.
Real Python: Python's unittest: Writing Unit Tests for Your Code
In this quiz, you’ll test your understanding of testing your Python code with the unittest framework.
Testing in Python is a huge topic and can come with a lot of complexity, but it doesn’t need to be hard. You can create simple tests for your application in a few easy steps and then build on them from there.
With this quiz, you can check your understanding of testing with Python’s unittest framework. Good luck!
[ 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 ]
Real Python: The Real Python Podcast – Episode #201: Decoupling Systems to Get Closer to the Data
What are the benefits of using a decoupled data processing system? How do you write reusable queries for a variety of backend data platforms? This week on the show, Phillip Cloud, the lead maintainer of Ibis, will discuss this portable Python dataframe library.
[ 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 ]
LN Webworks: Drupal Configuration Synchronization: A Simplified Guide
When you're adding a new feature, like connecting your contact form to Mailchimp, on your Drupal website, you'll want to make sure it works the same way when you move it from one stage to another. Luckily, Drupal has a handy feature called Configuration Synchronization for this.
This feature helps you easily export and import all the settings and setup between different copies of your Drupal website. In this blog post, we'll take a closer look at how Configuration Synchronization works and some tips for using it effectively. We will also understand the best ways to make sure your Drupal development stays consistent across different environments.