小编ctu*_*fli的帖子

Google App Engine和404错误

我在GAE上使用其他地方找到的提示设置了静态网站,但无法弄清楚如何返回404错误.我的app.yaml文件看起来像

- url: (.*)/
  static_files: static\1/index.html
  upload: static/index.html

- url: /
  static_dir: static
Run Code Online (Sandbox Code Playgroud)

将所有静态html/jpg文件存储在静态目录下.以上适用于存在的文件,但如果不存在,则返回空长文件.答案可能是编写一个python脚本来返回404错误,但是如何设置为现有的静态文件提供服务但是为不存在的文件运行脚本呢?

以下是在开发应用程序服务器上获取不存在的文件(nosuch.html)的日志:

ERROR    2008-11-25 20:08:34,084 dev_appserver.py] Error encountered reading file "/usr/home/ctuffli/www/tufflinet/static/nosuch.html":
[Errno 2] No such file or directory: '/usr/home/ctuffli/www/tufflinet/static/nosuch.html'
INFO     2008-11-25 20:08:34,088 dev_appserver.py] "GET /nosuch.html HTTP/1.1" 404 -
Run Code Online (Sandbox Code Playgroud)

python google-app-engine http-status-code-404

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

在Windows PowerShell中更改路径分隔符

是否有可能让PowerShell始终输出/而不是\?例如,我希望get-location的输出为C:/ Documents and Settings/Administrator.

更新

感谢使用替换的示例,但我希望这可以在全球范围内发生(例如制表符完成等).根据Matt的观察,分隔符是由System.IO.Path.DirectorySeparatorChar定义的,它在实践中出现,并且从文档中是只读的,我猜这是不可能的.

powershell

15
推荐指数
2
解决办法
8980
查看次数

c联合和位域

可以在联合中使用位域吗?

c unions bit-fields

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

在C中使用位域的正确方法是什么?

我正在使用位域来轻松访问浮点库我试图为没有FPU的微控制器.

问题是我似乎无法使用bitfields.看一看:

typedef struct
{
   union{
    unsigned long mantissa: 23;
    unsigned long exponent: 8;
    unsigned long sign: 1;
    float all;

      };

}_float __attribute__((__packed__));
Run Code Online (Sandbox Code Playgroud)

问题是,当我尝试访问或更改任何内容时,它会将位域分别视为末尾的1,8,23位.虽然它应该是从末尾开始的23位,然后是8位然后是最后一位.除非我完全误解了bitfields的使用.我认为使用打包可以解决问题,但你可以看到它没有.

任何帮助将非常感激.我不止一次谷歌搜索这个网站,所以我寄予厚望.

c unions bit-fields

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

删除最终的bash脚本参数

我正在尝试编写一个脚本,在目录中搜索模式的文件和greps.类似于下面的东西,除了 find表达式要复杂得多(排除特定的目录和文件).

#!/bin/bash
if [ -d "${!#}" ]
then
    path=${!#}
else
    path="."
fi

find $path -print0 | xargs -0 grep "$@"
Run Code Online (Sandbox Code Playgroud)

显然,上述方法不起作用,因为"$@"仍然包含路径.我已经尝试通过迭代所有参数来构建参数列表的变体来排除路径,例如

args=${@%$path}
find $path -print0 | xargs -0 grep "$path"
Run Code Online (Sandbox Code Playgroud)

要么

whitespace="[[:space:]]"
args=""
for i in "${@%$path}"
do
    # handle the NULL case
    if [ ! "$i" ]
    then
        continue
    # quote any arguments containing white-space
    elif [[ $i =~ $whitespace ]]
    then
        args="$args \"$i\""
    else
        args="$args $i"
    fi
done

find $path -print0 | xargs -0 …
Run Code Online (Sandbox Code Playgroud)

bash shell arguments

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

rmmod时恐慌

你好,我是内核开发新手,

创建了一个简单的程序:

#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/kthread.h>

MODULE_LICENSE("Dual BSD/GPL");


int messager(void*);
struct task_struct* kthrstr;

static int start_module(void)
{
    printk(KERN_INFO "Loading the messager\n");

    kthrstr = kthread_create(messager,NULL,"MESSAGER");
    wake_up_process(kthrstr);
    return 0;
}

static void stop_module(void)
{
    printk(KERN_INFO "Unloading the messager\n");
    kthread_stop(kthrstr);
}

int messager(void* varg)
{
    daemonize("MESSAGER");
    allow_signal(SIGKILL);

    while(1)
    {   
        printk(KERN_INFO "Timeout: Hello");
        set_current_state(TASK_INTERRUPTIBLE);
        schedule_timeout(10 * HZ);
        if (signal_pending(current))
            break;  
    }
    return 0;
} 

module_init(start_module);
module_exit(stop_module);
Run Code Online (Sandbox Code Playgroud)

模块正确加载,消息也按预期显示在syslog中.但是当使用rmmod卸载模块时,它会发生恐慌,如下所示.请帮助我确定发生了什么错误以及如何纠正:

[ 2207.466086] Timeout: Hello
[ 2215.756784] Unloading the messager
[ 2217.461846] BUG: unable …
Run Code Online (Sandbox Code Playgroud)

linux linux-kernel

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

C :为一个函数参数发送不同的结构

我有一个使用 OpenGL 绘制圆的函数,我想向它传递一个包含 x 和 y 坐标以及半径的结构。问题是这个相同的函数必须与 3 个不同的结构一起使用,所有结构都包含坐标、半径和绘图函数不使用的其他一些内容。

有没有办法让 3 个不同的结构只有一个参数(一次只发送一个)。

我希望我说得足够精确。

PS:函数必须是“抽象的”。

c arguments structure function abstract

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

vmlinux中运行crash时没有调试数据来分析kernel panic

我正在尝试使用 kdump 和崩溃实用程序分析 openSUSE 11.3 上的 Linux 内核恐慌。系统成功创建了 vmcore 文件,但是当我去分析它时,崩溃抱怨缺少符号。

# crash -s vmlinux-2.6.34-12-desktop.gz vmcore
crash: vmlinux-2.6.34-12-desktop.gz: no debugging data available
crash: vmlinux-2.6.34-12-desktop.debug: debuginfo file not found

crash: either install the appropriate kernel debuginfo package, or
       copy vmlinux-2.6.34-12-desktop.debug to this machine
Run Code Online (Sandbox Code Playgroud)

系统正在运行库存桌面内核

# uname -r
2.6.34-12-desktop
Run Code Online (Sandbox Code Playgroud)

并安装了kernel-develkernel-desktop-devel包。其他一些包是否有调试符号(类似于 Red Hat 的 kernel-debuginfo rpm)或者我应该使用另一种方法/内核吗?

crash opensuse linux-kernel

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

试图禁止指令

是否可以使用GNU工具(gcc,binutils等)将所有出现的汇编指令修改为无操作?具体来说,带-pg选项的gcc会生成以下程序集(ARM):

   0x0: e1a0c00d    mov ip, sp
   0x4: e92dd800    stmdb   sp!, {fp, ip, lr, pc}
   0x8: e24cb004    sub fp, ip, #4  ; 0x4
   0xc: ebfffffe    bl  0 <mcount>
Run Code Online (Sandbox Code Playgroud)

我想记录最后一条指令的地址,然后将其更改为nop,如下面的代码所示

   0x0: e1a0c00d    mov ip, sp
   0x4: e92dd800    stmdb   sp!, {fp, ip, lr, pc}
   0x8: e24cb004    sub fp, ip, #4  ; 0x4
   0xc: e1a00000    nop         (mov r0,r0)
Run Code Online (Sandbox Code Playgroud)

Linux内核可以在运行时执行与此类似的操作,但我正在寻找构建时解决方案.

compiler-construction assembly linker gcc binutils

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