"TypeError: execve() arg 3 contains a non-string value" on running a submin generic hook
"TypeError: execve() arg 3 contains a non-string value" on running a submin generic hook
我已经安装了 submin 并且能够创建和配置 subversion 存储库。
我想配置 submin 以在创建存储库时复制我的颠覆挂钩。
Submin 有一个 Generic Hook mechanism 但我没能让它工作。 hook目录有好几个,wiki没告诉我用哪个hook目录。
我添加了一个简单的脚本到:
/var/lib/submin/hooks/repository-create/copy-hooks
& 我将所有权设置为 www-data。在创建存储库时收到错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/submin/hooks/common.py", line 24, in trigger_hook
trigger_user_hook(event, **args)
File "/usr/local/lib/python2.7/dist-packages/submin/hooks/common.py", line 51, in trigger_user_hook
p = Popen([hook], env=env)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
TypeError: execve() arg 3 contains a non-string value
看来我有 triggered/created 用户挂钩但有错误。
编辑:
代码创建字典:
env = dict([(key.upper(), value) for key, value in args.iteritems()
if value])
它传递给 popen()。
'args' 是使用以下方法创建的:
trigger_hook('repository-create', admin_username=session_user,
repositoryname=name, vcs_type=vcs_type)
正在研究 'arg 3' 错误,最可能的原因是 'env' 字典包含非字符串,通常是 Unicode 字符串。在 popen() 和
之前添加 'env' 的调试
type: <type 'unicode'> value: new
type: <class 'submin.models.user.User'> value: admin
type: <type 'unicode'> value: svn
所以我传递了一个 class 和 Unicode 字符串。
我不确定如何将 class 值和 Unicode 字符串转换为字符串。如何在循环中对字符进行字符串化?解决路由原因似乎是更好的选择,但对 hack 会很满意。
编辑 2:
我同意,class 的传递是我的想法。
但是您的代码会引发语法错误,而且我的 Python 还不足以进行调试,至少要快速调试!
fyi 调用代码调用两组钩子,工具的钩子函数和用户钩子:
# Then execute all hooks
if event in hooks:
for hook_fn in hooks[event]:
hook_fn(**args)
trigger_user_hook(event, **args)
所以我需要在本地进行更改。
字典 'env' 是从 'args' 构造的。
关键是 'ADMIN_USERNAME',class 有一个方法 _getName(self)。我可以看到要调用什么(?)但是我在语法上苦苦挣扎....
请提供代码。
编辑 3
谢谢。 'trigger-user-hook' 中的新修复程序和原始转换循环都将 class 转换为文本。代码不再报错,但我的脚本没有 运行。
我的脚本在 submin 之外工作。
PS 由于缺乏代表,我无法投票。
在第 51 行之前将 hook
的调试打印添加到 /usr/local/lib/python2.7/dist-packages/submin/hooks/common.py
可以阐明 "arg 3".
的具体问题
更新:
这是 execve()
的 POSIX 版本中处理 env
并给出错误的代码(Python-2.7.9/Modules/posixmodule.c:3248
;仅显示相关行):
keys = PyMapping_Keys(env);
vals = PyMapping_Values(env);
<...>
for (pos = 0; pos < i; pos++) {
<...>
key = PyList_GetItem(keys, pos);
val = PyList_GetItem(vals, pos);
<...>
if (!PyArg_Parse(
key,
"s;execve() arg 3 contains a non-string key",
&k) ||
!PyArg_Parse(
val,
"s;execve() arg 3 contains a non-string value",
&v))
{
goto fail_2;
}
如Parsing arguments and building values - C API docs所说,'s'
表示str
或unicode
;如果嵌入 [=21=]
s,则 TypeError
被引发;如果 unicode
无法使用 默认编码 进行转换,则会引发 UnicodeError
。
所以,它实际上在 type: <class 'submin.models.user.User'> value: admin
上窒息。
更新2:
在 submin-2.2.1/models/repository.py
中创建并传递了违规值。这是解决此问题的差异:
--- a/submin/models/repository.py
+++ b/submin/models/repository.py
@@ -78,7 +78,7 @@ class Repository(object):
def add(vcs_type, name, session_user):
vcs = models.vcs.get(vcs_type, "repository")
vcs.add(name)
- trigger_hook('repository-create', admin_username=session_user,
+ trigger_hook('repository-create', admin_username=unicode(session_user),
repositoryname=name, vcs_type=vcs_type)
def __init__(self, repositoryname, vcs_type):
我创建了一个拉取请求以将其应用到官方代码库中:https://github.com/mjholtkamp/submin/pull/1
我已经安装了 submin 并且能够创建和配置 subversion 存储库。
我想配置 submin 以在创建存储库时复制我的颠覆挂钩。
Submin 有一个 Generic Hook mechanism 但我没能让它工作。 hook目录有好几个,wiki没告诉我用哪个hook目录。
我添加了一个简单的脚本到:
/var/lib/submin/hooks/repository-create/copy-hooks
& 我将所有权设置为 www-data。在创建存储库时收到错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/submin/hooks/common.py", line 24, in trigger_hook
trigger_user_hook(event, **args)
File "/usr/local/lib/python2.7/dist-packages/submin/hooks/common.py", line 51, in trigger_user_hook
p = Popen([hook], env=env)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
TypeError: execve() arg 3 contains a non-string value
看来我有 triggered/created 用户挂钩但有错误。
编辑: 代码创建字典:
env = dict([(key.upper(), value) for key, value in args.iteritems()
if value])
它传递给 popen()。 'args' 是使用以下方法创建的:
trigger_hook('repository-create', admin_username=session_user,
repositoryname=name, vcs_type=vcs_type)
正在研究 'arg 3' 错误,最可能的原因是 'env' 字典包含非字符串,通常是 Unicode 字符串。在 popen() 和
之前添加 'env' 的调试type: <type 'unicode'> value: new
type: <class 'submin.models.user.User'> value: admin
type: <type 'unicode'> value: svn
所以我传递了一个 class 和 Unicode 字符串。 我不确定如何将 class 值和 Unicode 字符串转换为字符串。如何在循环中对字符进行字符串化?解决路由原因似乎是更好的选择,但对 hack 会很满意。
编辑 2: 我同意,class 的传递是我的想法。 但是您的代码会引发语法错误,而且我的 Python 还不足以进行调试,至少要快速调试!
fyi 调用代码调用两组钩子,工具的钩子函数和用户钩子:
# Then execute all hooks
if event in hooks:
for hook_fn in hooks[event]:
hook_fn(**args)
trigger_user_hook(event, **args)
所以我需要在本地进行更改。 字典 'env' 是从 'args' 构造的。 关键是 'ADMIN_USERNAME',class 有一个方法 _getName(self)。我可以看到要调用什么(?)但是我在语法上苦苦挣扎.... 请提供代码。
编辑 3 谢谢。 'trigger-user-hook' 中的新修复程序和原始转换循环都将 class 转换为文本。代码不再报错,但我的脚本没有 运行。 我的脚本在 submin 之外工作。 PS 由于缺乏代表,我无法投票。
在第 51 行之前将 hook
的调试打印添加到 /usr/local/lib/python2.7/dist-packages/submin/hooks/common.py
可以阐明 "arg 3".
更新:
这是 execve()
的 POSIX 版本中处理 env
并给出错误的代码(Python-2.7.9/Modules/posixmodule.c:3248
;仅显示相关行):
keys = PyMapping_Keys(env);
vals = PyMapping_Values(env);
<...>
for (pos = 0; pos < i; pos++) {
<...>
key = PyList_GetItem(keys, pos);
val = PyList_GetItem(vals, pos);
<...>
if (!PyArg_Parse(
key,
"s;execve() arg 3 contains a non-string key",
&k) ||
!PyArg_Parse(
val,
"s;execve() arg 3 contains a non-string value",
&v))
{
goto fail_2;
}
如Parsing arguments and building values - C API docs所说,'s'
表示str
或unicode
;如果嵌入 [=21=]
s,则 TypeError
被引发;如果 unicode
无法使用 默认编码 进行转换,则会引发 UnicodeError
。
所以,它实际上在 type: <class 'submin.models.user.User'> value: admin
上窒息。
更新2:
在 submin-2.2.1/models/repository.py
中创建并传递了违规值。这是解决此问题的差异:
--- a/submin/models/repository.py
+++ b/submin/models/repository.py
@@ -78,7 +78,7 @@ class Repository(object):
def add(vcs_type, name, session_user):
vcs = models.vcs.get(vcs_type, "repository")
vcs.add(name)
- trigger_hook('repository-create', admin_username=session_user,
+ trigger_hook('repository-create', admin_username=unicode(session_user),
repositoryname=name, vcs_type=vcs_type)
def __init__(self, repositoryname, vcs_type):
我创建了一个拉取请求以将其应用到官方代码库中:https://github.com/mjholtkamp/submin/pull/1