File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -250,13 +250,20 @@ def parse_containerspec(containerspec):
250
250
user , name = name .split ("@" , 1 )
251
251
return name , user
252
252
253
- def get_encoding (self ):
254
- cmd = self .run ("python -c 'import locale;print(locale.getpreferredencoding())'" )
255
- if cmd .rc == 0 :
256
- encoding = cmd .stdout_bytes .splitlines ()[0 ].decode ("ascii" )
257
- else :
258
- # Python is not installed, we hope the encoding to be the same as
259
- # local machine...
253
+ def get_encoding (self ) -> str :
254
+ encoding = None
255
+ for python in ("python3" , "python" ):
256
+ cmd = self .run (
257
+ "%s -c 'import locale;print(locale.getpreferredencoding())'" ,
258
+ python ,
259
+ encoding = None ,
260
+ )
261
+ if cmd .rc == 0 :
262
+ encoding = cmd .stdout_bytes .splitlines ()[0 ].decode ("ascii" )
263
+ break
264
+ # Python is not installed, we hope the encoding to be the same as
265
+ # local machine...
266
+ if not encoding :
260
267
encoding = locale .getpreferredencoding ()
261
268
if encoding == "ANSI_X3.4-1968" :
262
269
# Workaround defaut encoding ascii without LANG set
You can’t perform that action at this time.
0 commit comments