pamir : réécriture de pacman-mirrors en python
Publié : 28 jui 2013, 13:06
Bonjour à tous,
J'ai réécrit ce script bash en python pour m'entraîner.
Pour l'utiliser :
1) le télécharger ICI ;
2) le rendre exécutable, et le copier sous root dans /usr/bin (sudo cp pamir.py /usr/bin/pamir).
Au passage, il est possible de le renommer pamir au lieu de pamir.py, c'est plus court à taper.
Avantages :
- trois fois plus rapide que l'ancien, charge moins le CPU ;
- fournit la date de dernière mise à jour d'un miroir ;
- liste des pays possibles dans le help (-h) ;
- permet de sélectionner plusieurs pays sur la ligne de commande ;
- test de validité du paramètre branche ;
- possibilité de créer une liste sans être root.
Inconvénients ;
- pas l'outil officiel.
Exemple d'utilisation :
J'ai mis time devant pour avoir le temps d'exécution.
ce qui donne comme mirrorlist :
(edit)
Exemple de help :
J'ai réécrit ce script bash en python pour m'entraîner.
Pour l'utiliser :
1) le télécharger ICI ;
2) le rendre exécutable, et le copier sous root dans /usr/bin (sudo cp pamir.py /usr/bin/pamir).
Au passage, il est possible de le renommer pamir au lieu de pamir.py, c'est plus court à taper.
Avantages :
- trois fois plus rapide que l'ancien, charge moins le CPU ;
- fournit la date de dernière mise à jour d'un miroir ;
- liste des pays possibles dans le help (-h) ;
- permet de sélectionner plusieurs pays sur la ligne de commande ;
- test de validité du paramètre branche ;
- possibilité de créer une liste sans être root.
Inconvénients ;
- pas l'outil officiel.
Exemple d'utilisation :
J'ai mis time devant pour avoir le temps d'exécution.
[pat@xfce ~]$ time sudo pamir -c France,Germany,Netherlands
France
0.203 http://manjarolinux.polymorf.fr/stable/$repo/$arch
Germany
0.104 http://ftp.halifax.rwth-aachen.de/manjaro/stable/$repo/$arch
0.160 http://ftp.tu-chemnitz.de/pub/linux/manjaro/stable/$repo/$arch
0.149 http://ftp.rz.tu-bs.de/pub/mirror/manjaro.org/repos/stable/$repo/$arch
Netherlands
0.101 http://ftp.nluug.nl/pub/os/Linux/distr/manjaro/stable/$repo/$arch
real 0m0.864s
user 0m0.117s
sys 0m0.020s
[pat@xfce ~]$
ce qui donne comme mirrorlist :
##
## Manjaro Linux repository mirrorlist
## Generated on 28 Jun 2013
##
## Use pacman-mirrors to modify
##
## Location : Netherlands
## Time : 0.101
## Updated : 2013-06-28 10:00:36
Server = http://ftp.nluug.nl/pub/os/Linux/distr/manjaro/stable/$repo/$arch
## Location : Germany
## Time : 0.104
## Updated : 2013-06-28 06:50:35
Server = http://ftp.halifax.rwth-aachen.de/manjaro/stable/$repo/$arch
## Location : Germany
## Time : 0.149
## Updated : 2013-06-28 02:00:34
Server = http://ftp.rz.tu-bs.de/pub/mirror/manjaro.org/repos/stable/$repo/$arch
## Location : Germany
## Time : 0.160
## Updated : 2013-06-28 03:40:34
Server = http://ftp.tu-chemnitz.de/pub/linux/manjaro/stable/$repo/$arch
## Location : France
## Time : 0.203
## Updated : 2013-06-28 11:10:36
Server = http://manjarolinux.polymorf.fr/stable/$repo/$arch
(edit)
Exemple de help :
$ pamir -h
Usage : /usr/bin/pamir [-b branch] [-c country[,country...] [-h] [-o output]
-b branch stable, testing, or unstable
-c country[,country...] use only mirrors from country(ies)
( Africa Bangladesh Belgium Brasil China Denmark France Germany Greece Indonesia Ireland Italy Japan Netherlands Philippines Romania Russia South_Korea Sweden Taiwan United_Kingdom United_States )
-h show help
-o output specify output file