mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-26 01:01:53 +00:00
Fixed directory names for the survey scans such that surveys could be found. It did not seem possible to simply change the localsettings.py file to get it to work.
This commit is contained in:
parent
70a743f88b
commit
484f8f76cc
@ -87,15 +87,15 @@ def listdir(*directories):
|
|||||||
return [folder.rstrip(r"/") for folder in folders]
|
return [folder.rstrip(r"/") for folder in folders]
|
||||||
|
|
||||||
# add survey scans
|
# add survey scans
|
||||||
def parseSurveyScans(year, logfile=None):
|
def parseSurveyScans(expedition, logfile=None):
|
||||||
# yearFileList = listdir(year.year)
|
# yearFileList = listdir(expedition.year)
|
||||||
yearPath=os.path.join(settings.SURVEY_SCANS, year.year)
|
yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year)
|
||||||
yearFileList=os.listdir(yearPath)
|
yearFileList=os.listdir(yearPath)
|
||||||
print yearFileList
|
print yearFileList
|
||||||
for surveyFolder in yearFileList:
|
for surveyFolder in yearFileList:
|
||||||
try:
|
try:
|
||||||
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
|
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
|
||||||
# scanList = listdir(year.year, surveyFolder)
|
# scanList = listdir(expedition.year, surveyFolder)
|
||||||
scanList=os.listdir(os.path.join(yearPath,surveyFolder))
|
scanList=os.listdir(os.path.join(yearPath,surveyFolder))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print surveyFolder + " ignored",
|
print surveyFolder + " ignored",
|
||||||
@ -117,13 +117,13 @@ def parseSurveyScans(year, logfile=None):
|
|||||||
if type(surveyNumber)==types.TupleType:
|
if type(surveyNumber)==types.TupleType:
|
||||||
surveyNumber=surveyNumber[0]
|
surveyNumber=surveyNumber[0]
|
||||||
try:
|
try:
|
||||||
placeholder=get_or_create_placeholder(year=int(year.year))
|
placeholder=get_or_create_placeholder(year=int(expedition.year))
|
||||||
survey=Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=year, defaults={'logbook_entry':placeholder})[0]
|
survey=Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=expedition, defaults={'logbook_entry':placeholder})[0]
|
||||||
except Survey.MultipleObjectsReturned:
|
except Survey.MultipleObjectsReturned:
|
||||||
survey=Survey.objects.filter(wallet_number=surveyNumber, expedition=year)[0]
|
survey=Survey.objects.filter(wallet_number=surveyNumber, expedition=expedition)[0]
|
||||||
file=os.path.join(year.year, surveyFolder, scan)
|
file_=os.path.join(yearPath, surveyFolder, scan)
|
||||||
scanObj = ScannedImage(
|
scanObj = ScannedImage(
|
||||||
file=file,
|
file=file_,
|
||||||
contents=scanType,
|
contents=scanType,
|
||||||
number_in_wallet=scanNumber,
|
number_in_wallet=scanNumber,
|
||||||
survey=survey,
|
survey=survey,
|
||||||
@ -131,16 +131,16 @@ def parseSurveyScans(year, logfile=None):
|
|||||||
)
|
)
|
||||||
#print "Added scanned image at " + str(scanObj)
|
#print "Added scanned image at " + str(scanObj)
|
||||||
if scanFormat=="png":
|
if scanFormat=="png":
|
||||||
if isInterlacedPNG(os.path.join(settings.SURVEY_SCANS,file)):
|
if isInterlacedPNG(os.path.join(settings.SURVEY_SCANS, "surveyscans", file_)):
|
||||||
print file + " is an interlaced PNG. No can do."
|
print file_+ " is an interlaced PNG. No can do."
|
||||||
continue
|
continue
|
||||||
scanObj.save()
|
scanObj.save()
|
||||||
|
|
||||||
# dead
|
# dead
|
||||||
def parseSurveys(logfile=None):
|
def parseSurveys(logfile=None):
|
||||||
readSurveysFromCSV()
|
readSurveysFromCSV()
|
||||||
for year in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
|
for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
|
||||||
parseSurveyScans(year)
|
parseSurveyScans(expedition)
|
||||||
|
|
||||||
# dead
|
# dead
|
||||||
def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL)
|
def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL)
|
||||||
|
Loading…
Reference in New Issue
Block a user