pymultilame
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
pymultilame [2018/08/27 06:35] – [Les sources sur github] serge | pymultilame [2021/08/21 15:47] – ↷ Liens modifiés en raison d'un déplacement. 216.244.66.228 | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
</ | </ | ||
- | =====Principe===== | + | =====Les sources sur GitHub===== |
+ | * **[[https:// | ||
- | =====Les sources sur github===== | + | ===== pymultilame |
- | * https:// | + | ==== Des scripts python pour les tâches répétitives. |
- | =====Installation===== | + | |
- | =====Utilisation===== | + | Ce module propose les outils les plus courrant que j' |
- | =====Aide===== | + | Ce module est une amélioration de |
- | Obtenu | + | |
+ | * [[https:// | ||
+ | |||
+ | qui n'est plus maintenu. | ||
+ | |||
+ | === Rubriques proposées | ||
+ | |||
+ | * Blender: Des scripts spécifiques pour le Blender Game Engine 2.7x et qui ne peuvent tourner que dans Blender | ||
+ | * Twisted: des exemples de twisted en python3 | ||
+ | * Network: des sockets simples en python3 | ||
+ | * Tools: des outils utilisés fréquement | ||
+ | |||
+ | ==== Installation | ||
+ | |||
+ | === Installation de Twisted pour python 3.x === | ||
+ | |||
+ | * [[archives: | ||
+ | |||
+ | < | ||
+ | sudo pip3 install twisted | ||
+ | </ | ||
+ | |||
+ | === Installation de pymultilame === | ||
+ | |||
+ | * [[creer_son_propre_package_python|Python: | ||
+ | |||
+ | < | ||
+ | sudo pip3 install -e git+https:// | ||
+ | </ | ||
+ | |||
+ | Mise à jour: | ||
+ | |||
+ | < | ||
+ | sudo pip3 install --upgrade git+https:// | ||
+ | </ | ||
+ | |||
+ | ==== Utilisation ==== | ||
+ | |||
+ | <code python> | ||
+ | # Imports en python3 | ||
+ | from pymultilame import HttpDownload | ||
+ | from pymultilame import MyTools | ||
+ | from pymultilame import TcpClient3 | ||
+ | from pymultilame import MyConfig | ||
+ | from pymultilame import get_my_ip | ||
+ | from pymultilame import Multicast | ||
+ | from pymultilame import UdpClient | ||
+ | from pymultilame import PileFIFO | ||
+ | from pymultilame import Multicast | ||
+ | |||
+ | from pymultilame import Tempo | ||
+ | from pymultilame import EasyAudio | ||
+ | from pymultilame import TextureChange | ||
+ | |||
+ | from pymultilame import scene_change, | ||
+ | from pymultilame import get_all_objects, | ||
+ | |||
+ | |||
+ | # Imports en python2 | ||
+ | |||
+ | from pymultilame.myconfig2 import MyConfig2 | ||
+ | from pymultilame.tcpclient2 import TcpClient2 | ||
+ | </ | ||
+ | |||
+ | ==== Licence ==== | ||
+ | |||
+ | Touls les scripts sont sous | ||
+ | |||
+ | GNU GENERAL PUBLIC LICENSE Version 3 | ||
+ | |||
+ | voir le fichier LICENSE | ||
+ | |||
+ | =====Documentation génèrée | ||
+ | Le script qui génère cette doc est dans le module pymultilame. | ||
+ | ====blendergetobject==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | get_all_objects() | ||
+ | Trouve tous les objets des scènes actives | ||
+ | Retourne un dict {nom de l' | ||
+ | |||
+ | get_all_scenes() | ||
+ | Récupération des scènes | ||
+ | |||
+ | get_scene_with_name(scn) | ||
+ | Récupération de la scène avec le nom | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blendersound==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Classe générique qui permet de gérer facilement le son | ||
+ | dans le Blender Game Engine BGE. | ||
+ | |||
+ | gl est le GameLogic, get with : from bge import logic as gl | ||
+ | |||
+ | Appel de cette classe où tous les sons sont dans une liste avec : | ||
+ | import aud | ||
+ | |||
+ | soundList = [" | ||
+ | |||
+ | Création de l' | ||
+ | |||
+ | gl.sound = EasyAudio(soundList) | ||
+ | soit { " | ||
+ | Joue le son boum | ||
+ | gl.sound[" | ||
+ | Stop le son | ||
+ | gl.sound[" | ||
+ | Idem repeat, pause | ||
- | <file text docstring.txt> | ||
- | ====blendertools==== | ||
CLASSES | CLASSES | ||
- | builtins.object | + | Factory |
- | VirtualGl | + | |
| | ||
- | class VirtualGl(builtins.object) | + | class EasyAudio(builtins.dict) |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | |||
+ | class Factory(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====blendertempo==== | ||
+ | <code txt> | ||
+ | CLASSES | ||
+ | TempoFactory | ||
+ | | ||
+ | class Tempo(builtins.dict) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | class TempoFactory(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | FUNCTIONS | ||
+ | test() | ||
+ | Tourne en dehors de Blender. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blendertexture==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Class générique qui permet de changer la texture d'un objet. | ||
+ | Ce script ne peut tourner que dans blender. | ||
+ | |||
+ | CLASSES | ||
+ | class TextureChange(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blendertools==== | ||
+ | <code txt> | ||
FUNCTIONS | FUNCTIONS | ||
droiteAffine(x1, | droiteAffine(x1, | ||
Ligne 55: | Ligne 286: | ||
Scene must be str: if scene = scene python object, name is scene.name | Scene must be str: if scene = scene python object, name is scene.name | ||
- | DATA | + | </code> |
- | gl = <blendertools.VirtualGl object> | + | |
- | + | ||
- | FILE | + | |
- | / | + | |
+ | ====blenderviewport==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | disable_viewport(cam) | ||
+ | Disable | ||
+ | | ||
+ | enable_full_viewport(cam) | ||
+ | cam is blender object | ||
+ | | ||
+ | enable_half_viewport(cam1, | ||
+ | cam1 and 2 are blender objects | ||
+ | | ||
+ | enable_quad_viewport(cam1, | ||
+ | cam1 2 3 4 are blender objects | ||
+ | | ||
+ | enable_stereo_viewport(cam1, | ||
+ | cam1 and 2 are blender objects | ||
+ | </ | ||
====fifolist==== | ====fifolist==== | ||
+ | <code txt> | ||
CLASSES | CLASSES | ||
- | builtins.object | ||
- | PileFIFO | ||
- | | ||
class PileFIFO(builtins.object) | class PileFIFO(builtins.object) | ||
- | | + | |
+ | | ||
| | ||
| | ||
Ligne 85: | Ligne 329: | ||
| | ||
| | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====getmyip==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | get_my_ip() | ||
+ | Retourne l' | ||
+ | Valable pour python 3.x | ||
+ | Non valable sur android | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====httpdownload==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Télécharge une url. | ||
+ | Peut aussi l' | ||
+ | |||
+ | CLASSES | ||
+ | class HttpDownload(builtins.object) | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | FILE | + | FUNCTIONS |
- | | + | |
+ | Mode ' | ||
+ | Mode ' | ||
+ | donc enregistre un fichier | ||
+ | w ecrase | ||
+ | a ajoute | ||
+ | </ | ||
+ | ====multicast==== | ||
+ | <code txt> | ||
+ | CLASSES | ||
+ | class Multicast(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====myconfig==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Le fichier ini doit être défini avec son chemin absolu | ||
+ | | ||
+ | Pour un projet python: | ||
+ | import os | ||
+ | dossier = os.path.dirname(os.path.abspath(__file__)) | ||
+ | ou | ||
+ | os.getcwd() | ||
+ | | ||
+ | Pour un projet Blender, le chemin complet est trouvé avec: | ||
+ | bge.logic.expandPath() | ||
+ | |||
+ | CLASSES | ||
+ | class MyConfig(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====myconfig2==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Le fichier ini doit être défini avec son chemin absolu | ||
+ | | ||
+ | Pour un projet python: | ||
+ | import os | ||
+ | dossier = os.path.dirname(os.path.abspath(__file__)) | ||
+ | ou | ||
+ | os.getcwd() | ||
+ | | ||
+ | Pour un projet Blender, le chemin complet est trouvé avec: | ||
+ | bge.logic.expandPath() | ||
+ | |||
+ | CLASSES | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
====mytools==== | ====mytools==== | ||
+ | <code txt> | ||
DESCRIPTION | DESCRIPTION | ||
Des méthodes souvent appelées par les autres scripts, | Des méthodes souvent appelées par les autres scripts, | ||
Ligne 106: | Ligne 494: | ||
CLASSES | CLASSES | ||
- | builtins.object | ||
- | MyTools | ||
- | | ||
class MyTools(builtins.object) | class MyTools(builtins.object) | ||
| | ||
Ligne 129: | Ligne 514: | ||
| | ||
| | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 143: | Ligne 532: | ||
| | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | DATA | + | </code> |
- | __all__ = [' | + | |
- | + | ||
- | FILE | + | |
- | | + | |
- | + | ||
- | + | ||
- | + | ||
- | ====http_download==== | + | |
- | DESCRIPTION | + | |
- | Télécharge une url. | + | |
- | Peut aussi l' | + | |
+ | ====tcpclient2==== | ||
+ | <code txt> | ||
CLASSES | CLASSES | ||
- | builtins.object | + | |
- | HttpDownload | + | |
- | + | ||
- | class HttpDownload(builtins.object) | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
+ | | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
+ | | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | FUNCTIONS | + | </ |
- | save_data_in_file(data, | + | |
- | Mode ' | + | |
- | Mode ' | + | |
- | donc enregistre un fichier | + | |
- | w ecrase | + | |
- | a ajoute | + | |
- | DATA | + | ====tcpclient3==== |
- | __all__ | + | <code txt> |
- | + | ||
- | FILE | + | |
- | / | + | |
- | + | ||
- | + | ||
- | + | ||
- | ====tcpclient==== | + | |
CLASSES | CLASSES | ||
- | | + | class TcpClient3(builtins.object) |
- | TcpClient | + | |
- | + | ||
- | | + | |
| | ||
| | ||
Ligne 250: | Ligne 591: | ||
| | ||
| | ||
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 255: | Ligne 598: | ||
| | ||
| | ||
- | | ||
| | ||
| | ||
| | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 268: | Ligne 612: | ||
| | ||
| | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====udpclient==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Recréer un socket avant chaque envoi ou réception, résoud les problèmes | ||
+ | de réseau, ça se reconnecte tout seul. | ||
+ | Par contre, le port éphémère du recvfrom changera à chaque fois. | ||
+ | |||
+ | CLASSES | ||
+ | class UdpClient(builtins.object) | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
- | FUNCTIONS | ||
- | sleep(...) | ||
- | sleep(seconds) | ||
- | | ||
- | Delay execution for a given number of seconds. | ||
- | a floating point number for subsecond precision. | ||
- | FILE | + | {{tag> |
- | / | + | |
- | </ | + | |
- | + | ||
- | {{tag> | + |