Guest User

Untitled

a guest
Jun 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.85 KB | None | 0 0
  1.              # / usr / bin / python # - * - coding: Latin-1 - *
  2.  
  3. #######################################################
  4. #Author : Angelo
  5. #Date : 11.02.2012
  6. #Website :Angelo.otaku-ana.net
  7. #Thanks to : Fr0g, Daft
  8. #This program is free,distribuate with a GNU Licence.
  9. #######################################################
  10.  
  11.  
  12. import shutil
  13. import os
  14. import tarfile
  15. import time
  16.  
  17.  
  18. reponse_a = str();# Variable pour quitter
  19. position = str(); # Curseur de la position actuelle
  20. add = str();      #Variable pour quitter l'ajout d'un dossier enfant,
  21. #                  et ajout d'un nouveau répértoire
  22. local = os.environ['USER']; # Nom d'utilisateur
  23. nom = time.strftime('%d-%m-%y-%H:%M',time.localtime())
  24. heure = time.strftime('%H:%M',time.localtime())
  25.  
  26. if os.name == "posix": #Si le système est de type Unix
  27.     cible = '/home/'+local;
  28.     lo = 'Linux';
  29. else :
  30.     lo = 'Windows'
  31.    
  32. print (nom)#Affiche l'heure et la date
  33. print("Vous etes sous : {0}".format(lo));
  34. print("Pour quitter appuyer sur q sinon sur entrez \n");
  35. reponse_a = raw_input('> '); #Savoir si l'utilisateur veut rester
  36. reponse_a = reponse_a.lower();#Convertir majucule en minuscules
  37. while reponse_a != "q":
  38.     os.system('clear')
  39.     position = os.getcwd();#Répértoire courant
  40.     print("Le repertoire est: {0},il est {1}".format(position,heure));
  41.     liste = os.listdir(position);
  42.     print("----------------------------------------------------------");
  43.     print(liste);
  44.     print("----------------------------------------------------------");
  45.     print("Pour rentrer dans un autre repertoire");
  46.     print("Entrez seulement son nom");
  47.     print("Pour terminer, lancer la commande : stop");
  48.     print("Pour remonter d'un repertoire taper '..'")
  49.     print("----------------------------------------------------------");
  50.     add = "/"+raw_input('> ');
  51.     if add !="/stop":
  52.         try:
  53.             position = position + add; #Calcul la nouvelle postion
  54.             os.chdir(position);        #Va à la nouvel position
  55.             os.system('clear')
  56.         except:
  57.             print("Erreur mauvais repertoire,\n appuyer sur entrez");
  58.             raw_input();
  59.             os.system('clear')
  60.  
  61.     else:
  62.         break;
  63.  
  64. os.system('clear')
  65. print("Le repertoire choisi est : {0}".format(position));
  66. print("Creation de l'archive en cours ...");
  67. Archive = tarfile.open('Archive','w');
  68. Archive.add(position);
  69. print("Creation de l'archive terminé !");
  70. Archive.close;
  71.  
  72. os.chdir(cible); # Va au repertoire /home/login
  73. os.system('mkdir Archive'); # Crer le dossier Archive
  74.  
  75. src = position+"/"+"Archive";
  76. dst = "/{0}/Archive/{1}".format(cible,nom); # Destination a
  77. # /home/login/Archive et renomme le fichier a la date.
  78. shutil.move(src,dst); #Deplace le fichier
  79. print("Deplacement finit, le fichier ce trouve a /home/login/Archive");
  80. print("Merci d'avoir utiliser ce programme");
Add Comment
Please, Sign In to add comment