Made script obey quiet option. Added file and error count to print at end.
Also made sure the error output gets piped and doesn't show up in console. However, we shouldn't ignore any error output, this should be accounted for and properly logged. So, this is a TODO.
This commit is contained in:
parent
0dcd14a73b
commit
4435a36bed
|
@ -94,7 +94,7 @@ def get_client_set( path ):
|
||||||
|
|
||||||
command = "p4 fstat ..."
|
command = "p4 fstat ..."
|
||||||
|
|
||||||
proc = subprocess.Popen( command.split( ), stdout=subprocess.PIPE, stderr=None, cwd=path )
|
proc = subprocess.Popen( command.split( ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path )
|
||||||
for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
line = get_str_from_process_stdout( line )
|
line = get_str_from_process_stdout( line )
|
||||||
|
|
||||||
|
@ -222,14 +222,21 @@ def main( args ):
|
||||||
|
|
||||||
directory = normpath( options.directory if options.directory is not None else os.getcwd( ) )
|
directory = normpath( options.directory if options.directory is not None else os.getcwd( ) )
|
||||||
|
|
||||||
|
remove_count = 0
|
||||||
|
warning_count = 0
|
||||||
|
error_count = 0
|
||||||
|
|
||||||
with Console( auto_flush_num=20, auto_flush_time=1000 ) as c:
|
with Console( auto_flush_num=20, auto_flush_time=1000 ) as c:
|
||||||
|
if not options.quiet:
|
||||||
c.writeflush( "Caching files in depot..." )
|
c.writeflush( "Caching files in depot..." )
|
||||||
files_in_depot = get_client_set( directory )
|
files_in_depot = get_client_set( directory )
|
||||||
|
|
||||||
|
if not options.quiet:
|
||||||
c.writeflush( "Checking " + directory)
|
c.writeflush( "Checking " + directory)
|
||||||
for root, dirs, files in os.walk( directory ):
|
for root, dirs, files in os.walk( directory ):
|
||||||
ignore_list = {}#get_ignore_list( root, files_to_ignore )
|
ignore_list = {}#get_ignore_list( root, files_to_ignore )
|
||||||
|
|
||||||
|
if not options.quiet:
|
||||||
c.write( "|Checking " + root )
|
c.write( "|Checking " + root )
|
||||||
|
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
|
@ -237,6 +244,7 @@ def main( args ):
|
||||||
|
|
||||||
if match_in_ignore_list( path, ignore_list ):
|
if match_in_ignore_list( path, ignore_list ):
|
||||||
# add option of using send2trash
|
# add option of using send2trash
|
||||||
|
if not options.quiet:
|
||||||
c.write( "| ignoring " + d )
|
c.write( "| ignoring " + d )
|
||||||
dirs.remove( d )
|
dirs.remove( d )
|
||||||
|
|
||||||
|
@ -244,18 +252,32 @@ def main( args ):
|
||||||
path = normpath( join( root, f ) )
|
path = normpath( join( root, f ) )
|
||||||
|
|
||||||
if path not in files_in_depot:
|
if path not in files_in_depot:
|
||||||
c.write( "| " + path )
|
if not options.quiet:
|
||||||
c.write( "| " + f + " is unversioned, removing it." )
|
c.write( "| " + f + " is unversioned, removing it." )
|
||||||
#try:
|
try:
|
||||||
# os.chmod( path, stat.S_IWRITE )
|
os.chmod( path, stat.S_IWRITE )
|
||||||
# os.remove( path )
|
os.remove( path )
|
||||||
#except OSError as ex:
|
remove_count += 1
|
||||||
# c.writeflush( "| " + type( ex ).__name__ )
|
except OSError as ex:
|
||||||
# c.writeflush( "| " + repr( ex ) )
|
c.writeflush( "| " + type( ex ).__name__ )
|
||||||
# c.writeflush( "|ERROR." )
|
c.writeflush( "| " + repr( ex ) )
|
||||||
|
c.writeflush( "|ERROR." )
|
||||||
|
|
||||||
|
error_count += 1
|
||||||
|
|
||||||
|
if not options.quiet:
|
||||||
c.write( "|Done." )
|
c.write( "|Done." )
|
||||||
|
|
||||||
|
output = "\nRemoved " + str( remove_count ) + " file/s"
|
||||||
|
|
||||||
|
if warning_count > 0:
|
||||||
|
output += " w/ " + str( warning_count ) + " warning/s"
|
||||||
|
|
||||||
|
if error_count > 0:
|
||||||
|
output += " w/ " + str( error_count ) + " errors/s"
|
||||||
|
|
||||||
|
c.write( output + "." )
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
main( sys.argv )
|
main( sys.argv )
|
||||||
|
|
Loading…
Reference in New Issue