Skip to content Skip to sidebar Skip to footer

I Seem To Get An Error Although The Script Runs, I Can't See Why

I have a piece of code here that copies a list of directories etc from a config file. It runs and copies the directories etc but it still errors each time it runs, can anyone help

Solution 1:

It seems like you have an empty line in your servicers.conf, may be at the end of file?

You can filter those in your code by checking:

fname = file_name.strip()
if fname:
    sourcefile = os.path.join(...)
    ...

Solution 2:

I would suggest checking to see if your destination directory exists before attempting to create it:

ifnotos.path.exists(destdir):
    os.makedirs(destdir)

Solution 3:

An easy way to fix this would be to delete the destination directory and then you are replacing it with the new directory anyway.

First check if the directory exists, if it does not make one.

Post a Comment for "I Seem To Get An Error Although The Script Runs, I Can't See Why"