Fixed bug in p4SyncMissingFiles.py. Also fixed bug in p4Helper when
running p4RemoveUnversioned.py.
This commit is contained in:
parent
c32c0bfbd1
commit
ea14f96d76
35
p4Helper.py
35
p4Helper.py
|
@ -85,7 +85,7 @@ def call_process( args ):
|
||||||
|
|
||||||
def try_call_process( args, path=None ):
|
def try_call_process( args, path=None ):
|
||||||
try:
|
try:
|
||||||
subprocess.check_output( args.split( ), shell=False, cwd=path )
|
subprocess.check_output( args.split( ), shell=False, cwd=path, stderr=subprocess.STDOUT )
|
||||||
return 0
|
return 0
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return 1
|
return 1
|
||||||
|
@ -204,7 +204,7 @@ class P4Workspace:
|
||||||
#print("\nChecking p4 info...")
|
#print("\nChecking p4 info...")
|
||||||
result = get_p4_py_results('info')
|
result = get_p4_py_results('info')
|
||||||
if len(result) == 0 or b'userName' not in result[0].keys():
|
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)
|
sys.exit(1)
|
||||||
username = get_str_from_process_stdout(result[0][b'userName'])
|
username = get_str_from_process_stdout(result[0][b'userName'])
|
||||||
client_host = get_str_from_process_stdout(result[0][b'clientHost'])
|
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.auto_flush_time = auto_flush_time * 1000 if auto_flush_time is not None else -1
|
||||||
self.shutting_down = False
|
self.shutting_down = False
|
||||||
|
|
||||||
def write( self, data ):
|
def write( self, data, pid = None ):
|
||||||
self.queue.put( ( Console.MSG.WRITE, threading.current_thread().ident, data ) )
|
pid = pid if pid is not None else threading.current_thread().ident
|
||||||
|
self.queue.put( ( Console.MSG.WRITE, pid, data ) )
|
||||||
|
|
||||||
def writeflush( self, data ):
|
def writeflush( self, data, pid = None ):
|
||||||
pid = threading.current_thread().ident
|
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.WRITE, pid, data ) )
|
||||||
self.queue.put( ( Console.MSG.FLUSH, pid ) )
|
self.queue.put( ( Console.MSG.FLUSH, pid ) )
|
||||||
|
|
||||||
def flush( self ):
|
def flush( self, pid = None ):
|
||||||
self.queue.put( ( Console.MSG.FLUSH, threading.current_thread().ident ) )
|
pid = pid if pid is not None else threading.current_thread().ident
|
||||||
|
self.queue.put( ( Console.MSG.FLUSH, pid ) )
|
||||||
|
|
||||||
def clear( self ):
|
def clear( self, pid = None ):
|
||||||
self.queue.put( ( Console.MSG.CLEAR, threading.current_thread().ident ) )
|
pid = pid if pid is not None else threading.current_thread().ident
|
||||||
|
self.queue.put( ( Console.MSG.CLEAR, pid ) )
|
||||||
|
|
||||||
def __enter__( self ):
|
def __enter__( self ):
|
||||||
self.start( )
|
self.start( )
|
||||||
|
@ -342,10 +345,14 @@ class Console( threading.Thread ):
|
||||||
self.buffer_write_times[ pid ] = datetime.datetime.now( )
|
self.buffer_write_times[ pid ] = datetime.datetime.now( )
|
||||||
self.buffers[ pid ].append( s )
|
self.buffers[ pid ].append( s )
|
||||||
|
|
||||||
if self.auto_flush_num >= 0 and len( self.buffers[ pid ] ) >= self.auto_flush_num:
|
try:
|
||||||
self.flush( pid )
|
if self.auto_flush_num >= 0 and len( self.buffers[ pid ] ) >= self.auto_flush_num:
|
||||||
elif self.auto_flush_time >= 0 and ( datetime.datetime.now( ) - self.buffer_write_times[ pid ] ).microseconds >= self.auto_flush_time:
|
self.flush( pid )
|
||||||
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
|
# 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:
|
elif event == Console.MSG.FLUSH:
|
||||||
pid = data[ 1 ]
|
pid = data[ 1 ]
|
||||||
|
|
|
@ -44,23 +44,25 @@ class P4SyncMissing:
|
||||||
def shutdown( data ):
|
def shutdown( data ):
|
||||||
return False
|
return False
|
||||||
def sync( files ):
|
def sync( files ):
|
||||||
files_flat = ' '.join(files)
|
files_flat = ' '.join('"' + f + '"' for f in files)
|
||||||
#subprocess.check_output( "p4 sync -f " + files_flat + "", shell=False, cwd=None )
|
|
||||||
ret = -1
|
ret = -1
|
||||||
count = 0
|
count = 0
|
||||||
while ret != 0 and count < 2:
|
while ret != 0 and count < 2:
|
||||||
ret = try_call_process( "p4 sync -f " + files_flat )
|
ret = try_call_process( "p4 sync -f " + files_flat )
|
||||||
count += 1
|
count += 1
|
||||||
if ret != 0 and not options.quiet:
|
#if ret != 0 and not options.quiet:
|
||||||
c.write("Failed, trying again to sync " + files_flat)
|
# c.write("Failed, trying again to sync " + files_flat)
|
||||||
|
if ret != 0:
|
||||||
|
pass
|
||||||
if not options.quiet:
|
#if not options.quiet:
|
||||||
files_len = len(files)
|
# c.write("Failed to sync " + files_flat)
|
||||||
if files_len > 1:
|
else:
|
||||||
c.write( " Synced batch of " + str(len(files)) )
|
if not options.quiet:
|
||||||
for f in files:
|
files_len = len(files)
|
||||||
c.write( " Synced " + os.path.relpath( f, directory ) )
|
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
|
return True
|
||||||
|
|
||||||
commands = {
|
commands = {
|
||||||
|
@ -116,7 +118,7 @@ class P4SyncMissing:
|
||||||
|
|
||||||
self.buckets = {}
|
self.buckets = {}
|
||||||
self.buckets[file_type_text] = Bucket(10)
|
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):
|
def push_queued(bucket):
|
||||||
if bucket.queue_size == 0:
|
if bucket.queue_size == 0:
|
||||||
|
|
Loading…
Reference in New Issue