Fixed mixing of unix/windows paths. Need to test this works cross platform.

Also removed PressEnter. Added global basename function so we can
override which version we're using, right now I'm seeing if
ntpath.basename works for all cases.
This commit is contained in:
Brian 2014-05-09 12:15:32 -06:00
parent 8bb78e7c02
commit b3051f8dc8
1 changed files with 12 additions and 9 deletions

View File

@ -13,6 +13,9 @@
import inspect, multiprocessing, optparse, os, re, stat, subprocess, sys, threading, traceback
# trying ntpath, need to test on linux
import ntpath
re_remove_comment = re.compile( "#.*$" )
def remove_comment( s ):
@ -33,9 +36,9 @@ p4_ignore = ".p4ignore"
main_pid = os.getpid( )
def PressEnter( ):
print( "\nPress ENTER to continue..." )
s=input( "" )
def basename( path ):
#return os.path.basename( path )
return ntpath.basename( path )
def get_ignore_list( path, files_to_ignore ):
# have to split path and test top directory
@ -192,17 +195,17 @@ class Worker( threading.Thread ):
# # dirty hack that grabs the filename from the ends of the printed out (not err) "depo_path - local_path"
# # I could use regex to verify the expected string, but that will just slow us down.
# basename = os.path.basename( line )
# base = basename( line )
i = line.rfind( ' - ')
if i >= 0:
basename = line[ : i ]
if basename == "*":
base = line[ : i ]
if base == "*" or len(base) == 0:
# Directory is empty, we could delete it now
continue
path = os.path.join( directory, basename )
path = os.path.join( directory, base )
if not os.path.isdir( path ):
files.append( basename )
files.append( base )
for content in dir_contents:
path = os.path.join( directory, content )
@ -253,7 +256,7 @@ def main( args ):
# make sure script doesn't delete itself
with files_to_ignore.mutex:
files_to_ignore[ root_full_path ] = [ re.compile( os.path.join( re.escape( root_full_path + os.sep ), os.path.basename( __file__ ) ) ) ]
files_to_ignore[ root_full_path ] = [ re.compile( re.escape( os.path.join( root_full_path, basename( __file__ ) ) ) ) ]
# Setup threading
threads = []