小编Dec*_*eck的帖子

如何将STDOUT和STDERR重定向到变量

我想重定向STDERRSTDOUT一个变量.我这样做了

close(STDOUT);
close(STDERR);

my $out;
open(STDOUT, ">>", \$out);
open(STDERR, ">>", \$out);

for(1..10)
{
    print "print\n"; # this is ok. 
    warn "warn\n"; # same
    system("make"); # this is lost. neither in screen nor in variable.
}
Run Code Online (Sandbox Code Playgroud)

这个问题system.我也希望捕获此调用的输出.

perl redirect stdout system stderr

11
推荐指数
3
解决办法
2万
查看次数

使用Python中的记录模块进行颜色记录

让我们简化一下.我的目标是使用Python中的日志记录模块在终端中进行颜色输出.我希望info有一个绿色前缀,警告有一个黄色前缀,错误有一个红色前缀.为简单起见,我们将其***用作前缀即

*** log text
*** another message with another prefix color
Run Code Online (Sandbox Code Playgroud)

到目前为止我做了什么

# declaration of function (global scope)
log = None
warn = None
error = None 
def build_log_funcs():
    # why I initialize it inside the function ?
    # because script doesnt have to know about logging method
    # the function just provide log  functions
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)

    sh = logging.StreamHandler()
    # LOG_FORMAT just global variable with pattern including %(levelmarks)s
    # it will be replaced …
Run Code Online (Sandbox Code Playgroud)

python logging

9
推荐指数
1
解决办法
3884
查看次数

如何使用gunicorn运行Flask应用程序?

该问题可以分为两个单独的部分。

  1. 我有以下项目结构

    |- project
    |   |-- app/ - directory with actual project code
    |   |-- app.py - imports something from app/ and call create_app
    
    Run Code Online (Sandbox Code Playgroud)

    当我运行时gunicorn,我应该将他指向app实际在app.py. 所以我收到一个错误,因为gunicorn 将其视为app:app一个包。唯一的办法是重命名一些东西?

  2. 我使用工厂方法来创建应用程序。所以我在 app.py 中导入create_app函数并将其传递给Managerfrom flask.ext.script。我将管理器对象传递给gunicorn。在这种情况下,gunicorn 可以正确运行,但是一旦第一个请求到来,我就会收到以下错误:

    [2015-03-25 15:38:11 +0000] [14395] [ERROR] Error handling request
    Traceback (most recent call last):
      File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 52, in handle
    self.handle_request(listener_name, req, client, addr)
      File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 159, in handle_request
    super(GeventWorker, self).handle_request(*args)
      File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 105, …
    Run Code Online (Sandbox Code Playgroud)

python flask gunicorn

5
推荐指数
1
解决办法
3496
查看次数

推荐一个c ++ lib来使用http

我需要一个库来处理http(c ++,c).它必须发送和接收http请求.它将在服务器中用于回答http请求.我的客户端 - 服务器交互应该使用REST模型.

c c++ http

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

不能使用GNUstep在Objective-C上构建程序

我正在尝试在Linux上的Objective-C(Ubuntu)上构建hello world.main.c中

#import <Foundation/Foundation.h>

int main(void)
{

    NSLog(@"asdasd");  
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我不认为这里有错误.然后我创建了Makefile:

GNUSTEP_MAKEFILES = /usr/share/GNUstep/Makefiles

include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = main
main_OBJC_FILES = main.m
include $(GNUSTEP_MAKEFILES)/tool.make
Run Code Online (Sandbox Code Playgroud)

然后我运行"make":

This is gnustep-make 2.2.0. Type 'make print-gnustep-make-help' for help.
Making all for tool main...
make[1]: GNUmakefile: no such file or directory
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

linux objective-c gnu-make gnustep

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

标签 统计

python ×2

c ×1

c++ ×1

flask ×1

gnu-make ×1

gnustep ×1

gunicorn ×1

http ×1

linux ×1

logging ×1

objective-c ×1

perl ×1

redirect ×1

stderr ×1

stdout ×1

system ×1