def handle(self, *args, **options): environ_path = unicode(os.environ["PATH"]) os.environ["PATH"] += u":{0}:".format(settings.ENVIRON_BIN_PATH) docs_path = os.path.join(settings.BASE_DIR, 'docs') message = [] for doc_name in os.listdir(docs_path): doc_path = os.path.join(docs_path, doc_name) doc_build_path = os.path.join(doc_path, "_build") if os.path.exists(doc_build_path): shutil.rmtree(doc_build_path) if os.path.isdir(doc_path): message.append(u'='*20) message.append(doc_path) message.append(u'='*20) message.append( u'\n----------\n'.join( subprocess.Popen( ["make", "html"], env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=doc_path).communicate())) send_email_notification.delay( title=u'Конспекты собраны', message=u'\n'.join(message)) os.environ["PATH"] = environ_path
def handle(self, *args, **options): environ_path = unicode(os.environ["PATH"]) os.environ["PATH"] += u":{0}:".format(settings.ENVIRON_BIN_PATH) docs_path = os.path.join(settings.BASE_DIR, 'docs') message = [] for doc_name in os.listdir(docs_path): doc_path = os.path.join(docs_path, doc_name) doc_build_path = os.path.join(doc_path, "_build") if os.path.exists(doc_build_path): shutil.rmtree(doc_build_path) if os.path.isdir(doc_path): message.append(u'=' * 20) message.append(doc_path) message.append(u'=' * 20) message.append(u'\n----------\n'.join( subprocess.Popen(["make", "html"], env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=doc_path).communicate())) send_email_notification.delay(title=u'Конспекты собраны', message=u'\n'.join(message)) os.environ["PATH"] = environ_path
def comment_create(request, post_slug): try: post = Post.objects.get(slug=post_slug) except Post.DoesNotExist: raise Http404() if "content_raw" not in request.POST: return redirect( reverse("blog:post_detail", args=[post.category.name, post_slug])) if not post.published and not request.user.is_superuser: raise PermissionDenied() comment = Comment() if request.user.is_authenticated(): comment.user = request.user else: if ('user_name' not in request.POST or 'user_email' not in request.POST): return redirect( reverse( "blog:post_detail", args=[post.category.name, post_slug])) comment.user_name = request.POST['user_name'] comment.user_email = request.POST['user_email'] comment.content_raw = request.POST['content_raw'] comment.post = post comment.save() send_email_notification.delay( title=u'Новый коментарии', message=u'Новый коменатрии \n{0}\n{1}'.format( reverse('blog:post_detail', args=[post.category.name, post_slug]), datetime.datetime.now())) return redirect( reverse("blog:post_detail", args=[post.category.name, post_slug]))