def setUp(self): self.base_path = os.path.join(os.getcwd(), 'mock_downloads_dir') files.removeall(self.base_path) rarfile = pyunrar.RarFile(os.path.join(os.getcwd(), 'mock_downloads_dir.rar')) rarfile.extract(os.getcwd()) settings.DOWNLOADS_FOLDER = self.base_path settings.FOLDERS_MOVIES = os.path.join(os.getcwd(), 'target_folder', 'movies') settings.FOLDERS_TV_SHOWS = os.path.join(os.getcwd(), 'target_folder', 'shows') settings.VERBOSE = True files.removeall(settings.FOLDERS_MOVIES) files.removeall(settings.FOLDERS_TV_SHOWS)
def tearDown(self): files.removeall(self.base_path) os.rmdir(self.base_path)
if not d.is_old(): if settings.VERBOSE: print 'The directory is NOT old, aborting.' continue # we should take action if take_action: for path in files.find_all_files(execute_path): handler = None if path.is_interesting(): print "Is interesting", path handler = path.get_handler() print handler success = handler.execute() results.append(success) else: if settings.VERBOSE: print 'Did NOT take action' if False not in results and settings.DELETE_SOURCE_AFTER_ACTION or d.is_old(): print 'REMOVING', execute_path files.removeall(execute_path) if os.path.isfile(execute_path): os.remove(execute_path) else: os.rmdir(execute_path) # After we delete the "physical" directory, delete the representation in the Database directory.Directory.delete(d.id)