diff --git a/p4RemoveUnversioned.py b/p4RemoveUnversioned.py index 154728b..d2e326b 100644 --- a/p4RemoveUnversioned.py +++ b/p4RemoveUnversioned.py @@ -4,6 +4,7 @@ # python_version : 2.7.6 and 3.4.0 # ================================= +# todo: switch to `p4 fstat ...`, and parse the output for clientFile and cache it. # todo: have a backup feature, make sure files are moved to the recycle bin or a temporary file. # todo: switch to faster method of calling p4 fstat on an entire directory and parsing it's output # todo: add option of using send2trash @@ -160,7 +161,7 @@ class Worker( threading.Thread ): if len( new_line ) > 0: file_regexes.append( re.compile( os.path.join( re.escape( directory + os.sep ), new_line ) ) ) - self.console.write( "|Appending ignores from " + path ) + self.console.write( "| Appending ignores from " + path ) with self.files_to_ignore.mutex: if directory not in self.files_to_ignore: self.files_to_ignore[ directory ] = [] @@ -173,8 +174,17 @@ class Worker( threading.Thread ): files = [] command = "p4 fstat *" - proc = subprocess.Popen( command.split( ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=directory ) - (out, err) = proc.communicate() + try: + proc = subprocess.Popen( command.split( ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=directory ) + (out, err) = proc.communicate() + except Exception as ex: + self.console.write( "| " + type( ex ) ) + self.console.write( "| " + ex.args ) + self.console.write( "| " + ex ) + self.console.write( "|ERROR." ) + self.console.flush( ) + self.queue.task_done( ) + continue for line in err.decode('utf-8').split( os.linesep ): if len( line ) == 0: @@ -229,6 +239,7 @@ def main( args ): parser.add_option( "-d", "--dir", dest="directory", help="Desired directory to crawl.", default=None ) parser.add_option( "-t", "--threads", dest="thread_count", help="Number of threads to crawl your drive and poll p4.", default=100 ) + parser.add_option( "-q", "--quiet", action="store_false", dest="quiet", default=False ) parser.add_option( "-v", "--verbose", action="store_true", dest="verbose", default=True ) ( options, args ) = parser.parse_args( ) @@ -295,6 +306,4 @@ if __name__ == "__main__": main( sys.argv ) except: print( "Unexpected error!" ) - traceback.print_exc( file = sys.stdout ) - - PressEnter() \ No newline at end of file + traceback.print_exc( file = sys.stdout ) \ No newline at end of file