diff --git a/p4RemoveUnversioned.py b/p4RemoveUnversioned.py index d2e326b..670d7b0 100644 --- a/p4RemoveUnversioned.py +++ b/p4RemoveUnversioned.py @@ -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 = []