forked from ungleich-public/cdist
		
	catch unicodedecodeerror
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								c64ab97f2a
							
						
					
				
			
			
				commit
				
					
						ad1e51cb2e
					
				
			
		
					 1 changed files with 9 additions and 0 deletions
				
			
		|  | @ -40,6 +40,13 @@ class RemoteScriptError(cdist.Error): | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "Remote script execution failed: %s %s" % (self.script, self.command) |         return "Remote script execution failed: %s %s" % (self.script, self.command) | ||||||
| 
 | 
 | ||||||
|  | class DecodeError(cdist.Error): | ||||||
|  |     def __init__(self, command): | ||||||
|  |         self.command = command | ||||||
|  | 
 | ||||||
|  |     def __str__(self): | ||||||
|  |         return "Cannot decode output of " + " ".join(self.command) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class Remote(object): | class Remote(object): | ||||||
|     """Execute commands remotely. |     """Execute commands remotely. | ||||||
|  | @ -121,6 +128,8 @@ class Remote(object): | ||||||
|             raise cdist.Error("Command failed: " + " ".join(command)) |             raise cdist.Error("Command failed: " + " ".join(command)) | ||||||
|         except OSError as error: |         except OSError as error: | ||||||
|             raise cdist.Error(" ".join(*args) + ": " + error.args[1]) |             raise cdist.Error(" ".join(*args) + ": " + error.args[1]) | ||||||
|  |         except UnicodeDecodeError: | ||||||
|  |             raise DecodeError(command) | ||||||
| 
 | 
 | ||||||
|     def run_script(self, script, env=None, return_output=False): |     def run_script(self, script, env=None, return_output=False): | ||||||
|         """Run the given script with the given environment on the remote side. |         """Run the given script with the given environment on the remote side. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue