Services Blog Français

cli2 v4

| by jpic | cli cli2 devops dev

cli2 v4 is out!

Well, cli2 started as a minuscule thing, basically it was supposed to be just a CLI

But, since 2018, it became my personnal automation framework to crush any DevOps gig on my way by automating absolutely everything in record efforts.

It ended up including all the following batteries:

  • beautiful CLI alternative to click, but much less verbose, allowing more creative design patterns without any boilerplate thanks to introspection
  • which comes with a Sphinx extension to extensively document your CLIs
  • magic 12-factor configuration library
  • extremely beautiful structlog configuration for colorful and readable logging
  • httpx client wrapper that handles all kind of retries, data masking…
  • magic ORM for HTTP resources based on that client
  • Ansible Action plugin library with all the beautiful logging and a rich testing library so that you can go straight to the point in pytest
  • a good old fcntl based locking
  • a command line to run any python function over a beautiful CLI

And … that’s probably why v3.3.46 became a disgusting mess! Fear not, v4 is out and super easy!

Read More

Git-Fu

| by jpic | git devops dev

Git-fu

This tutorial aims to teach Git basics to work in a team.

In this tutorial, you are going to have 3 roles:

  • the git server,
  • Alice, a developer
  • Bob, another developer.

Git central

First, create what will serve as central git server for this tutorial:

git init --bare git-central

This will output something about master branch being non-inclusive, you can discard this message.

But it will specifically output:

Initialized empty Git repository in ~/git-central/

Alice and Bob will pull and push sources to ~/git-central/ just like if it was a gitlab server, because it’s a “bare” repository.

Read More

container-fu

| by jpic | linux devops docker

Humans have used containers for at least 100,000 years, and possibly for millions of years. The first containers were probably invented for storing food, allowing early humans to preserve more of their food for a longer time, to carry it more easily, and to protect it from other animals. The development of food storage containers was “of immense importance to the evolving human populations”, and “was a totally innovative behavior” not seen in other primates.

Read More

pytest superfixture design pattern

| by jpic | python pytest

pytest is an awsome Python Test framework which starts over from a clean slate instead of following the xUnit pattern.

Instead of:

class YourTestSuite(unittest.TestCase):
    def setUp(self):
        self.some_stuff = YourThing()

    def test_delete(self):
        self.some_stuff.delete()
        self.assertFalse(self.some_stuff.exists())

We do:

@pytest.fixture
def some_stuff():
    return YourThing()


def test_delete(some_stuff):
    some_stuff.delete()
    assert not some_stuff.exists()

A couple of advantages are worth noting:

  • the fixture is not created in every test
  • we also win one indentation level which is pretty cool!

However, what about complex code where we test the glue between over a dozen of fixtures?

Read More

Ryzom: Replacing templates with Python Components

| by jpic | python django ryzom

Why?

Because while frameworks like Django claim that “templates include a restricted language to avoid for the HTML coder to shoot themself in the foot”, the GoF on the other hand states that Decorator is the pattern that is most efficient for designing GUIs, which is actually a big part of the success encountered by frameworks such as React.

What?

Ryzom basically offers Python Components, with extra sauce of bleeding edge features such as “compiling Python code to JS”, and “data binding” which is “DOM refreshes itself when data changes in the DB” if you enable websockets. Currently support Django, but Starlette is also planned in the near future.

Read More

Shlax Container Image Builder: Preview

| by jpic | devops docker docker-compose ansible podman buildah

In a world where Dockerfiles, docker-compose.yml files, ansible files, and others compete for my attention against tech debt in projects that become a bit complex: I decided to make a Python micro framework to make it as nice to build an infra as I think it is to build a CRUD with Django.

Shlax is meant to be a multi purpose automation framework, where logic to acheive a certain state can be easily shared accross container building, host provisioning, infrastructures with virtual systems and networks. Most of it is not production ready yet, but the container building part seems to get me the best I can get:

Read More

Django + Snowpack How To = djsnowpack

| by jpic | django webpack snowpack javascript python html css sass

Snowpack is the fastest and easiest way ever to benefit from npm and imports in frontend code without going full SPA.

What this does

MUCH faster frontend development !

Elected Productivity Booster OS Award 2020, Snowpack is a frontend builder with a startup time of 50ms, which typically can be 30s in a typical Webpack project.

Change your CSS or JS and your Django page will reload !

Changing a frontend file will typically not cause a Django view reload because Django doesn’t want to provide JS by default: djsnowpack provides a solution for that.

Read More

django-autocomplete-light 3.8.0 release

| by jpic | django-autocomplete-light python django

WARNING 3.8.0 did not contain the proper built JS, please use 3.8.1 that was just released.

Django-autocomplete-light 3.8.0 was released, and features all your contributions of the year, and tested with a pre-release for the last 3 months or so.

It promises to fix all your JS loading issues, but comes at the price of a small backward compatibility breaks affecting users with custom init functions. If unsure: you probably don’t have any and the upgrade should just work for you.

As you will see, this is a pretty big release, we’ll also briefly talk about the future of django-autocomplete-light in this post.

Read More

Why CRUDLFA+

| by jpic | python django crud iommi crudlfap best-practice framework

This post describes how I feel Django could be even more awesome to use out of the box !

1. Non admins ?

The problem is pretty obvious: Django admin provides barely anything that’s usable for non-admin, not even working base templates and sane default features such as searchable lists with some kind of row level security.

2. No templates ?

For your internet users, Django only generates basic HTML forms without even a default template that calls {{ form }} and {{ form.media }} and {% csrf_token %}.

Read More
1 of 32 Next Page

They trust us

Contact

logo