我非常喜欢使用Google Slides作为云托管的轻量级插图画家替代品(也恰好是协作和免费的!).我在这里写了一些关于我的过程的想法:
我在工作流程中尝试做的是立即将演示文稿中的所有幻灯片作为图像下载?Google幻灯片用户界面只允许您一次下载每张幻灯片作为PNG吗?
这是否可能以某种方式使用附加组件或应用程序脚本?不知道从哪里开始...谢谢!
我每天都有一个cron工作来调用API并获取一些数据.对于数据的每一行,我启动一个任务队列来处理数据(这涉及通过其他API查找数据).一旦完成所有这些,我的数据在接下来的24小时内不会改变,所以我记得它.
有没有办法知道我排队的所有任务何时完成,以便我可以缓存数据?
目前我通过安排两个这样的cron作业以一种非常混乱的方式做到这一点:
class fetchdata(webapp.RequestHandler):
def get(self):
todaykey = str(date.today())
memcache.delete(todaykey)
topsyurl = 'http://otter.topsy.com/search.json?q=site:open.spotify.com/album&window=d&perpage=20'
f = urllib.urlopen(topsyurl)
response = f.read()
f.close()
d = simplejson.loads(response)
albums = d['response']['list']
for album in albums:
taskqueue.add(url='/spotifyapi/', params={'url':album['url'], 'score':album['score']})
class flushcache(webapp.RequestHandler):
def get(self):
todaykey = str(date.today())
memcache.delete(todaykey)
Run Code Online (Sandbox Code Playgroud)
然后我的cron.yaml看起来像这样:
- description: gettopsy
url: /fetchdata/
schedule: every day 01:00
timezone: Europe/London
- description: flushcache
url: /flushcache/
schedule: every day 01:05
timezone: Europe/London
Run Code Online (Sandbox Code Playgroud)
基本上 - 我猜测我的所有任务都不会花费超过5分钟的时间来运行,所以我只需要在5分钟后刷新缓存,这样可以确保数据缓存时完成.
有没有更好的编码方式?感觉像我的解决方案不是最好的....
谢谢汤姆
我是一个真正的编码n00b,如果这是一个简单或基本的问题,请道歉.
我正在编写Python,Webapp,Appengine.
我的问题是,在我写完页面之后是否可以继续工作?那是最好的办法吗?基本上,当有人在我的网站上创建一个列表(www.7bks.com)时,我想继续工作,对他们刚刚选择的书籍进行一些'后处理'.
目前我有类似的东西(伪代码!)
class InputList(webapp.RequestHandler):
def post(self):
#get books data from the post and put in datastore
list = List()
list = self.request.get('books')
list.put()
#redirect the user to the new list
self.redirect("http://www.7bks.com/list/&s" % list.id)
Run Code Online (Sandbox Code Playgroud)
现在,我想对列表中的每本书做一些缓慢的(涉及API调用)后期处理.我不想减慢重定向用户和生成列表页面的速度,因为我的后处理不会直接影响列表页面.我可以这样做吗?
class InputList(webapp.RequestHandler):
def post(self):
#get books data from the post and put in datastore
list = List()
list = self.request.get('books')
list.put()
#redirect the user to the new list
self.redirect("http://www.7bks.com/list/&s" % list.id)
#carry on working behind the scenes independently of the user
for book in …
Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码:
class Image(webapp.RequestHandler):
def get(self, id):
path = os.path.join(os.path.dirname(__file__), 'fcimages/%s.png' % id)
self.response.headers['Content-Type'] = 'image/png'
print file(path,'rb').read()
Run Code Online (Sandbox Code Playgroud)
它在本地工作正常(即返回图像),但当我在实时服务器上使用它时,我得到了垃圾.你可以在这里看到输出:http://1.ge0.co/fc/1.png
我究竟做错了什么?
谢谢!
PS - 我知道这不是最强大的代码,但它只用于我的内部项目,它不是按比例建立的.