Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TOOL] Eliminare quello che si ha su CD...
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Sun Dec 05, 2004 5:47 pm    Post subject: [TOOL] Eliminare quello che si ha su CD... Reply with quote

Ho fatto un piccolo script in python (per me' molto utile) che elimina da una cartella quello che e' contenuto in un altra cartella.

In Parlole un po' piu' chiare.
- Mi Copio su CD un po' di file della dir distfiles
- Elimino tutti i file che ho messo su cd con questo script.

Ecco qui il Programma.
Selezionate, Incollate nel vostro editor preferito e salvatelo da qualche parte.
magari in una directory Eseguibile come '/usr/bin'

pkgrm 0.1
Code:

#!/usr/bin/env python

import sys
import os

def main(path1, path2):
   try:
      dir1 = os.listdir(path1)
   except OSError, msg:
      print msg
      sys.exit(0)
   try:
      dir2 = os.listdir(path2)
   except OSError, msg:
      print msg
      sys.exit(0)
   
   for pkg1 in dir1:
      for pkg2 in dir2:
         if (pkg1 == pkg2):
            print "Remove", pkg1, "=", pkg2
            try:
               os.remove(path1 + "/" + pkg1)
            except OSError, msg:
               print msg
               
   

if (__name__ == '__main__'):
   if (len(sys.argv) < 3):
      print "Usage:"
      print "   pkgrm [ dir1 ] [ dir2 ]"
      print
      print "Example:"
      print "   pkgrm /usr/portage/distfiles /mnt/dvdrom/distfiles"
      print
   else:
      print "Path1:", sys.argv[1]
      print "Path2:", sys.argv[2]
      main(sys.argv[1], sys.argv[2])
   sys.exit(0)


Per Eseguire il Programma
Salvatelo 'magari come' pkgrm e poi fatelo partire indicando 2 directory:
Code:

Usage:
   pkgrm [ dir1 ] [ dir2 ]

Example:
   pkgrm /usr/portage/distfiles /mnt/dvdrom/distfiles


ATTENZIONE - Il Programma elimina senza chiedere conferma.
Quindi attenti a quello che fate!
_________________
http://th30z.netsons.org/
Back to top
View user's profile Send private message
Panda
Apprentice
Apprentice


Joined: 31 Jul 2003
Posts: 223
Location: Cremona <=> Catania

PostPosted: Sun Dec 05, 2004 10:33 pm    Post subject: Reply with quote

sai che e' interessante?

Io lo perferzionerei in stile etc-update... nel senso che potresti implementare un resoconto delle differenze delle due locazioni, far decidere file per file, oppure segare via tutto quello che non e' sul cd...
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30837
Location: here

PostPosted: Wed Dec 08, 2004 4:09 pm    Post subject: Reply with quote

Aggiunto ai post utilissimi sezione tools
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
oRDeX
Veteran
Veteran


Joined: 19 Oct 2003
Posts: 1325
Location: Italy

PostPosted: Wed Dec 08, 2004 4:25 pm    Post subject: Reply with quote

Magari proprio come etc-update potresti implementare un menù che mette in evidenza tutti i file che vorrebbe rimuovere con le varie opzioni, se cancellarli tutti senza guardarli, se cancellarli uno per uno con conferma, o selezionando il file da cancellare
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum