| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -245,19 +245,31 @@ class Hook(object):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if cmd[0] == 'vpython' and _detect_host_os() == 'win':
 | 
					 | 
					 | 
					 | 
					    if cmd[0] == 'vpython' and _detect_host_os() == 'win':
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      cmd[0] += '.bat'
 | 
					 | 
					 | 
					 | 
					      cmd[0] += '.bat'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    exit_code = 2
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    try:
 | 
					 | 
					 | 
					 | 
					    try:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      start_time = time.time()
 | 
					 | 
					 | 
					 | 
					      start_time = time.time()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      gclient_utils.CheckCallAndFilter(
 | 
					 | 
					 | 
					 | 
					      gclient_utils.CheckCallAndFilter(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          cmd, cwd=self.effective_cwd, print_stdout=True, show_header=True,
 | 
					 | 
					 | 
					 | 
					          cmd, cwd=self.effective_cwd, print_stdout=True, show_header=True,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          always_show_header=self._verbose)
 | 
					 | 
					 | 
					 | 
					          always_show_header=self._verbose)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      exit_code = 0
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    except (gclient_utils.Error, subprocess2.CalledProcessError) as e:
 | 
					 | 
					 | 
					 | 
					    except (gclient_utils.Error, subprocess2.CalledProcessError) as e:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # Use a discrete exit status code of 2 to indicate that a hook action
 | 
					 | 
					 | 
					 | 
					      # Use a discrete exit status code of 2 to indicate that a hook action
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # failed.  Users of this script may wish to treat hook action failures
 | 
					 | 
					 | 
					 | 
					      # failed.  Users of this script may wish to treat hook action failures
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # differently from VC failures.
 | 
					 | 
					 | 
					 | 
					      # differently from VC failures.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      print('Error: %s' % str(e), file=sys.stderr)
 | 
					 | 
					 | 
					 | 
					      print('Error: %s' % str(e), file=sys.stderr)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      sys.exit(2)
 | 
					 | 
					 | 
					 | 
					      sys.exit(exit_code)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    finally:
 | 
					 | 
					 | 
					 | 
					    finally:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      elapsed_time = time.time() - start_time
 | 
					 | 
					 | 
					 | 
					      elapsed_time = time.time() - start_time
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      metrics.collector.add_repeated('hooks', {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'action': gclient_utils.CommandToStr(cmd),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'name': self._name,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'cwd': os.path.relpath(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            os.path.normpath(self.effective_cwd),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            self._cwd_base),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'condition': self._condition,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'execution_time': elapsed_time,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        'exit_code': exit_code,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if elapsed_time > 10:
 | 
					 | 
					 | 
					 | 
					      if elapsed_time > 10:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        print("Hook '%s' took %.2f secs" % (
 | 
					 | 
					 | 
					 | 
					        print("Hook '%s' took %.2f secs" % (
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            gclient_utils.CommandToStr(cmd), elapsed_time))
 | 
					 | 
					 | 
					 | 
					            gclient_utils.CommandToStr(cmd), elapsed_time))
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |