本文整理匯總了Python中models.Document.close方法的典型用法代碼示例。如果您正苦於以下問題:Python Document.close方法的具體用法?Python Document.close怎麽用?Python Document.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Document
的用法示例。
在下文中一共展示了Document.close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: list
# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import close [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 = []
#.........這裏部分代碼省略.........