本文整理汇总了Python中models.Document.read方法的典型用法代码示例。如果您正苦于以下问题:Python Document.read方法的具体用法?Python Document.read怎么用?Python Document.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Document
的用法示例。
在下文中一共展示了Document.read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import read [as 别名]
def list(request):
if request.is_ajax():
print "ajax entered"
print request.FILES
form = UploadForm(request.POST,request.FILES)
if form.is_valid():
print 'form validated'
files = request.FILES.getlist('file')
for file in files:
path = MEDIA_ROOT+'ebooks/'+str(file)
destination = open(path, 'wb+')
for chunk in file.chunks():
destination.write(chunk)
destination.close()
for file in files:
path = MEDIA_ROOT+'ebooks/'+str(file)
destination = open(path, 'wb+')
a = destination.read()
print a
destination.close()
return HttpResponse('done \m/');
output = []
error = []
rlt = None
if request.method == 'POST':
form = UploadForm(request.POST, request.FILES)
if form.is_valid():
file = Document(file = request.FILES['file'])
file.save()
files = request.FILES.getlist('file')
for file in files:
path = MEDIA_ROOT+'ebooks/'+str(file)
destination = open(path, 'wb+')
for chunk in file.chunks():
destination.write(chunk)
destination.close()
for file in files:
path = MEDIA_ROOT+'ebooks/'+str(file)
destination = open(path, 'r')
a = destination.read()
destination.close()
for file in files:
path = MEDIA_ROOT+'ebooks/'+str(file)
a=b=''
p = subprocess.Popen(['g++',path])
#a,b = p.communicate()
p.wait()
print a
print 'goo boy'
a = os.linesep.join([s for s in a.splitlines() if s])
b = os.linesep.join([s for s in b.splitlines() if s])
output.append(a)
error.append(b)
if not b:
pr = subprocess.call(['./a.out'])
file = open('output.txt','r')
print file.read()
file.close()
file = open('1.txt','r')
print file.read()
file.close()
rlt = filecmp.cmp('output.txt','1.txt',shallow=False)
print 'pramod'
print rlt
"""
import subprocess
basename = "CodeGenTest";
execname = basename;
srcname = basename + ".cpp";
codeList = [];
codeList.append("#include<iostream>")
codeList.append("#include <stdio.h>");
codeList.append("using namespace std;int main(int argc, char *argv[])\n{");
codeList.append("printf(\"Hello world.\\n\");");
codeList.append("int a;cin>>a;");
codeList.append("}");
# Convert codelist to string.
codeList.append("");
codeString = "\n".join(codeList);
# Print code to output source file
outfile=open(srcname,'w');
outfile.write(codeString);
outfile.close();
print "Compile.";
cmd = ["g++", srcname, "-o", execname];
p = subprocess.Popen(cmd);
p.wait();
subprocess.call(["./"+execname,'<','input.txt','>','output.txt']);
"""
else:
form = UploadForm()
dir_path = os.path.join(MEDIA_ROOT,'ebooks/')
files = []
#.........这里部分代码省略.........