analitics

Pages

Showing posts with label news. Show all posts
Showing posts with label news. Show all posts

Tuesday, June 24, 2025

Python 3.13.5 : Get bookmarks from Edge browser with python.

Today I tested with these python modules json and pathlib.
This python script will get all bookmarks from Edge browser:
import json
from pathlib import Path

bookmark_path = Path.home() / "AppData/Local/Microsoft/Edge/User Data/Default/Bookmarks"

with open(bookmark_path, "r", encoding="utf-8") as f:
    data = json.load(f)

# Exemplu: listăm toate titlurile bookmark-urilor
def extract_bookmarks(bookmark_node):
    bookmarks = []
    if "children" in bookmark_node:
        for child in bookmark_node["children"]:
            bookmarks.extend(extract_bookmarks(child))
    elif bookmark_node.get("type") == "url":
        bookmarks.append((bookmark_node["name"], bookmark_node["url"]))
    return bookmarks

all_bookmarks = extract_bookmarks(data["roots"]["bookmark_bar"])
for name, url in all_bookmarks:
    print(f"{name}: {url}")

Friday, June 20, 2025

Python 3.13.5 : testing with flask, request and playwright python module.

Today some testing with these python modules: flask, request and playwright.
I used pip to install flask python package:
pip install flask
Collecting flask
  Downloading flask-3.1.1-py3-none-any.whl.metadata (3.0 kB)
...
Installing collected packages: markupsafe, itsdangerous, blinker, werkzeug, jinja2, flask
Successfully installed blinker-1.9.0 flask-3.1.1 itsdangerous-2.2.0 jinja2-3.1.6 markupsafe-3.0.2 werkzeug-3.1.3
pip install requests
...
Installing collected packages: urllib3, idna, charset_normalizer, certifi, requests
Successfully installed certifi-2025.6.15 charset_normalizer-3.4.2 idna-3.10 requests-2.32.4 urllib3-2.5.0
pip install playwright
Collecting playwright
...
Installing collected packages: pyee, greenlet, playwright
Successfully installed greenlet-3.2.3 playwright-1.52.0 pyee-13.0.0
...
playwright install
Downloading Chromium 136.0.7103.25 ...
This will download a lot fo files and the will install the playwright tool.
First script is simple one will try to get cloudflare header on default ip:
from flask import Flask, request

app = Flask(__name__)

@app.route("/")
def detecteaza_ipuri():
    ip_client = request.headers.get('CF-Connecting-IP', 'Necunoscut')
    ip_cloudflare = request.remote_addr
    return (
        f"IP real vizitator: {ip_client}
" f"IP Cloudflare (vizibil de server): {ip_cloudflare}" ) if __name__ == "__main__": app.run(debug=True)
The next one will check more ...
from flask import Flask, request
import requests
import ipaddress

app = Flask(__name__)

def este_ip_cloudflare(ip):
    try:
        raspuns = requests.get("https://www.cloudflare.com/ips-v4")
        raspuns.raise_for_status()
        subneturi = raspuns.text.splitlines()

        for subnet in subneturi:
            if ipaddress.ip_address(ip) in ipaddress.ip_network(subnet):
                return True
        return False
    except Exception as e:
        return f"Eroare la verificarea IP-ului Cloudflare: {e}"

@app.route("/")
def detecteaza_ipuri():
    ip_client = request.headers.get('CF-Connecting-IP', 'Necunoscut')
    ip_cloudflare = request.remote_addr
    rezultat = este_ip_cloudflare(ip_cloudflare)

    return (
        f"IP real vizitator: {ip_client}
" f"IP Cloudflare (forwarder): {ip_cloudflare}
" f"Este IP-ul din rețeaua Cloudflare? {'DA' if rezultat == True else 'NU' if rezultat == False else rezultat}" ) if __name__ == "__main__": app.run(host="0.0.0.0", port=5000)
Now, the script with the request python module:
import requests

url = "https://cobalt.tools"
headers = {
    "User-Agent": "Mozilla/5.0",  # Simulează un browser real
}

try:
    r = requests.get(url, headers=headers, timeout=10)
    content = r.text.lower()

    print(f"Cod răspuns HTTP: {r.status_code}")

    if "cloudflare" in content or "cf-ray" in content or "attention required" in content:
        print("Cloudflare a intermediat cererea sau a blocat-o cu o pagină specială.")
    else:
        print("Cererea a fost servită normal.")
except Exception as e:
    print(f"Eroare la conexiune: {e}")
The last one will use the playwright python module:
import sys
import re
from urllib.parse import urlparse
from pathlib import Path
from playwright.sync_api import sync_playwright

def converteste_url_in_nume_fisier(url):
    parsed = urlparse(url)
    host = parsed.netloc.replace('.', '_')
    path = parsed.path.strip('/').replace('/', '_')
    if not path:
        path = 'index'
    return f"{host}_{path}.txt"

if len(sys.argv) != 2:
    print("Utilizare: python script.py https://exemplu.com")
    sys.exit(1)

url = sys.argv[1]
fisier_output = converteste_url_in_nume_fisier(url)

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    pagina = browser.new_page()
    pagina.goto(url, wait_until='networkidle')
    continut = pagina.content()
    Path(fisier_output).write_text(continut, encoding='utf-8')
    browser.close()

print(f"Conținutul a fost salvat în: {fisier_output}")
This will create a file with the source code of web page.

Thursday, June 19, 2025

News : UV - fast Python package and project manager.

An extremely fast Python package and project manager, written in Rust.
cd uv_projects

uv_projects>uv init hello-world
Initialized project `hello-world` at `D:\PythonProjects\uv_projects\hello-world`

uv_projects>cd hello-world

uv_projects\hello-world>uv run main.py
Using CPython 3.13.5 interpreter at: C:\Python3135\python.exe
Creating virtual environment at: .venv
Hello from hello-world!

Saturday, June 14, 2025

Python 3.11.11 : Colab simple tests with Protocol Buffers - part 053.

The .proto file definition serves as a blueprint or schema for defining the structure of your data in Protocol Buffers. It plays a crucial role in ensuring data consistency and enabling efficient serialization and deserialization across different programming languages and systems.
You can find all steps on my colab_google - the GitHub repo.

Sunday, June 8, 2025

News : Python-Fiddle online tool.

Python-Fiddle is an online Python playground where you can write, run, and share Python code directly from the browser without any need to install and maintain Python and packages on your computer. This platform was created make Python programming accessible to everyone and everywhere. We hope to make this a useful tool for learning, teaching, sharing, and collaborating on Python projects.
You can find this online tool on the official website.

Sunday, May 18, 2025

Python 3.13.0 : bad management of python versions - need to fix into environment ...

I don't like how python management comes now, because some data god to \AppData\ and custom folder ... this will block some EXE because is not into environment ...
Will be more easy if the python team will make a management of all python on operating system area ... one reason is virtual environement , but this one python version of running ...
Can be better ? The management of python versions can be improved with simple user interface selection to manage all python versions and python modules, maybe a separate command shell more good thar python command on command shell, maybe a simple artificial intelligence just for user intercations and management of working ...
See this example , when I need to change to a lower version of python just to test some old python modules ...
Installing collected packages: tqdm, tifffile, scipy, rpds-py, platformdirs, opencv-python-headless, networkx, llvmlite, lazy-loader, imageio, attrs, scikit-image, referencing, pooch, numba, pymatting, jsonschema-specifications, jsonschema, rembg
   ----------------------------------------  0/19 [tqdm]  WARNING: The script tqdm.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   -- -------------------------------------  1/19 [tifffile]  WARNING: The scripts lsm2bin.exe, tiff2fsspec.exe, tiffcomment.exe and tifffile.exe are installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts imageio_download_bin.exe and imageio_remove_bin.exe are installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. ----------
   ----------------------------------- ---- 17/19 [jsonschema]  WARNING: The script jsonschema.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ----------------------------------- ---- 17/19 [jsonschema]  WARNING: The script rembg.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed attrs-25.3.0 imageio-2.37.0 jsonschema-4.23.0 jsonschema-specifications-2025.4.1 lazy-loader-0.4 llvmlite-0.44.0 networkx-3.4.2 numba-0.61.2 opencv-python-headless-4.11.0.86 platformdirs-4.3.8 pooch-1.8.2 pymatting-1.1.14 referencing-0.36.2 rembg-2.0.66 rpds-py-0.25.0 scikit-image-0.25.2 scipy-1.15.3 tifffile-2025.5.10 tqdm-4.67.1

D:\PythonProjects\PyQt6\catafest_images_viewer>python main_001_removebk.py
Traceback (most recent call last):
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\main_001_removebk.py", line 4, in 
    from image_viewer import ImageViewer
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\image_viewer.py", line 7, in 
    from qt_setup import Image, ContextMenu, ProcessDialog, ProcessingManager, ImageProcessor
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\qt_setup.py", line 5, in 
    from processing import ProcessDialog, ProcessingManager, ImageProcessor
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\processing.py", line 7, in 
    from rembg import remove
  File "C:\Users\nicol\AppData\Roaming\Python\Python313\site-packages\rembg\__init__.py", line 5, in 
    from .bg import remove
  File "C:\Users\nicol\AppData\Roaming\Python\Python313\site-packages\rembg\bg.py", line 7, in 
    import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'

Friday, April 25, 2025

Python 3.13.0rc1 : using gTTS version 2.5.4 python package.

gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate text-to-speech API
pip install gTTS
Collecting gTTS
  Downloading gTTS-2.5.4-py3-none-any.whl.metadata (4.1 kB)
...
Installing collected packages: gTTS
Successfully installed gTTS-2.5.4
simple python script with one example : create an audio file in romanian language.
from gtts import gTTS
tts = gTTS('Azi este 25 aprilie 2025', lang='ro', tld='ro')
tts.save('azi25.mp3')

Tuesday, April 22, 2025

News : Pydantic Releases Sandboxed Python Execution Server.

Pydantic officially announced its broader support for the MCP within the PydanticAI framework around March 20, and now the new tool leverages the Model Context Protocol (MCP), an open standard initiated by Anthropic.
The server achieves isolation by executing code using Pyodide, a Python runtime compiled to WebAssembly.
give AI agents the ability to perform Python-based tasks safely
You can find the Pydantic’s documentation for the tool, available at ai.pydantic.dev .
The Model Context Protocol itself try to solve difficulties in connecting AI models to the diverse external tools and data sources they often need.

Saturday, April 5, 2025

Saturday, March 15, 2025

Python 3.13.0rc1 : strange crash of Python running ...

... my windows 10 crash the python running ... this is the output of crash:

Saturday, February 22, 2025

News : Python and Grok 3 Beta — The Age of Reasoning Agents

On the official website of x.ai you can find this:
We are thrilled to unveil an early preview of Grok 3, our most advanced model yet, blending superior reasoning with extensive pretraining knowledge.
You can find a simle and good example with python and pygame how this can be used.
The Grok 3 artificial inteligence is used for :
Research
Brainstorm
Analyze Data
Create images
Code
For me, the artificial intelligence help me to be more fast into coding versus issues and bugs, game design, parse and change data.
I don't test this Grok 3, but I can tell you some artificial inteligence into develop area are bad even they say is dedicated to this issue.

Sunday, December 29, 2024

Python 3.13.0 : Only the unstructured library in Fedora 41 ...

The unstructured library provides open-source components for ingesting and pre-processing images and text documents, such as PDFs, HTML, Word docs, and many more. The use cases of unstructured revolve around streamlining and optimizing the data processing workflow for LLMs. unstructured modular functions and connectors form a cohesive system that simplifies data ingestion and pre-processing, making it adaptable to different platforms and efficient in transforming unstructured data into structured outputs.
I used pip tool to install this python package:
mythcat@fedora:~$ pip install unstructured
Defaulting to user installation because normal site-packages is not writeable
Collecting unstructured
  Downloading unstructured-0.11.8-py3-none-any.whl.metadata (26 kB)
...
Successfully installed aiofiles-24.1.0 annotated-types-0.7.0 anyio-4.7.0 backoff-2.2.1 beautifulsoup4-4.12.3 chardet-5.2.0 click-8.1.8 cryptography-44.0.0 dataclasses-json-0.6.7 emoji-2.14.0 eval-type-backport-0.2.2 filetype-1.2.0 h11-0.14.0 httpcore-1.0.7 httpx-0.28.1 jsonpath-python-1.0.6 langdetect-1.0.9 marshmallow-3.23.2 mypy-extensions-1.0.0 nest-asyncio-1.6.0 nltk-3.9.1 pydantic-2.9.2 pydantic-core-2.23.4 pypdf-5.1.0 python-iso639-2024.10.22 python-magic-0.4.27 rapidfuzz-3.11.0 requests-toolbelt-1.0.0 sniffio-1.3.1 soupsieve-2.6 tabulate-0.9.0 tqdm-4.67.1 typing-extensions-4.12.2 typing-inspect-0.9.0 unstructured-0.11.8 unstructured-client-0.28.1 wrapt-1.17.0
But I got error on the unstructured-inference:
pip install unstructured-inference
Collecting unstructured-inference
...
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for onnx
Failed to build onnx
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (onnx)
... and errors on unstructured[pdf]:
mythcat@fedora:~$ pip install unstructured[pdf]
...
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for onnx
Failed to build onnx
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (onnx)

News : My GAME ENGINE is FINALLY DONE! (9 Years in the Making) - build with python.

... this is the cave engine project manager and if you don't know cave cave is a 3D easy to use ... python game engine for you to make games for computer Windows or Linux ... from GuilhermeTeres !

Saturday, September 7, 2024

News : Python and the Intel's NPU Acceleration Library.

You can find the Intel's NPU Acceleration Library on this GitHub repo with Python code samples.

News : Python in Visual Studio Code – September 2024 Release

We’re excited to announce the September 2024 release of the Python and Jupyter extensions for Visual Studio Code!
This release includes the following announcements:
Django unit test support
Go to definition from inlay hints with Pylance
If you’re interested, you can check the full list of improvements in our changelogs for the Python, Jupyter and Pylance extensions.
Read more on the offcial website.

Thursday, August 29, 2024

News : ... august 2024

... news for Python users and developers.
Python 3.12.5 released, see the official webpage.
... new Python 3.13.0 release candidate 1 released, you can read on this webpage.
the last one: Announcing Python Software Foundation Fellow Members for Q1 2024! from this webpage.
About the releases, I can say that all kinds of improvements are coming, I liked that they made the shell more interactive.

Sunday, April 28, 2024

News : New Django Builder online tool.

Django builder is free to use, and a personal project worked on in my spare time.
Any donations are very much appreciated.
If you want to, feel free to donate using the BitCoin address or PayPal link below.
Here is a new online tool that allows you to create projects with the Django framework and manage them more easily. It comes with different versions of Django, you can include channels and HTMX.
I don't see a command line to manage the project...

Friday, April 19, 2024

Python 3.10.12 : Colab quantum circuits with qiskit - part 046.

I've added another introductory example to my GitHub repository with Google Colab notebooks on how to use quantum circuits with the Python package called qiskit and the IBM Quantum Platform.
I used the IBM Quantum Platform and it provides an A.P.I symbol so that it can be used with the source code.
You can find this notebook at this catafest_061.ipynb repo file.

Thursday, April 4, 2024

News : SciPy 1.13.0 new release.

SciPy 1.13.0 is the culmination of 3 months of hard work. This out-of-band release aims to support NumPy 2.0.0, and is backwards compatible to NumPy 1.22.4. The version of OpenBLAS used to build the PyPI wheels has been increased to 0.3.26.dev.
This release requires Python 3.9+ and NumPy 1.22.4 or greater.
For running on PyPy, PyPy3 6.0+ is required.
This release can be found on the official GitHub repo.
python -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python312\lib\site-packages (24.0)
...
python -m pip install --upgrade matplotlib
Collecting matplotlib
  Downloading matplotlib-3.8.4-cp312-cp312-win_amd64.whl.metadata (5.9 kB)
...
Successfully installed contourpy-1.2.1 cycler-0.12.1 fonttools-4.50.0 kiwisolver-1.4.5 matplotlib-3.8.4
...
python -m pip install --upgrade scipy
Collecting scipy
  Downloading scipy-1.13.0-cp312-cp312-win_amd64.whl.metadata (60 kB)
...
Successfully installed scipy-1.13.0
I tested the interpolate.Akima1DInterpolator changes with the default python script and works well:
import numpy as np
from scipy.interpolate import Akima1DInterpolator

import matplotlib.pyplot as plt
fig, ax = plt.subplots()

x = np.linspace(1, 7, 7)
y = np.array([-1, -1, -1, 0, 1, 1, 1])
xs = np.linspace(min(x), max(x), num=100)
y_akima = Akima1DInterpolator(x, y, method="akima")(xs)
y_makima = Akima1DInterpolator(x, y, method="makima")(xs)


ax.plot(x, y, "o", label="data")
ax.plot(xs, y_akima, label="akima")
ax.plot(xs, y_makima, label="makima")

ax.set_title('Fruit supply by kind and color')
ax.legend(title='Fruit color')

plt.show()
about Akima piecewise cubic Hermite interpolation.
Akima interpolator Fit piecewise cubic polynomials, given vectors x and y. The interpolation method by Akima uses a continuously differentiable sub-spline built from piecewise cubic polynomials. The resultant curve passes through the given data points and will appear smooth and natural.
The result of this source code is this:

Sunday, March 31, 2024

Python 3.12.1 : About multiprocessing performance.

Today I test a simple python script for Pool and ThreadPool python classes from multiprocessing python module.
The main goal was to test Python’s multiprocessing performance with my computer.
NumPy releases the GIL for many of its operations, which means you can use multiple CPU cores even with threads.
Processing large amounts of data with Pandas can be difficult, and with Polars dataframe library is a potential solution.
Sciagraph gives you both performance profiling and peak memory profiling information.
Let's teste only these class:
The multiprocessing.pool.Pool class provides a process pool in Python.
The multiprocessing.pool.ThreadPool class in Python provides a pool of reusable threads for executing spontaneous tasks.
This is the python script:
from time import time
import multiprocessing as mp
from multiprocessing.pool import ThreadPool
import numpy as np
import pickle

def main():
    arr = np.ones((1024, 1024, 1024), dtype=np.uint8)
    expected_sum = np.sum(arr)

    with ThreadPool(1) as threadpool:
        start = time()
        assert (
            threadpool.apply(np.sum, (arr,)) == expected_sum
        )
        print("Thread pool:", time() - start)

    with mp.get_context("spawn").Pool(1) as process_pool:
        start = time()
        assert (
            process_pool.apply(np.sum, (arr,))
            == expected_sum
        )
        print("Process pool:", time() - start)

if __name__ == "__main__":
    main()
This is the result:
python thread_process_pool_001.py
Thread pool: 1.6689703464508057
Process pool: 11.644825458526611