小编Jaq*_*sos的帖子

Elastic Beanstalk中的Django POST侦听器接收AWS Worker层请求

我正在尝试设置一个工作环境来运行后台任务.我在两个环境中运行相同的应用程序版本,一个是Web服务器,另一个是Worker.

我需要根据到期日期定期删除文件.我已将视图映射为localhost上的URL,其中消息将作为HTTP POST请求转发.该任务正在安排,似乎SQS正在运行,但消息都在WorkerDeadLetterQueue.

在日志文件中我收到了请求但是403错误:

在/ var /日志/的httpd /访问日志:

"POST/networks_app/delete_expired_files HTTP/1.1"403 2629" - ""aws-sqsd/2.0"

这个在/var/log/aws-sqsd/default.log:

消息:发送到%[ http:// localhost:80/networks_app/delete_expired_files] 2016-01-23T14:58:05Z http-err:d5f645cf-ce15-40bc-8ee3-34acb79e797b(4)403 - 0.007

这是我的views.py代码:

def delete_expired_files(request):
    if request.method == 'POST':
        users = DemoUser.objects.all()
        for user in users:
            documents = Document.objects.filter(owner=user.id)
            if documents:
                for doc in documents:
                    now = timezone.now()
                    if now >= doc.date_published + timedelta(days = doc.owner.group.valid_time):
                        doc.delete()
Run Code Online (Sandbox Code Playgroud)

该cron.yaml文件:

version: 1
cron:
 - name: "delete_expired_files"
   url: "/networks_app/delete_expired_files"   
   schedule: "* * …
Run Code Online (Sandbox Code Playgroud)

python django worker amazon-ec2 amazon-web-services

6
推荐指数
1
解决办法
562
查看次数

AWS Elastic BeansTalk Django cronjob发布请求返回403错误

我正在开发一个软件功能,我必须使用Django + cron + AWS定期删除文件.问题是我无法使其发挥作用.什么是让它发挥作用的最佳方法?我错过了一些AWS配置吗?我已经配置了一个Web服务器和一个工作环境,在它们上部署了相同的应用程序版本.任务是映射到url的视图(访问url函数执行).工作者环境有一条确认消息:

从cron.yaml成功加载了1个计划任务.

但是对于worker access_log也有403错误:

"POST/networks_app/delete_expired_files HTTP/1.1"403 2629" - ""aws-sqsd/2.0"

cron.yaml:

version: 1
cron:
 - name: "delete_expired_files"
   url: "/networks_app/delete_expired_files"
   schedule: "10 * * * *"
Run Code Online (Sandbox Code Playgroud)

在urls.py上的 url映射:

urlpatterns = [
    url(r'^delete_expired_files', views.delete_expired_files, name='delete_expired_files'),
]
Run Code Online (Sandbox Code Playgroud)

用于删除views.py文件的函数:

def delete_expired_files(request):
    users = DemoUser.objects.all()
    for user in users:
        documents = Document.objects.filter(owner=user.id)
        if documents:
            for doc in documents:
                now = timezone.now()
                if now >= doc.date_published + timedelta(days=doc.owner.group.valid_time): …
Run Code Online (Sandbox Code Playgroud)

python django cron amazon-web-services amazon-elastic-beanstalk

6
推荐指数
1
解决办法
235
查看次数

如何定义水壶的启发式功能?

我试图将水壶问题放入启发式功能中,但我发现了一些问题.

有2个水壶,一个可容纳5(x),另一个可容纳3(y)加仑的水.目标是(y,x)=(0,4).

我无法弄清楚如何将它放入启发式函数中,而且我对状态的数量有疑问.如果我承认这些动作(从龙头中取出一个,将一个倒入排水管,从一个倒到另一个,直到接收水壶装满或浇水壶是空的),有15个可能的状态,但如果我考虑关于加仑数的所有可能性,有24种可能性.那是对的吗?

(0,0)

(3,0)(0,5)

(0,3)(3,5)(3,2)

(3,3)(0,2)

(1,5)(2,0)

(1,0)(2,5)

(0,1)(3,4)

(0,4)

我认为这个问题的启发式函数可以定义为:

h(x,y) = (x * 5) + (y * 3)
Run Code Online (Sandbox Code Playgroud)

但我也找到了一个问题的答案(水壶的启发式功能),现在我很困惑.有人能解释一下吗?

max(estimate_from_parent - action_cost,estimate_from_this_node)

algorithm search artificial-intelligence heuristics a-star

4
推荐指数
1
解决办法
4226
查看次数

如何修复在laravel中找不到的类'App\Http\Controllers\Notification'?

我有一个Controller,它监听一个新的Schedule创建,并通过ajax将结果发送回视图.在其中,我想添加通知,以便在由于特定日期和时间缺乏资源而无法完成计划时向用户发送电子邮件.

问题是我得到以下错误:

Class 'App\Http\Controllers\Notification' not found in /laravel/app/Http/Controllers/DadosAgendamentoController.php on line 89
Run Code Online (Sandbox Code Playgroud)

文件夹结构是这样的:

-app
    -Http
        -Controllers 
            DadosAgendamentoController.php
    -Notifications
        AgendamentoPendente.php
Run Code Online (Sandbox Code Playgroud)

DadosAgendamentoController.php头码:

namespace App\Http\Controllers;

use Input;
use Request;
use App\Servicos;
use App\Disponibilidades;
use App\Estabelecimentos;
use App\HorariosEstabelecimento;
use App\Agendamento;
use App\User;
use App\Notifications\AgendamentoPendente;
Run Code Online (Sandbox Code Playgroud)

第88和89行:

$user = User::where('id',1)->get();
Notification::send($user, new AgendamentoPendente(1));
Run Code Online (Sandbox Code Playgroud)

通过我的控制器我可以访问上面的所有类,但不能访问AgendamentoPendente

我的目标是发送电子邮件给管理员,这样当资源在所需的日期和时间不可用时,他可以向客户建议新的日期和时间.

怎么修好?我可以在此Controller中访问该类吗?怎么样?

php facade laravel laravel-5

4
推荐指数
2
解决办法
9558
查看次数

jQuery在click事件上设置动画后增加css属性的值

我希望从底部和淡入淡出到底部的效果,基于元素的属性margin-top,但我没有我想要的结果.它在第一次工作正常,淡入淡出.但是当我第二次执行它时,属性的值比它应该的大10px.每当我点击一下并淡出时,当我点击再次出现时,它比上一次多10px.我该怎么做才不增加这个值?代码在上面.请帮帮我吧!谢谢.

$(document).on("click",".nav-menu",function(){
    var $initial_margin_top = $(".w-clearfix.nav-menu-ul").css("margin-top"); 
    var $margin_num = parseInt($initial_margin_top.split("px")[0]) + 10; 
    if($(this).hasClass("nav-menu-hover")){ 
        $(".w-clearfix.nav-menu-ul").animate({"margin-top": $margin_num+"px","opacity":"0"}); 
        $(".w-clearfix.nav-menu-ul").css({"margin-top": $initial_margin_top});
        $(this).removeClass("nav-menu-hover");
    }else if(!$(this).hasClass("nav-menu-hover")){ 
        $(this).addClass("nav-menu-hover");  
        $(".w-clearfix.nav-menu-ul").css({"margin-top": $margin_num+"px" ,"opacity":"0"});
        $(".w-clearfix.nav-menu-ul").removeClass("hide");
        $(".w-clearfix.nav-menu-ul").animate({"margin-top": $initial_margin_top,"opacity":"1","margin-left":"-1px"}); 
        $(".w-clearfix.nav-menu-ul").css({"margin-top": $initial_margin_top});
    }
});
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

3
推荐指数
1
解决办法
431
查看次数

如何在可执行文件中使用 pyinstaller 包含特定的 .jar 文件?

打包为 exe 时,如何强制 pyinstaller 使用特定的 .jar 文件?

我正在尝试生成一个使用tabula-py lib的可执行文件。这个库需要一个 jar 文件tabula-1.0.1-jar-with-dependencies.jar,我在我的 file.py 文件夹中有它。这些是myfile.spec中的一些修改:

# this is for pandas lib
def get_pandas_path():
    import pandas
    pandas_path = pandas.__path__[0]
    return pandas_path

dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries)

# this is for tabula-py
jar = 'tabula-1.0.1-jar-with-dependencies'
jar_path = 'C:\\Users\\jaquedeveloper\\Documents\\freelancer\\bot\\' + jar
coll = COLLECT(exe,
       a.binaries,
       a.zipfiles,
       a.datas,
       [(jar, jar_path, 'PKG')],
       strip=None,
       upx=True,
       name='test')
Run Code Online (Sandbox Code Playgroud)

尽管如此,错误仍然存​​在。当我从命令行运行我的代码时,来自使用 java jar 的 tabula-py …

python java jar pyinstaller

0
推荐指数
1
解决办法
1428
查看次数