How to run another python code in backgroud with flask

@app.route('/result/<case_id>') def result(case_id): USER_FOLDER = os.path.join(UPLOAD_FOLDER + '/' + Case_ID) Analysis_code.main(USER_FOLDER, Case_ID, Case_ID + '_mRNA_file.txt', Case_ID + '_lncRNA_file.txt', Case_ID + '_miRNA_file.txt') return render_template('test.html',case_id=Case_ID) In my this result route, I call a function that are from another file.But wh

如何在烧瓶背景中运行另一个python代码

@app.route('/result/<case_id>') def result(case_id): USER_FOLDER = os.path.join(UPLOAD_FOLDER + '/' + Case_ID) Analysis_code.main(USER_FOLDER, Case_ID, Case_ID + '_mRNA_file.txt', Case_ID + '_lncRNA_file.txt', Case_ID + '_miRNA_file.txt') return render_template('test.html',case_id=Case_ID) 在我的这个结果路径中,我调用了来自另一个文件的函数。但是当flask执行Analysis

template won't work on Heroku

EDIT: I think it might be related to the comments posted here Let me also add that I did not push this up in a virtualenv because I have anaconda installed for Ipython and supposedly those don't play nice together... This is another possible root of the problem I'm attempting to deploy a flask app that runs fine locally and on foreman but gives a 500 error when deployed on heroku. It

模板在Heroku上不起作用

编辑:我想这可能与这里发布的评论有关 我还要补充一点,我没有在virtualenv中推动它,因为我为Ipython安装了anaconda,并且据说它们在一起玩的不好......这是另一个可能的问题根源 我正在尝试部署一个在本地和工头上运行良好的烧瓶应用程序,但在部署到heroku时会出现500错误。 它连接到我的数据库并打印任何我告诉它,直到render_template在我的初始方法。 这是我的堆栈跟踪。 Traceback (most recent call last):

periodically rendering html without context

I would like to have a periodic task which renders an html file and uploads it to s3 via boto. The problem with this is that since the task is outside of an endpoint function (ie decorated by app.route), there is no Flask context. So, when my task executes and render_template is called, there is an exception due to there being no context: Traceback ........ File "/usr/local/lib/python2.7/

定期呈现没有上下文的HTML

我想有一个周期性的任务,它呈现一个html文件并通过boto将它上传到s3。 问题在于,由于任务不在端点函数之外(即由app.route装饰),因此没有Flask上下文。 所以,当我的任务执行并且render_template被调用时,由于没有上下文而存在异常: Traceback ........ File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 126, in render_template ctx.app.update_template_context(context) Attribute

Using Boto to tell when a file has successfully been uploaded to Glacier

Currently I am using Amazon Web Services(AWS) and to open an S3 bucket, save its contents to a directory in an EC2, I then create a tar file from everything that is in that directory and push that tar file to AWS Glacier. The last step that I was trying to accomplish was to have the script terminate when the tar file has been successfully upload to AWS Glacier (Which takes 3-5 hours). Currentl

使用Boto告诉文件何时成功上传到Glacier

目前,我正在使用Amazon Web Services(AWS)并打开S3存储桶,将其内容保存到EC2中的目录中,然后从该目录中的所有内容创建一个tar文件,并将该tar文件推送到AWS Glacier。 我尝试完成的最后一步是在tar文件成功上传到AWS Glacier(需要3-5小时)时终止脚本。 目前我难以理解如何获取archive_id并询问文件库是否已成功加载tar文件。 与AWS Glacier交互我一直在使用python boto工具。 我包含了将文件上传到冰川的python bo

Discrete optimzation in python

I am trying to use the scipy.optimize package to optimize a discrete optimization problem (global optimization). Acc to the doc, simulated annealing implemented in scipy.optimize.anneal should be a good choice for the same. But I am not sure how to force the optimizer to search only integer values of the search space. Can someone help? An illustrative example: f(x1,x2) = (1-0.4*x1)^2 + 100

在Python中离散优化

我正在尝试使用scipy.optimize包来优化离散优化问题(全局优化)。 根据文档,在scipy.optimize.anneal实现的模拟退火应该是一个不错的选择。 但我不知道如何强制优化器仅搜索搜索空间的整数值。 有人可以帮忙吗? 一个说明性例子: f(x1,x2) = (1-0.4*x1)^2 + 100*(0.6*x2 -0.4*x1^2)^2 where, $x1, x2 in I$ 我检查了scipy.optimize.anneal,我看不到使用离散值的方法。 自己实现它的方法是创建一个自定义的“移动”

Python memory allocation error using subprocess.Popen

I am doing some bioinformatics work. I have a python script that at one point calls a program to do an expensive process (sequence alignment..uses a lot of computational power and memory). I call it using subprocess.Popen. When I run it on a testcase, it completes and finishes fine. However, when I run it on the full file, where it would have to do this multiple times for different sets of in

使用subprocess.Popen的Python内存分配错误

我正在做一些生物信息学工作。 我有一个python脚本,它在某个时刻调用一个程序来执行一个昂贵的过程(序列对齐......使用大量的计算能力和内存)。 我使用subprocess.Popen调用它。 当我在一个测试用例上运行它时,它会完成并完成正常工作。 但是,当我在完整文件上运行它时,它将不得不多次为不同的输入集执行此操作,它会死亡。 子过程抛出: OSError: [Errno 12] Cannot allocate memory 我在这里和这里发现了几个链接

based simple python chat program

I am writing a simple socket-based chat program that allows the server to send and receive message to the client. The client can send message to server but when I try sending a message from the server, it crashes saying that 'file' objects has attribute 'recv'. Server.py import socket import os import select import sys def prompt(): sys.stdout.write('<You> ') sy

基于简单的Python聊天程序

我正在编写一个简单的基于套接字的聊天程序,它允许服务器向客户端发送和接收消息。 客户端可以发送消息给服务器,但是当我尝试从服务器发送消息时,它会崩溃,说'文件'对象的属性为'recv'。 Server.py import socket import os import select import sys def prompt(): sys.stdout.write('<You> ') sys.stdout.flush() try: server_socket = socket.socket(socket.AF_INET, socket.SOCK

couldn't remove origin point in matplotlib polycollection

I have tried an example with PolyCollection from matplotlib tutorials and noticed one strange thing. I couldn't remove this points from axes origin see fig. How do I manage this? from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection from matplotlib.colors import colorConverter import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fi

无法删除matplotlib polycollection中的原点

我从matplotlib教程中尝试了PolyCollection的例子,并注意到一件奇怪的事情。 我无法从轴原点中删除这些点,请参阅图。 我如何管理这个? from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection from matplotlib.colors import colorConverter import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') cc = lambda arg: colorConverte

Global name in Python

I want to find out whether two numbers N1 and N2 are the permutations of the same digits. For example 123 and 321 are permutations of the same digits, where as 234 and 123 are not. I have used Python to solve the problem of which I am not an expert. I am using IDLE Python GUI on Windows 7 . The specifications are Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win

Python中的全局名称

我想知道两个数N1和N2是否是相同数字的排列。 例如, 123和321是相同数字的排列,其中234和123不是。 我用Python解决了我不是专家的问题。 我在Windows 7上使用IDLE Python GUI 。 规范是Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 。 Python代码如下所示, def k(n, m): s1 = n s2 = m k = 0 fl = 0 while k < 10 : arr1[k] = 0 arr2[

Django UncompressableFileError

I am using Amazon S3 bucket to store my static files. And I have compressor app in Django to compress all the static files. Django gives me error: 'home_page/css/bootstrap.min.css' isn't accessible via COMPRESS_URL ('https://alphagravel.s3.amazonaws.com/static/') and can't be compressed Same you can check here: http://52.5.32.9/ But: URL - 'https://alphagravel.

Django UncompressableFileError

我正在使用Amazon S3存储区来存储我的静态文件。 我在Django中有压缩程序来压缩所有的静态文件。 Django给我错误: 'home_page / css / bootstrap.min.css'无法通过COMPRESS_URL('https://alphagravel.s3.amazonaws.com/static/')访问,无法压缩 同样你可以在这里查看:http://52.5.32.9/ 但是:URL - 'https://alphagravel.s3.amazonaws.com/static/home_page/css/bootstrap.min.css'是可访