@@ -378,6 +378,8 @@ def chmod(self, location, mode):
378
378
Change the permissions of a file or directory
379
379
"""
380
380
location = self .path (location )
381
+ if not 0 <= mode <= 0o777 :
382
+ raise ValueError ("Invalid mode value" )
381
383
if os .path .exists (location ):
382
384
os .chmod (location , mode )
383
385
@@ -392,7 +394,11 @@ def chown(self, location, user, group=None, recursive=False):
392
394
if recursive and os .path .isdir (location ):
393
395
for root , dirs , files in os .walk (location ):
394
396
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
+ )
396
402
for file in files :
397
403
shutil .chown (os .path .join (root , file ), user , group )
398
404
else :
@@ -501,6 +507,10 @@ def get_os(self):
501
507
with open ("/etc/os-release" , encoding = "utf-8" ) as f :
502
508
if "Raspbian" in f .read ():
503
509
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"
504
514
if self .run_command ("command -v apt-get" , suppress_message = True ):
505
515
with open ("/etc/os-release" , encoding = "utf-8" ) as f :
506
516
release_file = f .read ()
@@ -555,6 +565,12 @@ def check_kernel_update_reboot_required(self):
555
565
556
566
# pylint: enable=invalid-name
557
567
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
+
558
574
@staticmethod
559
575
def is_raspberry_pi ():
560
576
"""
0 commit comments