[Pythonmac-SIG] Finder Crash, after moving files....
Benjamin Schollnick
bscholl1 at rochester.rr.com
Fri Jul 2 20:39:53 EDT 2004
Folks,
I know I asked about this before... But...
The following script will crash the finder, in a repeatable manner....
After, roughly, only .... <cough> <cough> four thousand and twenty
five <cough> <cough> findertools.move's, the finder will crash....
This finder crash also seems to take down Safari if it is running....
(No other applications, just the Finder and Safari...
Actually, technically the finder is running... But you have the
spinning pizza wheel, and your only recourse is to relaunch the
finder....
Also... I can't find the directory that findertools or EasyDialogs is
now stored in.... I am running on 10.3.4, and this has happened for a
long time... I never thought to see if it is reproducable or
consistent....
- Benjamin
Btw-> If anyone asks, this is usually run on my download directory...
Well, actually a different script is run on my download directory to
"clean it up", and make subdirectories, and move files.
I just changed the way that script works, so I need to "remove" the
old subdirectories and have it process them again... So I whipped this
up...
-----------------------------------------------------------------------
#!python
import sys
import os
from bas_common import *
mac_mode = macintosh
if mac_mode:
import macostools
import findertools
# import macfs
import EasyDialogs
def move_file ( old_path, new_path, filename ):
# print "old: ",old_path
# print "new:",new_path
# print "filename:",filename
# print "old + file:", old_path + os.sep + filename
if os.path.exists (new_path + os.sep + filename):
Ask = EasyDialogs.AskYesNoCancel("Duplicate File Detected (%s),
Overwrite?" % filename, default = 1, yes=None, no=None, cancel=None,
id=262)
if Ask == 1:
if mac_mode:
# Overwrite, by removing the old file
#
os.remove(new_path + os.sep + filename)
elif Ask == 0:
#
# Do not overwrite, end routine, by returning
#
return 0
elif Ask == -1:
#
# Abort program, return error code
#
return -1
if mac_mode:
findertools.move (old_path + os.sep + filename, new_path)
return None
if len(sys.argv) < 1:
print "Aborted...."
sys.exit(5)
sources = EasyDialogs.AskFolder ( message="Please choose a folder to
process")
print sources
sources = sources.strip()
print sources
found = os.listdir ( sources )
if found == None or found =="":
print "No directory selected."
sys.exit(5)
number_of_entries = len(found)
count = 0
for j in found:
new_directory = sources + os.sep + j
if os.path.isdir ( new_directory ):
files = os.listdir ( new_directory )
if len(files) > 1:
print "\n",new_directory
for x in files:
if x.upper() == ".DS_STORE":
pass
else:
print " ",count," ",
#print new_directory, " ", sources, " ", x
move_file ( new_directory, sources, x)#, new_dir, filename )
count = count +1
print ".",
-----------------------------------------------------------------------
More information about the Pythonmac-SIG
mailing list