![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4
![]() |
Ok, has no use to me, probably has NO use to anyone, But i made it just to see if it works basically..
All it will do is make sure that NO files can be added to a protected folder specifyed by 'path' variable. And will delete anything that is not added to a 'whitelist'.. Have fun with it, don't really care if there is no use! lol.. import os from time import sleep whitelist = [ 'protected.txt', #add files to this to 'protect' from deletion 'save.doc' ] path = YOUR GIVEN PATH while(1): for root, dirs, files in os.walk(path): for name in files: if name not in whitelist: try: os.remove(os.path.join(path, name)) except: pass sleep(4) Designed to run as a 'background' process, so save it as a '.pyw' ps: There is no break from the loop, to close search processes in the windows task manager for 'pythonw.exe' and close that to close the program.. ![]()
__________________
while me is alive: make(life,simple) |
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
![]() You're meant to fork your process into the background. How to do that has been addressed in another thread. If you want a solution that doesn't eat CPU, yet still gets informed of file additions/modifications in a directory almost instantaneously, look into the appropriate technology for your OS that informs your daemon of file i/o events that occur in a certain directory (e.g FAM on *nix, KDirWatch when using kdelibs, etc). |
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4
![]() |
I'm a lazy person!!
Great excuse to pull *still learning like's the feed-back* hehe, i'll look in to 'forking' processes now! As for the second part All i'm gonna say is, please don't confuse me!! ![]()
__________________
while me is alive: make(life,simple) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|