17.12.2012 Views

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

228<br />

La bibliothèque standard<br />

TROISIÈME PARTIE<br />

[tziade@Tarek ~]$ ls la/<br />

route/<br />

[tziade@Tarek ~]$ ls la/route<br />

est/<br />

[tziade@Tarek ~]$ ls la/route/est<br />

courte/longue/<br />

pathconf(chemin, nom) -> entier<br />

Renvoie les informations de configuration système pour le chemin chemin.<br />

nom définit le type d’informations à récupérer. C’est une chaîne de caractères ou un<br />

entier récupéré respectivement dans la liste des clés et des valeurs du dictionnaire<br />

os.pathconf_names. La liste fournie n’est pas exhaustive et il est possible sur certains<br />

systèmes d’utiliser d’autres valeurs avec pathconf.<br />

De plus, si le système ne connaît pas une des constantes fournies dans le dictionnaire,<br />

une erreur sera levée au moment de son utilisation (pathconf n’est pas disponible<br />

sous MS-Windows).<br />

Récupération d’informations de configuration<br />

>>> import os<br />

>>> os.pathconf_names<br />

{'PC_MAX_INPUT': 2, 'PC_VDISABLE': 8, 'PC_SYNC_IO': 9, 'PC_SOCK_MAXBUF':<br />

12, 'PC_NAME_MAX': 3, 'PC_MAX_CANON': 1, 'PC_PRIO_IO': 11,<br />

'PC_CHOWN_RESTRICTED':6, 'PC_ASYNC_IO': 10, 'PC_NO_TRUNC': 7,<br />

'PC_FILESIZEBITS': 13, 'PC_LINK_MAX': 0, 'PC_PIPE_BUF': 5,<br />

'PC_PATH_MAX': 4}<br />

>>> os.pathconf('/usr/lib/python2.4/tarfile.py', 'PC_FILESIZEBITS')<br />

64<br />

readlink(lien) -> chemin<br />

Récupère le chemin pointé par un lien. Provoque une OSError si le chemin fourni<br />

n’est pas un lien (non disponible sous MS-Windows).<br />

Recherche du fichier originel d’un lien<br />

$ touch fichier.py<br />

$ ln -s fichier.py lien.py<br />

$ python<br />

Python 2.6.1 (r261:67515, Dec 6 2008, 16:42:21)<br />

[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin<br />

Type "help", "copyright", "credits" or "license" for more information.<br />

>>> import os<br />

>>> os.readlink('lien.py')<br />

'fichier.py'

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!