Every line of 'python delete folder and contents' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
137 def delete_folder_contents(mpf_home, delete_uploaded_media, delete_logs, mpf_log_path): 138 mpf_share_dir = os.path.join(mpf_home, 'share') 139 for folder in ALWAYS_DELETE_FOLDERS: 140 delete_children(os.path.join(mpf_share_dir, folder)) 141 if delete_uploaded_media: 142 delete_children(os.path.join(mpf_share_dir, 'remote-media')) 143 if delete_logs: 144 delete_children(mpf_log_path)
116 def delete_folder(dst): 117 """ 118 Delete a folder from S3. 119 """ 120 s3 = boto.connect_s3() 121 122 bucket = s3.get_bucket(app_config.S3_BUCKET['bucket_name']) 123 124 for key in bucket.list(prefix='%s/' % dst): 125 print 'Deleting %s' % (key.key) 126 127 key.delete()
47 def delete_files(file_name): 48 ''' 49 Common function to delete generated temporary files 50 ''' 51 my_dir = "./" 52 for fname in os.listdir(my_dir): 53 if fname.startswith(file_name): 54 os.remove(os.path.join(my_dir, fname))
125 @staticmethod 126 def clear_dir(folder: str) -> None: 127 import os, shutil 128 for the_file in os.listdir(folder): 129 file_path = os.path.join(folder, the_file) 130 try: 131 if os.path.isfile(file_path): 132 os.unlink(file_path) 133 # elif os.path.isdir(file_path): shutil.rmtree(file_path) 134 except Exception as e: 135 print(e)
599 def delete(self, path): 600 """Delete a file/directory and any associated checkpoints.""" 601 self.delete_file(path, allow_non_empty=True)