mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	target: timestamp for capture_screen
Add an option to format an ISO8601 timestamp into the screenshot file name.
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							2a23c435d4
						
					
				
				
					commit
					8370c8fba3
				
			@@ -242,6 +242,11 @@ class Gem5SimulationPlatform(Platform):
 | 
				
			|||||||
            if '.bmp' in f:
 | 
					            if '.bmp' in f:
 | 
				
			||||||
                screen_caps.append(f)
 | 
					                screen_caps.append(f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if '{ts}' in filepath:
 | 
				
			||||||
 | 
					            cmd = '{} date -u -Iseconds'
 | 
				
			||||||
 | 
					            ts = self.target.execute(cmd.format(self.target.busybox)).strip()
 | 
				
			||||||
 | 
					            filepath = filepath.format(ts=ts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        successful_capture = False
 | 
					        successful_capture = False
 | 
				
			||||||
        if len(screen_caps) == 1:
 | 
					        if len(screen_caps) == 1:
 | 
				
			||||||
            # Bail out if we do not have image, and resort to the slower, built
 | 
					            # Bail out if we do not have image, and resort to the slower, built
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -905,7 +905,9 @@ class LinuxTarget(Target):
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            tmpfile = self.tempfile()
 | 
					            tmpfile = self.tempfile()
 | 
				
			||||||
            self.execute('DISPLAY=:0.0 scrot {}'.format(tmpfile))
 | 
					            cmd = 'DISPLAY=:0.0 scrot {} && {} date -u -Iseconds'
 | 
				
			||||||
 | 
					            ts = self.execute(cmd.format(tmpfile, self.busybox)).strip()
 | 
				
			||||||
 | 
					            filepath = filepath.format(ts=ts)
 | 
				
			||||||
            self.pull(tmpfile, filepath)
 | 
					            self.pull(tmpfile, filepath)
 | 
				
			||||||
            self.remove(tmpfile)
 | 
					            self.remove(tmpfile)
 | 
				
			||||||
        except TargetError as e:
 | 
					        except TargetError as e:
 | 
				
			||||||
@@ -1144,7 +1146,9 @@ class AndroidTarget(Target):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def capture_screen(self, filepath):
 | 
					    def capture_screen(self, filepath):
 | 
				
			||||||
        on_device_file = self.path.join(self.working_directory, 'screen_capture.png')
 | 
					        on_device_file = self.path.join(self.working_directory, 'screen_capture.png')
 | 
				
			||||||
        self.execute('screencap -p  {}'.format(on_device_file))
 | 
					        cmd = 'screencap -p  {} && {} date -u -Iseconds'
 | 
				
			||||||
 | 
					        ts = self.execute(cmd.format(on_device_file, self.busybox)).strip()
 | 
				
			||||||
 | 
					        filepath = filepath.format(ts=ts)
 | 
				
			||||||
        self.pull(on_device_file, filepath)
 | 
					        self.pull(on_device_file, filepath)
 | 
				
			||||||
        self.remove(on_device_file)
 | 
					        self.remove(on_device_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user