#NEWLINE# def get_deployment_lock( error_rerun_script ) : #NEWLINE# #INDENT# start_time = time . time ( ) #NEWLINE# got_lock = False #NEWLINE# while ( ( time . time ( ) - start_time ) < 300 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . mkdir ( LOCK_DIR ) #NEWLINE# got_lock = True #NEWLINE# break #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# print ( ( ( WARNING + ( 'Another deployment in progress; waiting for lock... (If no deployment is running, rmdir %s)' % ( LOCK_DIR , ) ) ) + ENDC ) ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# time . sleep ( 3 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not got_lock ) : #NEWLINE# #INDENT# print ( ( ( ( ( ( ( FAIL + 'Deployment already in progress.  Please run\n' ) + ( '  %s\n' % ( start_time , ) ) ) + 'manually when the previous deployment finishes, or run\n' ) + ( '  rmdir %s\n' % ( LOCK_DIR , ) ) ) + 'if the previous deployment crashed.' ) + ENDC ) ) #NEWLINE# sys . exit ( 1 )