.txt 파일을 가져와 파일 내의 위치를 찾고 Yahoo Placemaker를 사용하여 .txt 파일을 나타내는지도를 제작자에게 플로팅하는 Google AppEngine Project를 만들었습니다 .속성 lat는 내 대시 보드에 표시되는 부동 소수점이어야합니다.
이BadValueError: Property lat must be a float
내 main.py는 다음과 같습니다 :
class Story(db.Model):
id = db.StringProperty()
loc_name = db.StringProperty()
title = db.StringProperty()
lat = db.FloatProperty()
long = db.FloatProperty()
link = db.StringProperty()
class MyStories(webapp.RequestHandler):
def get(self):
temp = db.Query(Story)
temp = temp.count()
story_set = Story.all()
template_values = {
'storyTemp': story_set
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
class place(webapp.RequestHandler):
def get(self):
path = '/Users/kimmasterson/storing/txtFiles'
try:
for infile in glob.glob(os.path.join(path, '*.txt')):
#print infile
f = open(infile, 'r')
data = f.read()
newfile = infile.replace('.txt', '')
newfile = newfile.replace('/Users/kimmasterson/storing/txtFiles/', '')
#print newfile
storyname = 'http://www.independent.ie/national-news/' + newfile
#print storyname
#print newfile
#logging.info(data)
p = placemaker('HSnG9pPV34EUBcexz.tDYuSrZ8Hnp.LowswI7TxreF8sXrdpVyVIKB4uPGXBYOA9VjjF1Ca42ipd_KhdJsKYjI5cXRo0eJM-')
print p.find_places(data)
for place in p.places:
splitted = place.name.split()
for word in splitted:
temp = db.Query(Story)
temp = temp.filter("link = ", storyname)
results = temp.fetch(limit=1)
if len(results) >0:
break
elif 'IE' in word:
print temp
print 'success'
story = Story(name=newfile, lat=place.centroid.latitude, long=place.centroid.longitude, link=storyname, loc_name = place.name, title = newfile).put()
except:
print 'error'
logging.info('BIG FAT ERROR')
def main():
application = webapp.WSGIApplication([('/', MyStories), ('/place', place)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
내 크론 내 로컬 호스트에서의 실행하지만 난 시도하고 appspot에 업로드 할 때 오류가 발생하는 경우 이 프로젝트는 잘 작동 .yaml :
cron:
- description: running place
url: /place
schedule: every day 10:00
어떤 이유로 나는 장소를 추가하고 파일을 내 로컬 호스트의지도에 연결합니다. 두 곳의 동일한 코드가 어떻게 다른 곳에서 작동 할 수 있는지에 대한 아이디어가 있습니까?
오류는 사라졌지 만 맵에는 마커가 나타나지 않습니다. 이 코드 줄을 main.py : path = os.path.join (os.path.dirname (__ file __), '/ Users/kimmasterson/저장/txtFiles')에 추가했습니다. 메인에 어딘가에 있습니다. 그것이 배치되어야하는 .py 즉 : 상단에? – jenniem001
@ jenniem001 앱에서 하드 드라이브의 파일을 계속 참조하려고합니다. '/ Users/kimmasterson'은 프로덕션 서버에 존재하지 않습니다. app.yaml과 같은 디렉토리에 파일을 놓은 다음 위의 경로로 'txtFiles'를 사용하면됩니다. –
path = os.path.join (os.path.dirname (__ file__), '/ storage/txtFiles') 오류 로그가없고 내 cron이 성공적으로 실행 중입니다. 그러나 나는 아직 어떤 표식도 가지고 있지 않다. 내가 뭔가 잘못하고 있는거야? 이것은 내 로그입니다 : "이 요청으로 인해 새 프로세스가 시작되어 응용 프로그램 코드가 처음으로로드되었습니다. 따라서이 요청은 일반적인 요청보다 더 오래 걸리고 CPU 사용량이 많을 수 있습니다 신청." 그러나 나는 기다렸으며 내지도에는 마커가 없습니다. – jenniem001