Catégorie: Print

Applescript : automount

ou comment monter des volumes sans se fatiguer, avec contrôle d'erreurs, notifications growl et installation en login item. tout ce qu'il faut faire c'est le placer dans le dossier application (enregistré en appli)

Télécharger automount 2.0

Pour la licence, je remets pas le bloc, mais c'est bien entendu GPL v3

Code:

try
       tell application "System Events"
               get exists login item "automount"
               if result is false then
                       make new login item at end of login items with properties
{path:"/Applications/automount.app", hidden:true, kind:"Application"}
               end if
       end tell
end try
 
try
       tell application "System Events" to set GrowlExists to exists
application process ("GrowlHelperApp" as string)
       if (GrowlExists) then
               tell application "GrowlHelperApp"
                       set the allNotificationsList to ¬
                               {"Succes", "Echec", "Erreur"}
                       set the enabledNotificationsList to ¬
                               {"Succes", "Echec", "Erreur"}
                       register as application ¬
                               "Automount" all notifications allNotificationsList ¬
                               default notifications enabledNotificationsList ¬
                               icon of application "Disk Utility"
               end tell
       else
               set growlURL to "http://growl.info/index.php"
               display dialog "Ce script fonctionne (mieux) avec Growl installé sur
le système." & return & "Aller sur " & growlURL & " pour le
télécharger ?" with icon note buttons {"Oui", "Non"} default button
{"Oui"}
               if button returned of result is "Oui" then
                       open location growlURL
               end if
       end if
end try
 
try
       set myVolumes to {¬
               "afp://login:pass@ip/folder/", ¬
               "smb://login:pass@ip/share_name/"}
end try
 
tell application "Finder"
       repeat with currentVolume in myVolumes
               try
                       set AppleScript's text item delimiters to {"/"}
                       set myParts to text items of currentVolume
                       set myLength to the count of myParts
                       set myName to text item (myLength - 1) of myParts
               end try
               if not (exists the disk myName) then
                       try
                               mount volume currentVolume
                       on error errText number errNum
                               if errNum is -55 then
                                       if (GrowlExists) then
                                               tell application "GrowlHelperApp"
                                                       notify with name ¬
                                                               "Echec" title ¬
                                                               "Montage" description "Le volume '" & myName & ¬
                                                               "' est déjà monté sur le bureau !" application name ¬
                                                               "Automount" icon of application "Disk Utility"
                                               end tell
                                       else
                                               display dialog "Le volume '" & myName & "' est déjà monté sur le
bureau !" with icon 2
                                       end if
                               else if errNum is -128 then
                                       if (GrowlExists) then
                                               tell application "GrowlHelperApp"
                                                       notify with name ¬
                                                               "Echec" title ¬
                                                               "Erreur de montage" description "Action annulée lors du
montage de '" & myName & ¬
                                                               "'  " application name ¬
                                                               "Automount" icon of application "Disk Utility"
                                               end tell
                                       else
                                               display dialog "Action annulée lors du montage de '" & myName &
"'  " with icon 0 buttons {"OK"} default button {"OK"}
 
                                       end if
                               else
                                       if (GrowlExists) then
                                               tell application "GrowlHelperApp"
                                                       notify with name ¬
                                                               "Echec" title "Erreur de montage n°" & errNum ¬
                                                               description "Impossible de monter le volume '" & myName & "' "
& return & "--" & return & "Message système : " & return & errText ¬
                                                               application name ¬
                                                               "Automount" icon of application "Disk Utility"
                                               end tell
                                       else
                                               display dialog "Impossible de monter le volume '" & myName & "'
" & return & "--" & return & "Message système : " & return & errText
with icon 0 buttons {"OK"} default button {"OK"}
                                       end if
                               end if
                       end try
                       if (GrowlExists) then
                               tell application "GrowlHelperApp"
                                       notify with name ¬
                                               "Succes" title ¬
                                               "Volume monté" description "Le volume '" & myName & ¬
                                               "' a bien été monté sur le bureau" application name ¬
                                               "Automount" icon of file "file:///Volumes/" & myName
 
                               end tell
                       end if
               end if
       end repeat
end tell
 
try
       tell application "automount" to quit
on error
       if (GrowlExists) then
               tell application "GrowlHelperApp"
                       notify with name ¬
                               "Erreur" title ¬
                               "Erreur lors de la sortie" description ¬
                               "Impossible de quitter Automount" application name ¬
                               "Automount" icon of application "Disk Utility"
               end tell
       else
               display dialog "Impossible de quitter Automount" with icon 0 buttons
{"OK"} default button {"OK"}
       end if
end try
Permalien 01.12.08 19:20:51, par Benjamin Email , 587 mots, Catégories: Non catégorisé, Print, Blog , Laisser un commentaire »Envoyer un trackaback »

Retour sur la Drupa 2008

Pour fêter cette mise à jour et la purge des anciens articles, un petit flashback sur la Drupa 2008 qui a fermé ses portes début juin en pleine fièvre footbalistique.

Pour cette édition 2008 je n'ai pu passer qu'une trop courte journée et demi sur le salon, bien peu au regard de l'événement Kolossal que représente le salon quadri-annuel de l'impression et du papier (Drucken & Papier = DRUPA, c'est bête mais fallait y penser).

Je vais vous proposer, une vue succincte et décalée sur ce qui fût le phénomène du microcosme des industries graphiques pour cette année.

Lire la suite »

Pages: 1 · 2

Permalien 20.06.08 01:31:05, par Benjamin Email , 844 mots, Catégories: Print ,