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édente | ||
fusauto [Le 01/02/2008, 07:39] – benjisan | fusauto [Le 04/06/2018, 11:18] (Version actuelle) – lien L'Africain | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | {{tag> | ||
+ | ---- | ||
+ | |||
+ | ====== FUSAUTO ====== | ||
+ | |||
+ | **FUSAUTO** est un script python pour faciliter l' | ||
+ | |||
+ | |||
+ | |||
+ | ===== Script python ' | ||
+ | |||
+ | Pour profiter de **FUSAUTO**, | ||
+ | Deux options : | ||
+ | * soit vous l' | ||
+ | * soit vous l' | ||
+ | |||
+ | Y copier les lignes suivantes et sauvegarder. | ||
+ | |||
+ | <code python># | ||
+ | # coding: utf-8 | ||
+ | # | ||
+ | # fusauto | ||
+ | # auto mount directory with fuse by reading a config file | ||
+ | # | ||
+ | # Copyright (C) Nicolas Albert < | ||
+ | # | ||
+ | # Version 0.0.1 | ||
+ | # | ||
+ | # This program is free software; you can redistribute it and/or modify | ||
+ | # it under the terms of the GNU General Public License as published by | ||
+ | # the Free Software Foundation; either version 3 of the License, or | ||
+ | # any later version. | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, | ||
+ | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+ | # GNU General Public License for more details. | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program; if not, write to the Free Software | ||
+ | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
+ | |||
+ | import sys, os | ||
+ | |||
+ | def runconf(conf, | ||
+ | file = open(conf, " | ||
+ | act = {} | ||
+ | for line in file.readlines(): | ||
+ | if not line.startswith('#' | ||
+ | part = line[: | ||
+ | act[part[0]] = part[2] | ||
+ | file.close() | ||
+ | if ' | ||
+ | if not ' | ||
+ | if not ' | ||
+ | os.system(" | ||
+ | |||
+ | def getfuses(): | ||
+ | mtab = open("/ | ||
+ | fuses =[ line for line in mtab.readlines() if line.split()[2][0: | ||
+ | mtab.close() | ||
+ | return fuses | ||
+ | |||
+ | def alreadymount(path): | ||
+ | for fuse in getfuses(): | ||
+ | fd = fuse.split()[1] | ||
+ | if fd == path or fd == os.getcwd()+'/' | ||
+ | return True | ||
+ | return False | ||
+ | |||
+ | def umount(path): | ||
+ | os.system("/ | ||
+ | |||
+ | if __name__ == " | ||
+ | if len(sys.argv) == 2 and os.path.isdir(sys.argv[1]): | ||
+ | if alreadymount(sys.argv[1]): | ||
+ | umount(sys.argv[1]) | ||
+ | else: | ||
+ | conf = sys.argv[1]+'/ | ||
+ | if os.path.isfile(conf): | ||
+ | runconf(conf, | ||
+ | else: | ||
+ | print conf," | ||
+ | else: | ||
+ | print "One directory is required"'' | ||
+ | </ | ||
+ | |||
+ | Il faut rendre le script exécutable : | ||
+ | '' | ||
+ | ou | ||
+ | '' | ||
+ | |||
+ | |||
+ | ===== Fichier de configuration ' | ||
+ | Pour fonctionner, | ||
+ | |||
+ | Rien de mieux qu'un exemple ! | ||
+ | |||
+ | Je veux monter un répertoire distant d'une machine (siniath-tirith) dans le répertoire __~/ | ||
+ | |||
+ | Je crée un nouveau fichier __~/ | ||
+ | |||
+ | <note warning> | ||
+ | Il est important de ne mettre aucun espace avant le 1er signe égal sur les lignes qui ne sont pas des commentaires, | ||
+ | |||
+ | < | ||
+ | # lines start with # are commentaries | ||
+ | |||
+ | # process must be run (must exist) | ||
+ | bin=/ | ||
+ | |||
+ | # remote folder (default : none) | ||
+ | from=siniath-tirith:/ | ||
+ | |||
+ | # fuse options (default : ) | ||
+ | opt=-o follow_symlinks, | ||
+ | |||
+ | |||
+ | |||
+ | ===== Utilisation ===== | ||
+ | |||
+ | Il suffit d' | ||
+ | |||
+ | **FUSAUTO** monte le répertoire s'il ne l'est pas déjà, sinon il le démonte. | ||
+ | |||
+ | === Shell === | ||
+ | '' | ||
+ | |||
+ | === Nautilus === | ||
+ | On va utiliser la possibilité de [[nautilus_scripts|script pour Nautilus]] pour pouvoir monter/ | ||
+ | |||
+ | Pour cela, on va lier le script dans le répertoire __~/ | ||
+ | |||
+ | < | ||
+ | |||
+ | Désormais, un clic-droit sur un répertoire propose ' | ||
+ | |||
+ | === Rox-Filer === | ||
+ | On va utiliser la possibilité de script pour rox-filer pour pouvoir monter/ | ||
+ | |||
+ | Pour cela, on va lier le script dans les répertoires __~/ | ||
+ | |||
+ | < | ||
+ | ln -s `which fusauto` ~/ | ||
+ | |||
+ | Désormais, un clic-droit sur un répertoire propose 'Rép. > fusauto' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Liens et références ===== | ||
+ | |||
+ | * [[http:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | // |