Added more debug info at the end for files processed, cleaned up formatting. At some point will strive to make the output more UNIX friendly, parsable.
I also fixed a bug where the script would crash instead of setting the P4Client. I need to fix the script to use a `with` construct so if you terminate the program the P4Client is returned to what it was.
This commit is contained in:
parent
06b0cbe426
commit
e7bb65874e
3 changed files with 25 additions and 27 deletions
|
@ -237,8 +237,8 @@ class Console( threading.Thread ):
|
|||
self.buffer_write_times.clear( )
|
||||
self.queue.task_done( )
|
||||
|
||||
print(self.queue.qsize())
|
||||
print(self.queue.empty())
|
||||
#print(self.queue.qsize())
|
||||
#print(self.queue.empty())
|
||||
break
|
||||
|
||||
elif event == Console.MSG.WRITE:
|
||||
|
@ -347,7 +347,7 @@ def main( args ):
|
|||
client_root = get_client_root()
|
||||
ldirectory = directory.lower()
|
||||
workspace_name = None
|
||||
if not ldirectory.startswith(client_root.lower()):
|
||||
if client_root is None or not ldirectory.startswith(client_root.lower()):
|
||||
print("\nCurrent directory not in client view, checking other workspaces for user '" + username + "' ...")
|
||||
|
||||
workspace_name = parse_info_from_command('p4 info', 'Client name: ')
|
||||
|
@ -386,6 +386,9 @@ def main( args ):
|
|||
# Key is the file root, the value is the table of file regexes for that directory.
|
||||
files_to_ignore = PDict()
|
||||
|
||||
processed_file_count = 0
|
||||
processed_directory_count = 0
|
||||
|
||||
remove_file_count = 0
|
||||
remove_dir_count = 0
|
||||
warning_count = 0
|
||||
|
@ -414,18 +417,21 @@ def main( args ):
|
|||
ignore_list = get_ignore_list( root, files_to_ignore )
|
||||
|
||||
if not options.quiet:
|
||||
c.write( "|Checking " + root )
|
||||
c.write( "|Checking " + os.path.relpath( root, directory ) )
|
||||
|
||||
for d in dirs:
|
||||
processed_directory_count += 1
|
||||
path = join( root, d )
|
||||
rel_path = os.path.relpath( path, directory )
|
||||
|
||||
if match_in_ignore_list( path, ignore_list ):
|
||||
# add option of using send2trash
|
||||
if not options.quiet:
|
||||
c.write( "| ignoring " + d )
|
||||
c.write( "| ignoring " + rel_path )
|
||||
dirs.remove( d )
|
||||
|
||||
for f in files:
|
||||
processed_file_count += 1
|
||||
path = normpath( join( root, f ) )
|
||||
|
||||
if path not in files_in_depot:
|
||||
|
@ -451,18 +457,20 @@ def main( args ):
|
|||
ignore_list = get_ignore_list( root, files_to_ignore )
|
||||
|
||||
for d in dirs:
|
||||
processed_directory_count += 1
|
||||
path = os.path.join( root, d )
|
||||
rel_path = os.path.relpath( path, directory )
|
||||
|
||||
if match_in_ignore_list( path, ignore_list ):
|
||||
# add option of using send2trash
|
||||
if not options.quiet:
|
||||
c.write( "| ignoring " + path )
|
||||
c.write( "| ignoring " + rel_path )
|
||||
dirs.remove( d )
|
||||
try:
|
||||
os.rmdir(path)
|
||||
remove_dir_count += 1
|
||||
if not options.quiet:
|
||||
c.write( "| " + path + " was removed." )
|
||||
c.write( "| " + rel_path + " was removed." )
|
||||
except OSError:
|
||||
# Fails on non-empty directory
|
||||
pass
|
||||
|
@ -484,7 +492,10 @@ def main( args ):
|
|||
c.write("|Done.")
|
||||
|
||||
if not options.quiet:
|
||||
output = "\n[ Removed " + str( remove_file_count ) + singular_pulural( remove_file_count, " file, ", " files, " )
|
||||
output = "\nChecked " + str( processed_file_count ) + singular_pulural( processed_file_count, " file, ", " files, " )
|
||||
output += str( processed_directory_count ) + singular_pulural( processed_directory_count, " directory", " directories")
|
||||
|
||||
output += "\nRemoved " + str( remove_file_count ) + singular_pulural( remove_file_count, " file, ", " files, " )
|
||||
output += str( remove_dir_count ) + singular_pulural( remove_dir_count, " directory", " directories")
|
||||
|
||||
if warning_count > 0:
|
||||
|
@ -494,9 +505,9 @@ def main( args ):
|
|||
|
||||
end = time.clock()
|
||||
delta = end - start
|
||||
output += ", and finished in " + str(delta) + "s"
|
||||
output += "\nFinished in " + str(delta) + "s"
|
||||
|
||||
c.write( output + " ]" )
|
||||
c.write( output )
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue