@@ -378,6 +378,8 @@ def chmod(self, location, mode):
378378 Change the permissions of a file or directory
379379 """
380380 location = self .path (location )
381+ if not 0 <= mode <= 0o777 :
382+ raise ValueError ("Invalid mode value" )
381383 if os .path .exists (location ):
382384 os .chmod (location , mode )
383385
@@ -392,7 +394,11 @@ def chown(self, location, user, group=None, recursive=False):
392394 if recursive and os .path .isdir (location ):
393395 for root , dirs , files in os .walk (location ):
394396 for directory in dirs :
395- shutil .chown (os .path .join (root , directory ), user , group )
397+ shutil .chown (
398+ os .path .join (root , directory ),
399+ user ,
400+ group ,
401+ )
396402 for file in files :
397403 shutil .chown (os .path .join (root , file ), user , group )
398404 else :
@@ -501,6 +507,10 @@ def get_os(self):
501507 with open ("/etc/os-release" , encoding = "utf-8" ) as f :
502508 if "Raspbian" in f .read ():
503509 release = "Raspbian"
510+ if self .exists ("/etc/rpi-issue" ):
511+ with open ("/etc/rpi-issue" , encoding = "utf-8" ) as f :
512+ if "Raspberry Pi" in f .read ():
513+ release = "Raspbian"
504514 if self .run_command ("command -v apt-get" , suppress_message = True ):
505515 with open ("/etc/os-release" , encoding = "utf-8" ) as f :
506516 release_file = f .read ()
@@ -555,6 +565,12 @@ def check_kernel_update_reboot_required(self):
555565
556566 # pylint: enable=invalid-name
557567
568+ def is_raspberry_pi_os (self ):
569+ """
570+ Check if we are running Raspberry Pi OS or Raspbian
571+ """
572+ return self .get_os () == "Raspbian"
573+
558574 @staticmethod
559575 def is_raspberry_pi ():
560576 """
0 commit comments