analitics

Pages

Tuesday, September 19, 2023

News : Django 5.0 alpha 1 released.

Django 5.0 alpha 1 is now available. It represents the first stage in the 5.0 release cycle and is an opportunity for you to try out the changes coming in Django 5.0.
Django 5.0 brings a deluge of exciting new features which you can read about in the in-development 5.0 release notes.
Now Django 5.0 supports Python 3.10, 3.11, and 3.12.
At that time, you should be able to run your package’s tests using python -Wd so that deprecation warnings appear.
Django 5.0 introduces the concept of a field group, and field group templates.
Database-computed default values
Database generated model field
More options for declaring field choices
New decorators now support wrapping asynchronous
... a lot of features deprecated in 5.0
You can read more on the official website.

Monday, September 18, 2023

News : Amazon free python audible audiobook.

Although Python programming language comes with many learning resources, you can find a lot of free audiobooks on Amazon.
You can try a free trial then you need to pay $14.95 a month after 30 days - cancel online anytime.

Saturday, September 9, 2023

News : Python 3.12.0 release candidate 2 now available.

This new release comes with many improvements for developers.
Here are some of them.
Modules from the standard library are now potentially suggested as part of the error messages displayed by the interpreter ...
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
  • Many large and small performance improvements like - PEP 709;
  • Support for the Linux perf profiler to report Python function names in traces;
  • New type annotation syntax for generic classes - PEP 695;
  • More flexible f-string parsing, allowing many things previously disallowed - PEP 701;
  • Support for the buffer protocol in Python code - PEP 688;
  • A new debugging/profiling API - PEP 669;
  • Support for isolated sub interpreters with separate Global Interpreter Locks - PEP 684;
All PEPs can be found on this GitHub project.

Saturday, September 2, 2023

Python 3.11.4 : Issues in Fedora with PyGobject and sway-tests

Today I wanted to test this repo named sway-tests.
I followed the steps there and received an error from gi.repository.
This error is related to another issue related to PyGobject.
In Fedora Linux distro, installing PyGobject is done with pip like this:
$ pip install PyGobject
In order to have no errors, the dnf or dnf5 tool should be used like this ...
I tested the functionality of this installation with a simple example:
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
It worked very well.
After solving this issue, I returned to the initial one and tested the sway-tests.
$ whereis sway
$ env/bin/pytest --sway=/usr/bin/sway
$ sudo env/bin/pytest --sway=/usr/bin/sway
I used the command both with and without sudo.
Both generated the same errors.
For the following command I had to install ... xorg-x11-server-Xephyr:
Xephyr is an X server which has been implemented as an ordinary X application. It runs in a window just like other X applications, but it is an X server ...
... the fixed centered black window specific to the xorg runtime appeared and somewhere on the side the terminal showed me a bunch of errors.
... obviously, I don't know how well sway-tests is implemented, now it's an archived repo, but I solved the use of PyGobject in python on the Fedora linux distribution.

Friday, September 1, 2023

Python 3.11.0 : Use python to set your R application on shinyapps.io.

If you use the R programming language and shinyapps.io then you can use Python to set up your application.
I create my folder and I install the rsconnect-python python package.
mkdir rsconnect-python-001
cd rsconnect-python-001
pip install rsconnect-python --user
Collecting rsconnect-python
From the shinyapps webpage, I got my token and my secret for my account and I used this command:
rsconnect add --account catafest --name catafest --token YOUR_TOKEN --secret YOUR_SECRET
Detected the following inputs:
    name: COMMANDLINE
    insecure: DEFAULT
    account: COMMANDLINE
    token: COMMANDLINE
    secret: COMMANDLINE
Checking shinyapps.io credential...              [OK]
Added shinyapps.io credential "catafest".
You can see is set and working.
I used a simple R source code named app.r:
library(shiny)

# Definirea interfeței utilizatorului
ui <- fluidPage(
  titlePanel("Aplicație Shiny Simplă"),
  sidebarLayout(
    sidebarPanel(
      numericInput("num", "Introduceți un număr:", value = 1),
      actionButton("goButton", "Generează")
    ),
    mainPanel(
      textOutput("rezultat")
    )
  )
)

# Definirea serverului
server <- function(input, output) {
  observeEvent(input$goButton, {
    num <- input$num
    output$rezultat <- renderText({
      paste("Numărul introdus este:", num)
    })
  })
}

# Crearea aplicației Shiny
shinyApp(ui, server)
The app.py file has this source code:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

# Creați o aplicație Dash
app = dash.Dash(__name__)

# Definiți aspectul și structura aplicației
app.layout = html.Div([
    html.H1("Aplicație Dash Simplă"),
    dcc.Graph(id='grafic'),
    dcc.Input(id='input-numar', type='number', value=1),
    html.Div(id='rezultat')
])

# Definiți funcția callback pentru actualizarea graficului
@app.callback(
    Output('grafic', 'figure'),
    Input('input-numar', 'value')
)
def actualizare_grafic(numar):
    # Implementați logica de actualizare a graficului aici
    # Exemplu simplu: Un grafic cu o linie dreaptă cu panta egală cu numărul introdus
    import plotly.express as px
    import pandas as pd
    
    data = pd.DataFrame({'x': range(10), 'y': [numar * x for x in range(10)]})
    
    fig = px.line(data, x='x', y='y', title='Graficul personalizat')
    
    return fig

# Rulează aplicația
if __name__ == '__main__':
    app.run_server(debug=True)
I run this command into the RGUI command :
shiny::runApp("C:/PythonProjects/rsconnect-python-001/")

Listening on http://127.0.0.1:7036
The result on browser is this:
I used this command to deploy the application on shinyapps.io:
>rsconnect deploy shiny . --name catafest --title test
[WARNING] 2023-09-01T22:28:10+0300 Can't determine entrypoint; defaulting to 'app'
    Warning: Capturing the environment using 'pip freeze'.
             Consider creating a requirements.txt file instead.
...
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/test/
...
  deploying - Starting instances
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/rsconnect-python-001/
←[32;20m        [OK]
←[0m←[0mSaving deployed information...←[0m←[32;20m      [OK]
←[0m
The result can be found on the shinyapps.io - admin.
I need to fix this error, but first test without app.py was deploy on web.
[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: /srv/connect/venv/bin/python3 -m pip install --upgrade pip
[2023-09-01T22:43:31.378864990+0000] Copying file manifest.json
←[31;20m        [ERROR]: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error: 
Unhandled Exception: 599
←[0mError: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error: 
Unhandled Exception: 599
I will come with better results.