Fixed bug in p4SyncMissingFiles.py. Also fixed bug in p4Helper when

running p4RemoveUnversioned.py.
This commit is contained in:
unknown 2015-05-13 10:45:04 -06:00
parent c32c0bfbd1
commit ea14f96d76
2 changed files with 36 additions and 27 deletions

View File

@ -85,7 +85,7 @@ def call_process( args ):
def try_call_process( args, path=None ):
try:
subprocess.check_output( args.split( ), shell=False, cwd=path )
subprocess.check_output( args.split( ), shell=False, cwd=path, stderr=subprocess.STDOUT )
return 0
except subprocess.CalledProcessError:
return 1
@ -204,7 +204,7 @@ class P4Workspace:
#print("\nChecking p4 info...")
result = get_p4_py_results('info')
if len(result) == 0 or b'userName' not in result[0].keys():
print("Can't find perforce info, is it even setup?")
print("Can't find perforce info, is it even setup? Possibly can't connect to server.")
sys.exit(1)
username = get_str_from_process_stdout(result[0][b'userName'])
client_host = get_str_from_process_stdout(result[0][b'clientHost'])
@ -297,19 +297,22 @@ class Console( threading.Thread ):
self.auto_flush_time = auto_flush_time * 1000 if auto_flush_time is not None else -1
self.shutting_down = False
def write( self, data ):
self.queue.put( ( Console.MSG.WRITE, threading.current_thread().ident, data ) )
def write( self, data, pid = None ):
pid = pid if pid is not None else threading.current_thread().ident
self.queue.put( ( Console.MSG.WRITE, pid, data ) )
def writeflush( self, data ):
pid = threading.current_thread().ident
def writeflush( self, data, pid = None ):
pid = pid if pid is not None else threading.current_thread().ident
self.queue.put( ( Console.MSG.WRITE, pid, data ) )
self.queue.put( ( Console.MSG.FLUSH, pid ) )
def flush( self ):
self.queue.put( ( Console.MSG.FLUSH, threading.current_thread().ident ) )
def flush( self, pid = None ):
pid = pid if pid is not None else threading.current_thread().ident
self.queue.put( ( Console.MSG.FLUSH, pid ) )
def clear( self ):
self.queue.put( ( Console.MSG.CLEAR, threading.current_thread().ident ) )
def clear( self, pid = None ):
pid = pid if pid is not None else threading.current_thread().ident
self.queue.put( ( Console.MSG.CLEAR, pid ) )
def __enter__( self ):
self.start( )
@ -342,10 +345,14 @@ class Console( threading.Thread ):
self.buffer_write_times[ pid ] = datetime.datetime.now( )
self.buffers[ pid ].append( s )
if self.auto_flush_num >= 0 and len( self.buffers[ pid ] ) >= self.auto_flush_num:
self.flush( pid )
elif self.auto_flush_time >= 0 and ( datetime.datetime.now( ) - self.buffer_write_times[ pid ] ).microseconds >= self.auto_flush_time:
self.flush( pid )
try:
if self.auto_flush_num >= 0 and len( self.buffers[ pid ] ) >= self.auto_flush_num:
self.flush( pid )
elif self.auto_flush_time >= 0 and ( datetime.datetime.now( ) - self.buffer_write_times[ pid ] ).microseconds >= self.auto_flush_time:
self.flush( pid )
except TypeError:
print('"' + pid + '"')
raise
# TODO: if buffer is not empty and we don't auto flush on write, sleep until a time then auto flush according to auto_flush_time
elif event == Console.MSG.FLUSH:
pid = data[ 1 ]

View File

@ -44,23 +44,25 @@ class P4SyncMissing:
def shutdown( data ):
return False
def sync( files ):
files_flat = ' '.join(files)
#subprocess.check_output( "p4 sync -f " + files_flat + "", shell=False, cwd=None )
files_flat = ' '.join('"' + f + '"' for f in files)
ret = -1
count = 0
while ret != 0 and count < 2:
ret = try_call_process( "p4 sync -f " + files_flat )
count += 1
if ret != 0 and not options.quiet:
c.write("Failed, trying again to sync " + files_flat)
if not options.quiet:
files_len = len(files)
if files_len > 1:
c.write( " Synced batch of " + str(len(files)) )
for f in files:
c.write( " Synced " + os.path.relpath( f, directory ) )
#if ret != 0 and not options.quiet:
# c.write("Failed, trying again to sync " + files_flat)
if ret != 0:
pass
#if not options.quiet:
# c.write("Failed to sync " + files_flat)
else:
if not options.quiet:
files_len = len(files)
if files_len > 1:
c.write( " Synced batch of " + str(len(files)) )
for f in files:
c.write( " Synced " + os.path.relpath( f, directory ) )
return True
commands = {
@ -116,7 +118,7 @@ class P4SyncMissing:
self.buckets = {}
self.buckets[file_type_text] = Bucket(10)
self.buckets[file_type_binary] = Bucket(2)
self.buckets[file_type_binary] = Bucket(1)
def push_queued(bucket):
if bucket.queue_size == 0: