esturdivant-usgs / science-base-automation

Automating large USGS ScienceBase data releases
4 stars 2 forks source link

rename_dirs_from_xmls fails because of illegal characters #70

Open esturdivant-usgs opened 5 years ago

esturdivant-usgs commented 5 years ago

When running on the Windows, os.rename throws OSError with illegal characters. Here it was caused by a line break (\n).

Error report:

Traceback (most recent call last):
  File "sb_automation.py", line 92, in <module>
    rename_dirs_from_xmls(parentdir)
  File "C:\Users\emontgomery\python_progs\science-base-automation\autoSB.py", line 544, in rename_dirs_from_xmls
    os.rename(datadir, os.path.join(basedir, data_title))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'D:\\sandwich2016' -> 'D:\\Geotagged Low-Altitude Aerial Imagery From Unmanned Aerial Systems Flights Over Town Neck Beach, in Sandwich, Massachusetts, on March 30, 2016\n        '
esturdivant-usgs commented 5 years ago

Added a stop-gap fix in commit 8f0df01a32c06d02bacefcfc9dfba280a0692fac

esturdivant-usgs commented 5 years ago

from Ellyn:

I put the closing title tag on the same line, so there's no \n, yet it's still choking in a similar way:

(sb_py3) C:\Users\emontgomery\python_progs\science-base-automation>python sb_automation.py
ScienceBase password:
Traceback (most recent call last):
  File "sb_automation.py", line 92, in <module>
    rename_dirs_from_xmls(parentdir)
  File "C:\Users\emontgomery\python_progs\science-base-automation\autoSB.py", line 545, in rename_dirs_from_xmls
    os.rename(datadir, os.path.join(basedir, data_title))
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\sandwich2016_forSB\\gcp' -> 'D:\\sandwich2016_forSB\\ Surveyed Positions of Ground Control Points Associated With Images Collected During Unmanned Aerial Systems Flights Over Town Neck Beach, in Sandwich, Massachusetts on January 22, January 25, February 11, March 30, and September 21, 2016'

At least now it's in a sub dir when it fails... It seems to have the 'gcp' to the left of the ->, but has lost the 'gcp' at the right, so no wonder it can't find the path. Looks like it's not assembling the path_with_subdir correctly...