当前位置: 首页>>代码示例>>Python>>正文


Python Document.chunks方法代码示例

本文整理汇总了Python中models.Document.chunks方法的典型用法代码示例。如果您正苦于以下问题:Python Document.chunks方法的具体用法?Python Document.chunks怎么用?Python Document.chunks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Document的用法示例。


在下文中一共展示了Document.chunks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import chunks [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 = []
#.........这里部分代码省略.........
开发者ID:knightwave,项目名称:firstproject,代码行数:103,代码来源:views.py


注:本文中的models.Document.chunks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。