Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Delete directories in folder is not working after folder is updated
#1
So I'm having an automated test that is deleting all the projects inside Projects folder.


folder = myPath\Projects\Project1
                         Project2
 

The test executes like this:

deleteProjectsFromFolder,createNewProject,deleteProjectsFromFolder


The code for deleteProjectsFromFolder is this:

        for the_file in os.listdir(folder):
            file_path = os.path.join(folder, the_file)
            try:
                if os.path.isfile(file_path):
                    os.unlink(file_path)
                elif os.path.isdir(file_path): shutil.rmtree(file_path)
            except Exception as e:
                print(e)
First delete projects from folder works but the second one after new project is created does not delete the directories(projects) anymore. What should I do in this case?Are there some other solutions for this?
Quote
#2
Show more of the code. The problem is likely originating elsewhere.
Quote
#3
I guess everything else is related to the automation framework itself. The problem I guess the program sits in that directory and after the folder is updated it does not know anymore to execute delete(folder) again.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Delete Lines that Contain Words - Loop through files in a folder - Write to new files dj99 3 189 Yesterday, 06:34 AM
Last Post: heiner55
  delete a file after closing it mcgrim 1 57 May-14-2019, 08:16 PM
Last Post: Larz60+
  Accessing files in various directories and folders ccuny 2 58 May-08-2019, 12:11 PM
Last Post: ccuny
  Read a folder with a multiple files NewBeie 7 141 May-06-2019, 08:04 AM
Last Post: NewBeie
  folder PyQt5 created during creation exe atlass218 0 71 Apr-26-2019, 06:25 PM
Last Post: atlass218
  Opening Directories on anothe File System mickrobinson567812 2 122 Apr-25-2019, 04:59 AM
Last Post: mickrobinson567812
  How to list number of times element is in defaultdict and delete it mrapple2020 3 105 Apr-15-2019, 07:34 AM
Last Post: perfringo
  Smartsheet api data using python into folder dspy9 0 89 Apr-04-2019, 07:30 PM
Last Post: dspy9
  Including classes from folder issue graham23s 1 126 Apr-03-2019, 07:33 AM
Last Post: Gribouillis
  Why doesn't gc delete an object without forcing a garbage collection call? AlekseyPython 5 237 Mar-19-2019, 02:10 AM
Last Post: micseydel

Forum Jump:


Users browsing this thread: 1 Guest(s)