(self)
Create a backup in /tmp
Create a backup in /tmp
Create a backup in / tmp
def create(self):
        """Create a backup in /tmp"""
        if not os.path.exists(self.local_path):
            return
        if os.path.exists(self.backup_path):
            shutil.rmtree(self.backup_path)
            while os.path.exists(self.backup_path):
                sleep(0.1)
        os.makedirs(self.backup_path, exist_ok=True)

        try:
            if os.path.isfile(self.local_path):
                shutil.copyfile(self.local_path, self.backup_path_full)
                os.remove(self.local_path)
            else:
                shutil.copytree(self.local_path, self.backup_path_full)
                shutil.rmtree(self.local_path)
                while os.path.exists(self.local_path):
                    sleep(0.1)
            self.logger.debug(
                f"Backup for {self.local_path}, created in {self.backup_path_full}"
            )
        except Exception:  # pylint: disable=broad-except
            pass
def create ( self ) : if not os . path . exists ( self . local_path ) : return if os . path . exists ( self . backup_path ) : shutil . rmtree ( self . backup_path ) while os . path . exists ( self . backup_path ) : sleep ( 0.1 ) os . makedirs ( self . backup_path , exist_ok = True ) try : if os . path . isfile ( self . local_path ) : shutil . copyfile ( self . local_path , self . backup_path_full ) os . remove ( self . local_path ) else : shutil . copytree ( self . local_path , self . backup_path_full ) shutil . rmtree ( self . local_path ) while os . path . exists ( self . local_path ) : sleep ( 0.1 ) self . logger . debug ( f"Backup for {self.local_path}, created in {self.backup_path_full}" ) except Exception : # pylint: disable=broad-except pass