No project description provided
Project description
PyComuneFirenze
Utility di uso interno al Comune di Firenze per semplificare e aggregare ad uso comune diverse operazioni, come:
- logging
- creare e cancellare cartelle di lavoro
- inserire dati su database
- mandare email
Installazione
È altamente consigliato installare i proprio pacchetti/librerie tramite virtual environment:
python -m venv *nome_del_virtual_environment*
cd *nome_del_virtual_environment*/Scripts/activate
pip install pycomunefirenze
Breve guida all'uso
Importazione del modulo
from pycomunefirenze import cdf
Per utilizzare le funzioni di logging integrate, inizializzare un logger generale, per esempio:
import logging
logging.basicConfig(filename='file.log',
filemode='a',
level=logging.INFO,
format='%(asctime)s - CHANGEME - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
E poi utilizzare il metodo logging normalmente
logging.info("log messages go here")
Interrogazione di API
response_text = general_request('metodo', 'url', **kwargs)
Per eventuali argomenti extra si riferimento alla documentazione di requests.
Creazione directory di lavoro
wd = cdf.create_directory('directory_a')
Cancellazione di directory di lavoro
cdf.delete_directory(wd)
Inserimento di righe su db
cdf.insert_on_db(
'user'
'password'
'example.intranet'
'5432',
'database',
'table_name',
{
'col1': 'data',
'col2': 42
},
truncate = False)
È possibile passare come parametro truncate per far sì che la tabella venga prima svuotata e poi popolata. Il default è False.
Mandare email
cdf.send_email(
'oggetto',
'mittente',
[
'destinatario1@example.org',
'destinatario2@example.org'
],
'testo della mail',
**kwargs
)
Per eventuali argomenti extra come cc, bcc etc..., si fa riferimento alla documentazione di RedMail.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycomunefirenze-0.6.2.tar.gz.
File metadata
- Download URL: pycomunefirenze-0.6.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de92af7222cf8a7415a374d9ca743574e2ae4099d0b5a77b35b7da16ee03d0a1
|
|
| MD5 |
2ceab51bc72f6c1c5da3659e63ddf08d
|
|
| BLAKE2b-256 |
e6830f03d480cf355915be592c8639db5d36578fdec78f0706e101c1ae6359c7
|
File details
Details for the file pycomunefirenze-0.6.2-py3-none-any.whl.
File metadata
- Download URL: pycomunefirenze-0.6.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f59fc39003c6fe1fb5bc27749607143e210023d30603f6cd809fd22c2d9c9b77
|
|
| MD5 |
67f9af609668f33d965a46794e5f9f26
|
|
| BLAKE2b-256 |
d2bb4ea7ef8f9a3a3f0f084083db25f145bc3de26ffbbf91191baecfaef88ba5
|