diff options
author | supriya <supriya@dragbox.(none)> | 2012-09-26 15:49:52 +0530 |
---|---|---|
committer | supriya <supriya@dragbox.(none)> | 2012-09-26 15:49:52 +0530 |
commit | 94535d4adc3a4960795d22e3b229a8375de10b74 (patch) | |
tree | 8d77de86b443495d67360dcd40786f2b8208d334 /gstudio/views | |
parent | cad11e2f7ed848cdfd7779451bb0f4f931e062c3 (diff) | |
download | gnowsys-94535d4adc3a4960795d22e3b229a8375de10b74.tar.gz |
all modules integrated
Diffstat (limited to 'gstudio/views')
-rw-r--r-- | gstudio/views/ajaxviews.py | 26 | ||||
-rw-r--r-- | gstudio/views/docu.py | 163 | ||||
-rw-r--r-- | gstudio/views/group.py | 39 | ||||
-rw-r--r-- | gstudio/views/groupadd.py | 5 | ||||
-rw-r--r-- | gstudio/views/image.py | 177 | ||||
-rw-r--r-- | gstudio/views/nodetypes.py | 16 | ||||
-rw-r--r-- | gstudio/views/page.py | 36 | ||||
-rw-r--r-- | gstudio/views/pageadd.py | 16 | ||||
-rw-r--r-- | gstudio/views/sectionadd1.py | 5 | ||||
-rw-r--r-- | gstudio/views/topicadd.py | 2 | ||||
-rw-r--r-- | gstudio/views/topicadd1.py | 5 | ||||
-rw-r--r-- | gstudio/views/user.py | 24 | ||||
-rw-r--r-- | gstudio/views/video.py | 326 |
13 files changed, 597 insertions, 243 deletions
diff --git a/gstudio/views/ajaxviews.py b/gstudio/views/ajaxviews.py index e763020..a55cf4e 100644 --- a/gstudio/views/ajaxviews.py +++ b/gstudio/views/ajaxviews.py @@ -351,33 +351,41 @@ def AjaxAddContentOrg(request): def AjaxCreateFile(request): + usr=str(request.user) iden = request.GET["id"] orgcontent = request.GET["content_org"] - myfile = open('/tmp/file.org', 'w') - myfile.write(orgcontent) + ext='.org' + html='.html' + myfile = open(os.path.join('/tmp/',usr+ext),'w') + myfile.write(new_ob.content_org) myfile.close() - myfile = open('/tmp/file.org', 'r') + myfile = open(os.path.join('/tmp/',usr+ext),'r') myfile.readline() - myfile = open('/tmp/file.org', 'a') + myfile = open(os.path.join('/tmp/',usr+ext),'a') myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') + myfile = open(os.path.join('/tmp/',usr+ext),'r') return HttpResponse("test sucess") def AjaxCreateHtml(request): - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + usr=str(request.user) + ext='.org' + stdout = os.popen("%s %s"%(PYSCRIPT_URL_GSTUDIO,usr+ext)) output = stdout.read() return HttpResponse("sucess") def AjaxAddContent(request): + usr=str(request.user) + html='.html' iden = request.GET["id"] nid = NID.objects.get(id = iden) refobj = nid.ref - data = open("/tmp/file.html") + data = open(os.path.join('/tmp/',usr+html)) data1 = data.readlines() - data2 = data1[67:] + data2 = data1[72:] + data3 = data2[:-3] newdata="" - for line in data2: + for line in data3: newdata += line.lstrip() refobj.content= newdata refobj.save() diff --git a/gstudio/views/docu.py b/gstudio/views/docu.py index 1d0f7f8..b544765 100644 --- a/gstudio/views/docu.py +++ b/gstudio/views/docu.py @@ -22,13 +22,18 @@ from demo.settings import * from gstudio.models import * from objectapp.models import * from gstudio.methods import * +import hashlib +from django.template.defaultfilters import slugify +import os +report = "true" def docu(request): p=Objecttype.objects.get(title="Document") q=p.get_nbh['contains_members'] if request.method=="POST": + title = request.POST.get("title1","") user = request.POST.get("user","") - content= request.POST.get("contenttext","") + content= unicode(request.POST.get("contenttext","")) sdoc = request.POST.get("sdoc","") dn = request.POST.get("dn","") sub3 = request.POST.get("mydropdown","") @@ -36,7 +41,7 @@ def docu(request): docid = request.POST.get("docid","") delete = request.POST.get("delete","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") + texttags = unicode(request.POST.get("texttags","")) contenttext = request.POST.get("commenttext","") if rating : rate_it(int(docid),request,int(rating)) @@ -69,21 +74,25 @@ def docu(request): if addtags != "": i=Gbobject.objects.get(id=docid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() if contenttext !="": - edit_description(docid,contenttext) + edit_description(docid,contenttext,str(request.user)) a=[] + reportid='' for each in request.FILES.getlist("doc[]",""): a.append(each) if a != "": for f in a: - save_file(f) - create_object(f,user,content) - vars=RequestContext(request,{'documents':q}) + report,imageeachid = save_file(f) + if report == "false": + reportid = imageeachid + else: + create_object(f,user,content,str(request.user),title) + vars=RequestContext(request,{'documents':q,'reportid':reportid}) template="gstudio/docu.html" return render_to_response(template, vars) s=Nodetype.objects.get(title="Document") @@ -93,17 +102,41 @@ def docu(request): return render_to_response(template, vars) def save_file(file, path=""): + report = "true" + imageeachid = '' filename = file._get_name() - fd = open('%s/%s' % (MEDIA_ROOTNEW2, str(path) + str(filename)), 'wb') + slugfile = str(filename) + slugfile=slugfile.replace(' ','_') + fd = open('%s/%s' % (MEDIA_ROOTNEW2, str(path) + str(slugfile)), 'wb') for chunk in file.chunks(): fd.write(chunk) fd.close() + global md5_checksum + md5_checksum = md5Checksum(MEDIA_ROOTNEW2+"/"+str(slugfile)) + attype = Attributetype.objects.get(title="md5_checksum_document") + att = Attribute.objects.all() + flag = 0 + for each in att: + if each.attributetype.id == attype.id: + if each.svalue == md5_checksum : + flag = 1 + imageeachid = each.subject.id + if flag == 1: + report = "false" + + return report,imageeachid -def create_object(file,log,content): + +def create_object(file,log,content,usr,title): p=Gbobject() - p.title=file._get_name() - p.rurl=MEDIA_ROOTNEW2+"p.title" + filename=file._get_name() + slugfile = str(filename) + slugfile=slugfile.replace(' ','_') + p.title = title + p.altnames = slugfile + #p.rurl= #MEDIA_ROOTNEW2+"p.title" final = '' + fname=slugify(p.title)+"-"+usr for each1 in p.title: if each1==".": final=final+'-' @@ -112,7 +145,8 @@ def create_object(file,log,content): else: final = final+each1 p.slug=final - p.content_org=content + contorg=unicode(content) + p.content_org=contorg.encode('utf8') p.status=2 p.save() p.sites.add(Site.objects.get_current()) @@ -124,18 +158,24 @@ def create_object(file,log,content): p.objecttypes.add(Objecttype.objects.get(id=q.id)) p.save() new_ob = content - myfile = open('/tmp/file.org', 'w') - myfile.write(new_ob) - myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') - myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") - myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) - output = stdout.read() - data = open("/tmp/file.html") + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(p.content_org) + myfile.close() + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + myfile = open(os.path.join(FILE_URL,fname+ext),'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) + output = stdout.read() + data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[72:] data3 = data2[:-3] @@ -144,28 +184,65 @@ def create_object(file,log,content): newdata += line.lstrip() p.content = newdata p.save() + a=Attribute() + a.attributetype=Attributetype.objects.get(title="md5_checksum_document") + a.subject=p + a.svalue=md5_checksum + a.save() def rate_it(topic_id,request,rating): ob = Gbobject.objects.get(id=topic_id) ob.rating.add(score=rating ,user=request.user, ip_address=request.META['REMOTE_ADDR']) return True +def show(request,documentid): + if request.method=="POST": + rating = request.POST.get("star1","") + docid = request.POST.get("docid","") + addtags = request.POST.get("addtags","") + texttags = unicode(request.POST.get("texttags","")) + contenttext = unicode(request.POST.get("contenttext","")) + if rating : + rate_it(int(docid),request,int(rating)) + if addtags != "": + i=Gbobject.objects.get(id=docid) + i.tags = i.tags+ ","+(texttags) + i.save() + if contenttext !="": + edit_description(docid,contenttext,str(request.user)) + gbobject = Gbobject.objects.get(id=documentid) + vars=RequestContext(request,{'doc':gbobject}) + template="gstudio/fulldocument.html" + return render_to_response(template,vars) + -def edit_description(sec_id,title): + +def edit_description(sec_id,title,usr): new_ob = Gbobject.objects.get(id=int(sec_id)) - new_ob.content_org = title - myfile = open('/tmp/file.org', 'w') - myfile.write(new_ob.content_org) - myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') - myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") - myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) - output = stdout.read() - data = open("/tmp/file.html") + contorg=unicode(title) + new_ob.content_org=contorg.encode('utf8') + ssid=new_ob.get_ssid.pop() + fname=str(ssid)+"-"+usr + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(new_ob.content_org) + myfile.close() + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) + output = stdout.read() + data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[72:] data3 = data2[:-3] @@ -175,3 +252,13 @@ def edit_description(sec_id,title): new_ob.content = newdata new_ob.save() return True + +def md5Checksum(filePath): + fh = open(filePath, 'rb') + m = hashlib.md5() + while True: + data = fh.read(8192) + if not data: + break + m.update(data) + return m.hexdigest() diff --git a/gstudio/views/group.py b/gstudio/views/group.py index d38b5ae..4a436ed 100644 --- a/gstudio/views/group.py +++ b/gstudio/views/group.py @@ -54,31 +54,50 @@ def groupdashboard(request,grpid): rep = request.POST.get("reply",'') id_no = request.POST.get("iden",'') id_no1 = request.POST.get("parentid","") - print "topicid",id_no,"replyid",id_no1,"reply",rep idusr = request.POST.get("idusr",'') - rating = request.POST.get("star1","") + usr = request.POST.get("usr",'') + rating = request.POST.get("star1","") flag1=request.POST.get("release","") block = request.POST.get("block","") topic_del = request.POST.get("del_topic", "") comment_del = request.POST.get("del_comment", "") - - if topic_del: + editable=request.POST.get("edit","") + editval=request.POST.get("editval","") + edittitle=request.POST.get("edittitle","") + editcontent=request.POST.get("editcont","") + editiden=request.POST.get("editiden","") + docid = request.POST.get("docid","") + addtags = request.POST.get("addtags","") + texttags = unicode(request.POST.get("texttags","")) + if editval=='editthread': + edit_thread(editiden,editcontent,str(request.user)) + if editable=='edited': + if id_no : + edit_topic(id_no,rep,usr) + elif id_no1 : + edit_topic(id_no1,rep,str(request.user)) + if topic_del: del_topic(int(id_no)) if comment_del: del_comment(int(id_no1)) + if addtags != "": + i=Gbobject.objects.get(id=int(docid)) + i.tags = i.tags+ ","+(texttags) + i.save() if flag1: boolean1 = True make_att_true(meeting_ob) if block : make_att_false(meeting_ob) if rating : - rate_it(int(id_no),request,int(rating)) - if rep : + rate_it(int(id_no1),request,int(rating)) + if rep and editable!='edited': if not id_no : - boolean = make_relation(rep,int(id_no1),int(idusr)) + + boolean = make_relation(rep,int(id_no1),int(idusr),str(request.user)) elif not id_no1 : - boolean = make_relation(rep,int(id_no),int(idusr)) + boolean = make_relation(rep,int(id_no),int(idusr),usr) if boolean : return HttpResponseRedirect("/gstudio/group/gnowsys-grp/"+str(grpid)) grpid = int(grpid) @@ -98,7 +117,9 @@ def groupdashboard(request,grpid): post=latest_topic.get_absolute_url() else: post="no topic added yet!!" - variables = RequestContext(request,{'topic' : Topic , 'meet_ob' : meeting_ob, "flag" : flag, "flag1" : boolean1, "admin_id" : admin_id, "attribute" : attob, 'admin_m':admin_m, 'endtime':endtime, 'post':post}) + ot=Gbobject.objects.get(id=grpid) + meeting_ob = System.objects.get(id=grpid) + variables = RequestContext(request,{'ot' : ot,'topic' : Topic , 'meet_ob' : meeting_ob, "flag" : flag, "flag1" : boolean1, "admin_id" : admin_id, "attribute" : attob, 'admin_m':admin_m, 'endtime':endtime, 'post':post}) template = "metadashboard/grpdashboard.html" return render_to_response(template, variables) diff --git a/gstudio/views/groupadd.py b/gstudio/views/groupadd.py index d0c7242..e32a101 100644 --- a/gstudio/views/groupadd.py +++ b/gstudio/views/groupadd.py @@ -30,6 +30,7 @@ def groupadd(request): stDate = (request.POST["stDate"]).split("/") endDate=(request.POST["endDate"]).split("/") hours1 = int(request.POST["hours1"]) + usr = request.POST.get("usr",'') minutes1 = int(request.POST["minutes1"]) hours2 = int(request.POST["hours2"]) minutes2 = int(request.POST["minutes2"]) @@ -38,9 +39,9 @@ def groupadd(request): if not errors: title=request.POST['subject'] - content=request.POST['message'] + content=unicode(request.POST['message']) idusr=request.POST['idusr'] - meetId = create_meeting(title,int(idusr),content) + meetId = create_meeting(title,int(idusr),content,usr) schedule_time(time1, time2, meetId) if meetId : return HttpResponseRedirect('/gstudio/group/gnowsys-grp/'+ str(meetId)) diff --git a/gstudio/views/image.py b/gstudio/views/image.py index 4b1c3f4..ec1b2fc 100644 --- a/gstudio/views/image.py +++ b/gstudio/views/image.py @@ -23,13 +23,20 @@ from gstudio.models import * from objectapp.models import * import os from gstudio.methods import * +from PIL import Image +import glob, os +import hashlib +from django.template.defaultfilters import slugify +size = 128, 128 +report = "true" +md5_checksum = "" def image(request): p=Objecttype.objects.get(title="Image") q=p.get_nbh['contains_members'] if request.method=="POST": title = request.POST.get("title1","") - content= request.POST.get("contenttext","") + content= unicode(request.POST.get("contenttext","")) simg = request.POST.get("simg","") sub3 = request.POST.get("mydropdown","") user = request.POST.get("user","") @@ -40,7 +47,7 @@ def image(request): fulid = request.POST.get("fulid","") show = request.POST.get("Show","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") + texttags = unicode(request.POST.get("texttags","")) contenttext = request.POST.get("contenttext","") if show != "": i=Gbobject.objects.get(id=fulid) @@ -79,27 +86,34 @@ def image(request): if addtags != "": i=Gbobject.objects.get(id=imgid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() a=[] + reportid='' for each in request.FILES.getlist("image[]",""): a.append(each) if a != "": i=0 for f in a: if i==0: - save_file(f,title,user) - create_object(f,user,title,content) - i=i+1 + report,imageeachid = save_file(f,title,user) + if report == "false": + reportid = imageeachid + else: + create_object(f,user,title,content,str(request.user)) + i=i+1 else: - save_file(f,title+'_'+str(i),user) - create_object(f,user,title+'_'+str(i),content) - i=i+1 + report,imageeachid = save_file(f,title+'_'+str(i),user) + if report == "false": + reportid = imageeachid + else: + create_object(f,user,title+'_'+str(i),content,str(request.user)) + i=i+1 p=Objecttype.objects.get(title="Image") q=p.get_nbh['contains_members'] - vars=RequestContext(request,{'images':q}) + vars=RequestContext(request,{'images':q,'reportid':reportid,'report':report}) template="gstudio/image.html" return render_to_response(template, vars) vars=RequestContext(request,{'images':q,'val':""}) @@ -107,31 +121,67 @@ def image(request): return render_to_response(template, vars) def save_file(file,title, user, path=""): + report = "true" + imageeachid = '' filename = title + slugfile = str(file) + slugfile=slugfile.replace(' ','_') os.system("mkdir -p "+ MEDIA_ROOTNEW2+"/"+user) - fd = open('%s/%s/%s' % (MEDIA_ROOTNEW2, str(user),str(path) + str(file)), 'wb') + fd = open('%s/%s/%s' % (MEDIA_ROOTNEW2, str(user),str(path) + str(slugfile)), 'wb') for chunk in file.chunks(): fd.write(chunk) fd.close() + global md5_checksum + md5_checksum = md5Checksum(MEDIA_ROOTNEW2+"/"+ str(user)+"/"+slugfile) + attype = Attributetype.objects.get(title="md5_checksum_image") + att = Attribute.objects.all() + flag = 0 + for each in att: + if each.attributetype.id == attype.id: + if each.svalue == md5_checksum : + flag = 1 + imageeachid = each.subject.id + if flag == 1: + report = "false" + else: + for infile in glob.glob(MEDIA_ROOTNEW2+"/"+str(user)+"/"+str(slugfile)): + file, ext = os.path.splitext(infile) + im = Image.open(infile) + imm = Image.open(infile) + im.thumbnail(size, Image.ANTIALIAS) + im.save(file + "-thumbnail", "JPEG") + width, height = imm.size + sizem = 1024,height + if int(width) > 1024: + imm.thumbnail(sizem, Image.ANTIALIAS) + imm.save(file + "_display_1024","JPEG") + else: + imm.thumbnail(imm.size,Image.ANTIALIAS) + imm.save(file + "_display_1024","JPEG") + return report,imageeachid + -def create_object(f,log,title,content): +def create_object(f,log,title,content,usr): p=Gbobject() filename = str(f) + filename=filename.replace(' ','_') p.title=title + fname=slugify(title)+"-"+usr p.image=log+"/"+filename - final = '' - for each1 in filename: - if each1==" ": - final=final+'-' - else: - final = final+each1 - i=0 - dirname = "" - while final[i] != ".": - dirname = dirname + final[i] - i=i+1 - p.slug=dirname - p.content_org=content + #final = '' + #for each1 in filename: + # if each1==" ": + # final=final+'-' + # else: + # final = final+each1 + #i=0 + #dirname = "" + #while final[i] != ".": + # dirname = dirname + final[i] + # i=i+1 + p.slug=slugify(filename) + contorg=unicode(content) + p.content_org=contorg.encode('utf8') p.status=2 p.save() p.sites.add(Site.objects.get_current()) @@ -143,18 +193,25 @@ def create_object(f,log,title,content): p.objecttypes.add(Objecttype.objects.get(id=q.id)) p.save() new_ob = content - myfile = open('/tmp/file.org', 'w') - myfile.write(new_ob) + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(p.content_org) myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) output = stdout.read() - data = open("/tmp/file.html") + data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[72:] data3 = data2[:-3] @@ -163,6 +220,12 @@ def create_object(f,log,title,content): newdata += line.lstrip() p.content = newdata p.save() + a=Attribute() + a.attributetype=Attributetype.objects.get(title="md5_checksum_image") + a.subject=p + a.svalue=md5_checksum + a.save() + def rate_it(topic_id,request,rating): ob = Gbobject.objects.get(id=topic_id) @@ -174,36 +237,47 @@ def show(request,imageid): rating = request.POST.get("star1","") imgid = request.POST.get("imgid","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") - contenttext = request.POST.get("contenttext","") + texttags = unicode(request.POST.get("texttags","")) + contenttext = unicode(request.POST.get("contenttext","")) if rating : rate_it(int(imgid),request,int(rating)) if addtags != "": i=Gbobject.objects.get(id=imgid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() if contenttext !="": - edit_description(imgid,contenttext) + edit_description(imgid,contenttext,str(request.user)) gbobject = Gbobject.objects.get(id=imageid) vars=RequestContext(request,{'image':gbobject}) template="gstudio/fullscreen.html" return render_to_response(template,vars) -def edit_description(sec_id,title): +def edit_description(sec_id,title,usr): new_ob = Gbobject.objects.get(id=int(sec_id)) - new_ob.content_org = title - myfile = open('/tmp/file.org', 'w') + contorg=unicode(title) + ssid=new_ob.get_ssid.pop() + fname=str(ssid)+"-"+usr + new_ob.content_org=contorg.encode('utf8') + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') myfile.write(new_ob.content_org) myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) + output = stdout.read() - data = open("/tmp/file.html") + data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[72:] data3 = data2[:-3] @@ -213,3 +287,14 @@ def edit_description(sec_id,title): new_ob.content = newdata new_ob.save() return True + +def md5Checksum(filePath): + fh = open(filePath, 'rb') + m = hashlib.md5() + while True: + data = fh.read(8192) + if not data: + break + m.update(data) + return m.hexdigest() + diff --git a/gstudio/views/nodetypes.py b/gstudio/views/nodetypes.py index 2762e06..fe301eb 100644 --- a/gstudio/views/nodetypes.py +++ b/gstudio/views/nodetypes.py @@ -58,6 +58,10 @@ from django.views.generic.date_based import archive_month from django.views.generic.date_based import archive_day from django.views.generic.date_based import object_detail +from gstudio.methods import * +from demo.settings import PYSCRIPT_URL_GSTUDIO +from demo.settings import FILE_URL + from gstudio.models import Nodetype from gstudio.views.decorators import protect_nodetype from gstudio.views.decorators import update_queryset @@ -79,5 +83,17 @@ def nodetype_shortlink(request, object_id): Redirect to the 'get_absolute_url' of a nodetype, accordingly to 'object_id' argument """ + if request.method == "POST" : + boolean = False + rep = request.POST.get("replytosection",'') + id_no = request.POST.get("iden",'') + # id_no1 = request.POST.get("parentid","") + idusr = request.POST.get("idusr",'') + usr = request.POST.get("usr",'') + editable = request.POST.get("edit","") + if editable=="edited": + edit_nodetype(id_no,rep,usr) + + nodetype = get_object_or_404(Nodetype, pk=object_id) return redirect(nodetype, permanent=True) diff --git a/gstudio/views/page.py b/gstudio/views/page.py index e59caec..3482ccb 100644 --- a/gstudio/views/page.py +++ b/gstudio/views/page.py @@ -22,26 +22,27 @@ from gstudio.methods import * def pagedashboard(request,pageid): pageid = int(pageid) - # boolean1 = False flag= False page_ob = System.objects.get(id=pageid) if request.method == "POST" : boolean = False rep = request.POST.get("replytosection",'') - print "rep" ,rep -# content_org = request.POST.get("orgreply",'') id_no = request.POST.get("iden",'') id_no1 = request.POST.get("parentid","") - print"id",id_no1 idusr = request.POST.get("idusr",'') + usr = request.POST.get("usr",'') rating = request.POST.get("star1","") - # # flag1=request.POST.get("pagerelease","") - # # block = request.POST.get("block","") section_del = request.POST.get("del_section", "") comment_del = request.POST.get("del_comment", "") docid = request.POST.get("docid","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") + texttags = unicode(request.POST.get("texttags","")) + editable = request.POST.get("edit","") + if editable=="edited": + if id_no: + edit_section(id_no,rep,usr) + elif id_no1: + edit_section(id_no1,rep,str(request.user)) if section_del: del_section(int(id_no)) if comment_del: @@ -50,19 +51,16 @@ def pagedashboard(request,pageid): rate_section(int(id_no),request,int(rating)) if addtags != "": i=Gbobject.objects.get(id=docid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() - if rep : + if rep and editable!='edited': if not id_no : - ptitle= make_title(int(id_no)) - boolean = make_sectionrelation(rep,ptitle,int(id_no1),int(idusr)) - - + ptitle= make_title(int(id_no1)) + boolean = make_sectionrelation(rep,ptitle,int(id_no1),int(idusr),usr) elif not id_no1 : ptitle= make_title(int(id_no)) - boolean = make_sectionrelation(rep,ptitle,int(id_no),int(idusr)) - + boolean = make_sectionrelation(rep,ptitle,int(id_no),int(idusr),usr) if boolean : return HttpResponseRedirect("/gstudio/page/gnowsys-page/"+str(pageid)) pageid = int(pageid) @@ -70,10 +68,6 @@ def pagedashboard(request,pageid): flag = True Section = page_ob.system_set.all()[0].gbobject_set.all() admin_id = page_ob.authors.all()[0].id #a list of topics - # # for each in page_ob.subject_of.all(): - # # if each.attributetype.title=='pagerelease': - # # attob = each.svalue - # # break admin_m = page_ob.authors.all()[0] topic_type_set=Objecttype.objects.get(title='Section') @@ -83,7 +77,9 @@ def pagedashboard(request,pageid): else: post="no topic added yet!!" ot=Gbobject.objects.get(id=pageid) - + page_ob = System.objects.get(id=pageid) variables = RequestContext(request, {'ot' : ot,'section' : Section,'page_ob' : page_ob,'admin_m':admin_m,"flag" : flag,"admin_id" : admin_id,'post':post}) + template = "metadashboard/pgedashboard.html" return render_to_response(template, variables) + diff --git a/gstudio/views/pageadd.py b/gstudio/views/pageadd.py index d51017c..1537fc7 100644 --- a/gstudio/views/pageadd.py +++ b/gstudio/views/pageadd.py @@ -29,11 +29,23 @@ def pageadd(request): # if not request.POST.get('org1', ''): # errors.append('Enter a page.') if not errors: - title=unicode(request.POST['subject']) + title=request.POST['subject'] # content=request.POST['page'] content_org=unicode(request.POST['org1']) idusr=request.POST['idusr'] - pageId = create_wikipage(title,int(idusr),content_org) + usr = request.POST.get("usr",'') + editable= request.POST.get("edit","") + # print content_org,"content" + + if editable=='edited': + + #if id_no: + edit_section(idusr,content_org,usr) + # elif id_no1: + # edit_section(id_no1,rep) + + + pageId = create_wikipage(title,int(idusr),content_org,usr) if pageId : return HttpResponseRedirect('/gstudio/page/gnowsys-page/'+ str(pageId)) variables = RequestContext(request,{'errors' : errors, 'pageId' : pageId}) diff --git a/gstudio/views/sectionadd1.py b/gstudio/views/sectionadd1.py index 8bc3dd1..55ba6ff 100644 --- a/gstudio/views/sectionadd1.py +++ b/gstudio/views/sectionadd1.py @@ -19,11 +19,12 @@ def sectionadd1(request,pageid): if not request.POST.get('org', ''): errors.append('Enter a page.') if not errors: - title=unicode(request.POST['subject']) + title=request.POST['subject'] # content=request.POST['page'] content_org=unicode(request.POST['org']) idusr=request.POST['idusr'] - tp = make_section_object(title,int(idusr),content_org) + usr=request.POST['usr'] + tp = make_section_object(title,int(idusr),content_org,usr) System.objects.get(id=int(pageid)).system_set.all()[0].gbobject_set.add(tp) if tp: return HttpResponseRedirect('/gstudio/page/gnowsys-page/'+pageid) diff --git a/gstudio/views/topicadd.py b/gstudio/views/topicadd.py index 31e780e..044a374 100644 --- a/gstudio/views/topicadd.py +++ b/gstudio/views/topicadd.py @@ -32,7 +32,7 @@ def topicadd(request): if not request.POST.get('message', ''): errors.append('Enter a message.') if not errors: - title=unicode(request.POST['subject']) + title=request.POST['subject'] content=unicode(request.POST['message']) idusr=request.POST['idusr'] boolean = make_topic_object(title,int(idusr),content) diff --git a/gstudio/views/topicadd1.py b/gstudio/views/topicadd1.py index dc1865f..bb866d8 100644 --- a/gstudio/views/topicadd1.py +++ b/gstudio/views/topicadd1.py @@ -33,9 +33,10 @@ def topicadd1(request,grpid): errors.append('Enter a message.') if not errors: title=request.POST['subject'] - content=request.POST['message'] + content=unicode(request.POST['message']) idusr=request.POST['idusr'] - tp = make_topic_object(title,int(idusr),content) + usr=request.POST['usr'] + tp = make_topic_object(title,int(idusr),content,usr) System.objects.get(id=int(grpid)).system_set.all()[0].gbobject_set.add(tp) if tp: return HttpResponseRedirect('/gstudio/group/gnowsys-grp/'+grpid) diff --git a/gstudio/views/user.py b/gstudio/views/user.py index 9fa9b6d..d49df25 100644 --- a/gstudio/views/user.py +++ b/gstudio/views/user.py @@ -21,27 +21,27 @@ from django.template import RequestContext from django.shortcuts import render_to_response from gstudio.methods import * -def userdashboard(request,username): - if request.user.username == username : +def userdashboard(request):#,username): + # if request.user.username == username : meetings = Systemtype.objects.get(title="Meeting") variables = RequestContext(request,{"meetings" : meetings }) template = "metadashboard/userdashboard.html" return render_to_response(template, variables) - else : - variables = RequestContext(request) - template = "metadashboard/logindashboard.html" - return render_to_response(template,variables) + #else : + # variables = RequestContext(request) + # template = "metadashboard/logindashboard.html" + # return render_to_response(template,variables) -def wikidashboard(request,username): - if request.user.username == username : +def wikidashboard(request):#,username): + #if request.user.username == username : pages = Systemtype.objects.get(title="Wikipage") variables = RequestContext(request,{"pages" : pages }) template = "metadashboard/wikidashboard.html" return render_to_response(template, variables) - else : - variables = RequestContext(request) - template = "metadashboard/logindashboard.html" - return render_to_response(template,variables) + #else : + # variables = RequestContext(request) + # template = "metadashboard/logindashboard.html" + # return render_to_response(template,variables) diff --git a/gstudio/views/video.py b/gstudio/views/video.py index 0bd39b7..6eb86d9 100644 --- a/gstudio/views/video.py +++ b/gstudio/views/video.py @@ -27,19 +27,26 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from demo.settings import * from gstudio.methods import * from django.contrib.auth import authenticate - +from django.template.defaultfilters import slugify +import hashlib +report = "true" +global md5_checksum +md5_checksum = "" def video(request): api=ox.api.API("http://wetube.gnowledge.org/api") p=Objecttype.objects.get(title="Video") q=p.get_nbh['contains_members'] sd = request.user + usr=str(request.user) + title = "" message = '' sd = str(sd) password = request.POST.get("upload","") content= request.POST.get("contenttext","") if request.method == 'POST': + title = request.POST.get("title1","") clip = request.FILES.get("clip","") - content= request.POST.get("contenttext","") + content= unicode(request.POST.get("contenttext","")) svid = request.POST.get("svid","") sub1 = request.POST.get("norm","") sub2 = request.POST.get("spe","") @@ -61,7 +68,7 @@ def video(request): wename = request.POST.get("wename","") titlename = request.POST.get("titlename","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") + texttags = unicode(request.POST.get("texttags","")) password = request.POST.get("videopassword","") if rate == '0': rate = 'No rating yet' @@ -114,95 +121,128 @@ def video(request): if addtags != "": i=Gbobject.objects.get(id=vidid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() if clip != "": api.signup({'username':user,'password':password,'email':useremail}) - save_file(clip,user) - clipname = clip._get_name() - i=0 - dirname = "" - while clipname[i] != ".": - dirname = dirname + clipname[i] - i=i+1 - y=str(dirname) - x=str(clipname[0]).upper() - CreateConfig(user,password) - # os.system("pandora_client config") - os.system("pandora_client add_volume "+ user+" "+MEDIA_ROOTNEW+"/"+user ) - os.system("pandora_client scan") - os.system("pandora_client sync") - os.system("pandora_client upload") + report,imageeachid = save_file(clip,user) + if report == "false": + reportid = imageeachid + q=p.get_nbh['contains_members'] + variables = RequestContext(request,{'vids':q,'reportid':reportid}) + template = "gstudio/video.html" + return render_to_response(template, variables) + else: + clipname = clip._get_name() + i=0 + dirname = "" + while clipname[i] != ".": + dirname = dirname + clipname[i] + i=i+1 + y=str(dirname) + x=str(clipname[0]).upper() + CreateConfig(user,password) + # os.system("pandora_client config") + os.system("pandora_client add_volume "+ user+" "+MEDIA_ROOTNEW+"/"+user ) + os.system("pandora_client scan") + os.system("pandora_client sync") + os.system("pandora_client upload") wclip= api.find({'sort': [{'key': 'title','operator': '+'}],'query': {'conditions': [{'key': 'title','value': y,'operator': '='}],'operator': '&'},'keys': ['id', 'title','user','duration','sourcedescription','created'],'range': [0,100]}) for each in wclip['data']['items']: - m=Gbobject() - m.title=each['title'].lower() - m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm' - m.slug=each['id'] - m.content_org=content - m.status=2 - m.save() - m.sites.add(Site.objects.get_current()) - m.save() - m.objecttypes.add(Objecttype.objects.get(id=p.id)) - m.save() - a=Attribute() - a.attributetype=Attributetype.objects.get(title="posted_by") - a.subject=m - a.svalue=user - a.save() - a1=Attribute() - a1.attributetype=Attributetype.objects.get(title="time_limit") - a1.subject=m - a1.svalue=each['duration'] - a1.save() - a2=Attribute() - a2.attributetype=Attributetype.objects.get(title="creation_day") - a2.subject=m - a2.svalue=each['created'] - a2.save() - a3=Attribute() - a3.attributetype=Attributetype.objects.get(title="source") - a3.subject=m - a3.svalue=each['sourcedescription'] - a3.save() - a4=Attribute() - a4.attributetype=Attributetype.objects.get(title="map_link") - a4.subject=m - l=each['sourcedescription'] - final='' - for each in l: - if each==" ": - final=final+'+' - else: - final=final+each - a4.svalue=final - a4.save() - m.save() - new_ob = content - myfile = open('/tmp/file.org', 'w') - myfile.write(new_ob) - myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') - myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") - myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) - output = stdout.read() - data = open("/tmp/file.html") - data1 = data.readlines() - data2 = data1[72:] - data3 = data2[:-3] - newdata="" - for line in data3: - newdata += line.lstrip() - m.content = newdata - m.save() - + flag=0 + for vid in q: + if vid.title==each['title'].lower(): + flag=1 + if vid.altnames==each['title'].lower(): + flag=1 + if flag==0: + print "in 1 for video" + m=Gbobject() + m.title = title + m.altnames=each['title'].lower() + fname=slugify(title)+"-"+usr + m.title=each['title'].lower() + m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm' + m.slug=each['id'] + contorg=unicode(content) + m.content_org=contorg.encode('utf8') + m.status=2 + m.save() + m.sites.add(Site.objects.get_current()) + m.save() + m.objecttypes.add(Objecttype.objects.get(id=p.id)) + m.save() + a=Attribute() + a.attributetype=Attributetype.objects.get(title="posted_by") + a.subject=m + a.svalue=user + a.save() + a1=Attribute() + a1.attributetype=Attributetype.objects.get(title="time_limit") + a1.subject=m + a1.svalue=each['duration'] + a1.save() + a2=Attribute() + a2.attributetype=Attributetype.objects.get(title="creation_day") + a2.subject=m + a2.svalue=each['created'] + a2.save() + a3=Attribute() + a3.attributetype=Attributetype.objects.get(title="source") + a3.subject=m + a3.svalue=each['sourcedescription'] + a3.save() + a4=Attribute() + a4.attributetype=Attributetype.objects.get(title="map_link") + a4.subject=m + l=each['sourcedescription'] + final='' + for each in l: + if each==" ": + final=final+'+' + else: + final=final+each + a4.svalue=final + a4.save() + m.save() + new_ob = content + usr=str(request.user) + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(m.content_org) + myfile.close() + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) + output = stdout.read() + data = open(os.path.join(FILE_URL,fname+html)) + data1 = data.readlines() + data2 = data1[72:] + data3 = data2[:-3] + newdata="" + for line in data3: + newdata += line.lstrip() + m.content = newdata + m.save() + a=Attribute() + a.attributetype=Attributetype.objects.get(title="md5_checksum_document") + a.subject=m + a.svalue=md5_checksum + a.save() + if sub3 != "": @@ -248,12 +288,20 @@ def video(request): for vid in q: if vid.title==each['title'].lower(): flag=1 + if vid.altnames==each['title'].lower(): + flag=1 if flag==0: m=Gbobject() - m.title=each['title'].lower() + if title: + m.title = title + else: + m.title = each['title'].lower() + m.altnames=each['title'].lower() + fname=slugify(title)+"-"+str(usr) m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm' m.slug=each['id'] - m.content=content + contorg=unicode(content) + m.content_org=contorg.encode('utf8') m.status=2 m.save() m.sites.add(Site.objects.get_current()) @@ -293,6 +341,42 @@ def video(request): a4.svalue=final a4.save() m.save() + new_ob = content + usr=str(request.user) + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(m.content_org) + myfile.close() + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) + output = stdout.read() + data = open(os.path.join(FILE_URL,fname+html)) + data1 = data.readlines() + data2 = data1[72:] + data3 = data2[:-3] + newdata="" + for line in data3: + newdata += line.lstrip() + m.content = newdata + m.save() + a=Attribute() + a.attributetype=Attributetype.objects.get(title="md5_checksum_document") + a.subject=m + a.svalue=md5_checksum + a.save() + svid="" q=p.get_nbh['contains_members'] variables = RequestContext(request,{'vids':q,'val':svid}) @@ -300,6 +384,8 @@ def video(request): return render_to_response(template, variables) def save_file(file, user,path=""): + report = "true" + imageeachid = '' filename = file._get_name() i=0 dirname = "" @@ -320,7 +406,20 @@ def save_file(file, user,path=""): for chunk in file.chunks(): fd.write(chunk) fd.close() - return + fd.close() + global md5_checksum + md5_checksum = md5Checksum(MEDIA_ROOTNEW+"/"+ str(fileuser)+"/"+str(filename[0]).upper()+"/"+str(dirname)+"/"+str(filename)) + attype = Attributetype.objects.get(title="md5_checksum_document") + att = Attribute.objects.all() + flag = 0 + for each in att: + if each.attributetype.id == attype.id: + if each.svalue == md5_checksum : + flag = 1 + imageeachid = each.subject.id + if flag == 1: + report = "false" + return report,imageeachid @@ -362,8 +461,10 @@ def show(request,videoid): favid=request.POST.get("favid","") favusr=request.POST.get("favusr","") addtags = request.POST.get("addtags","") - texttags = request.POST.get("texttags","") + texttags = unicode(request.POST.get("texttags","")) contenttext = request.POST.get("contenttext","") + contenttext = unicode(request.POST.get("contenttext","")) + titlecontenttext = request.POST.get("titlecontenttext") if rating : rate_it(int(vidid),request,int(rating)) @@ -395,31 +496,46 @@ def show(request,videoid): if addtags != "": i=Gbobject.objects.get(id=vidid) - i.tags = i.tags+ ","+str(texttags) + i.tags = i.tags+ ","+(texttags) i.save() if contenttext !="": - edit_description(vidid,contenttext) + edit_description(vidid,contenttext,str(request.user)) + if titlecontenttext !="": + new_ob = Gbobject.objects.get(id=int(vidid)) + new_ob.title = titlecontenttext + new_ob.save() gbobject = Gbobject.objects.get(id=videoid) vars=RequestContext(request,{'video':gbobject}) template="gstudio/transcript.html" return render_to_response(template,vars) -def edit_description(sec_id,title): +def edit_description(sec_id,title,usr): new_ob = Gbobject.objects.get(id=int(sec_id)) - new_ob.content_org = title - myfile = open('/tmp/file.org', 'w') + contorg=unicode(title) + ssid=new_ob.get_ssid.pop() + fname=str(ssid)+"-"+usr + new_ob.content_org=contorg.encode('utf8') + ext='.org' + html='.html' + myfile = open(os.path.join(FILE_URL,fname+ext),'w') myfile.write(new_ob.content_org) myfile.close() - myfile = open('/tmp/file.org', 'r') - myfile.readline() - myfile = open('/tmp/file.org', 'a') + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + rfile=myfile.readlines() + scontent="".join(rfile) + newcontent=scontent.replace("\r","") + myfile = open(os.path.join(FILE_URL,fname+ext),'w') + myfile.write(newcontent) + + #myfile.readline() + myfile = open(os.path.join(FILE_URL,fname+ext),'a') myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") myfile.write("\n#+TITLE: ") - myfile = open('/tmp/file.org', 'r') - stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + myfile = open(os.path.join(FILE_URL,fname+ext),'r') + stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) output = stdout.read() - data = open("/tmp/file.html") + data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[72:] data3 = data2[:-3] @@ -429,3 +545,13 @@ def edit_description(sec_id,title): new_ob.content = newdata new_ob.save() return True + +def md5Checksum(filePath): + fh = open(filePath, 'rb') + m = hashlib.md5() + while True: + data = fh.read(8192) + if not data: + break + m.update(data) + return m.hexdigest() |