skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Backup filename check for deltat does not take into account path #171

Closed joernu76 closed 6 years ago

joernu76 commented 6 years ago

When supplying the Loader class with a directory on Windows 7, the renaming of deltat.preds fails:

File "C:\Users\icg173\Anaconda2\envs\python3\lib\site-packages\skyfield\iokit.py", line 159, in call os.rename(self.path_to(filename), self.path_to(backup_name)) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\icg173\.config\mss\deltat.preds' -> 'C:\Users\icg173\.config\mss\deltat.old1.preds'

The problem seems to be a missing "self.path_to" here: skyfield/iokit.py, line 156ff [...] if not os.path.exists(backup_name): break self._log(' Renaming to: {0}', backup_name) os.rename(self.path_to(filename), self.path_to(backup_name)) [...] should be changed to: [...] if not os.path.exists(self.path_to(backup_name)): [...]

I also end up with many backups after fixing it, but that seems to be related to issue #170

JoshPaterson commented 6 years ago

I also get this error on Windows 10.