@@ -88,7 +88,7 @@ def run_command(self, cmd, suppress_message=False, return_output=False):
88
88
if not suppress_message :
89
89
self .info (decoded_output )
90
90
full_output += decoded_output
91
- except Exception as err : # pylint: disable=broad-except
91
+ except Exception : # pylint: disable=broad-except
92
92
pass
93
93
finally :
94
94
sys .stdout = original_stdout
@@ -294,7 +294,7 @@ def pattern_search(self, location, pattern, multi_line=False):
294
294
295
295
if self .exists (location ) and not self .isdir (location ):
296
296
if multi_line :
297
- with open (location , "r+" ) as file :
297
+ with open (location , "r+" , encoding = "utf-8" ) as file :
298
298
if re .search (pattern , file .read (), flags = re .DOTALL ):
299
299
found = True
300
300
else :
@@ -315,7 +315,7 @@ def pattern_replace(self, location, pattern, replace="", multi_line=False):
315
315
if self .pattern_search (location , pattern , multi_line ):
316
316
if multi_line :
317
317
regex = re .compile (pattern , flags = re .DOTALL )
318
- with open (location , "r+" ) as file :
318
+ with open (location , "r+" , encoding = "utf-8" ) as file :
319
319
data = file .read ()
320
320
file .seek (0 )
321
321
file .write (regex .sub (replace , data ))
@@ -397,7 +397,7 @@ def write_text_file(self, path, content, append=True):
397
397
content = "\n " + content
398
398
else :
399
399
mode = "w"
400
- with open (self .path (path ), mode ) as service_file :
400
+ with open (self .path (path ), mode , encoding = "utf-8" ) as service_file :
401
401
service_file .write (content )
402
402
403
403
@staticmethod
@@ -468,11 +468,11 @@ def get_os(self):
468
468
)
469
469
release = None
470
470
if os .path .exists ("/etc/os-release" ):
471
- with open ("/etc/os-release" ) as f :
471
+ with open ("/etc/os-release" , encoding = "utf-8" ) as f :
472
472
if "Raspbian" in f .read ():
473
473
release = "Raspbian"
474
474
if self .run_command ("command -v apt-get" , suppress_message = True ):
475
- with open ("/etc/os-release" ) as f :
475
+ with open ("/etc/os-release" , encoding = "utf-8" ) as f :
476
476
release_file = f .read ()
477
477
for opsys in os_releases :
478
478
if opsys in release_file :
@@ -495,7 +495,7 @@ def get_raspbian_version(self):
495
495
return None
496
496
raspbian_releases = ("buster" , "stretch" , "jessie" , "wheezy" )
497
497
if os .path .exists ("/etc/os-release" ):
498
- with open ("/etc/os-release" ) as f :
498
+ with open ("/etc/os-release" , encoding = "utf-8" ) as f :
499
499
release_file = f .read ()
500
500
if "/sid" in release_file :
501
501
return "unstable"
0 commit comments