“Mercurial 仅支持编码字符串”错误?

问题描述 投票:0回答:1

我搬到了一个新服务器,并尝试使用 Mercurial 的 hgweb 服务器。一如既往,它在旧服务器上运行良好......

Ubuntu 22, 蟒蛇3.10, 水银 6.1

我在访问网址时遇到此错误

https://url/hg
,我找不到任何有关“Mercurial 仅支持编码字符串”的参考?

[Sun Mar 24 16:48:30.464715 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215: Traceback (most recent call last):: /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.464776 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215:   File "/var/www/cgi-hg/hgweb.cgi", line 21, in <module>: /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.464798 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215:     application = hgweb("hgweb.config"): /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.464864 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215:   File "/usr/lib/python3/dist-packages/mercurial/hgweb/__init__.py", line 41, in hgweb: /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.464894 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215:     raise error.ProgrammingError(: /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.464945 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] AH01215: mercurial.error.ProgrammingError: Mercurial only supports encoded strings: 'hgweb.config': /var/www/cgi-hg/hgweb.cgi
[Sun Mar 24 16:48:30.473397 2024] [cgi:error] [pid 41415] [client 172.0.6.80:56644] End of script output before headers: hgweb.cgi

脚本 hgweb.cgi

#!/usr/bin/env python3
#
# An example hgweb CGI script, edit as necessary
# See also https://mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/var/www/cgi-hg/hbweb.config"

# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport

demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi

application = hgweb("hgweb.config")
wsgicgi.launch(application)

这里是hgweb.config

[paths]
#VIRTUAL_PATH = /REAL/PATH
#mbel  = /home/repos/mbel
admin = /home/repos/admin
mbepp = /home/repos/mbepp
mbepEditor = /home/repos/mbepEditor
monitor= /home/repos/monitor
solrproxy= /home/repos/solrproxy
mbep-data= /home/repos/mbep-data
mbep-util= /home/repos/mbep-util
mbep-editor= /home/repos/mbep-editor
installer=/home/repos/installer
updater=/home/repos/updater

[web]
style = gitweb
# descend = true

这是 apacheconf 文件 hg.conf

ScriptAliasMatch        ^/hg(.*)        /var/www/cgi-hg/hgweb.cgi/$1

<Directory /var/www/cgi-hg/>
        Options ExecCGI FollowSymLinks Indexes MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

<Directory /home/repos/>
 Options FollowSymLinks
 AllowOverride None
 Allow from all
</Directory>

<Location /hg>
 Options FollowSymLinks
# AllowOverride None
 Allow from all
#    AuthType Basic
#    AuthName "Mercurial repositories"
#    AuthUserFile /home/repos/repospassword
#    Require valid-user
</Location>

我不是Python程序员,我很困惑......

谢谢斯科特

python-3.x apache mercurial hgweb
1个回答
3
投票

当然是编程错误。

两条线

config= "/var/www/cgi-hg/hgweb.cgi"

更改为

config= b"/var/www/cgi-hg/hgweb.cgi"

b 以某种方式表示编码?

application = hgweb("hgweb.config")

成为

application = hgweb(config)

hgweb() 调用需要一个上面设置的变量作为配置?

这是修复后的 hgweb.cgi 文件

#
# An example hgweb CGI script, edit as necessary
# See also https://mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = b"/var/www/cgi-hg/hgweb.config"

# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport

demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi

application = hgweb(config)
wsgicgi.launch(application)
© www.soinside.com 2019 - 2024. All rights reserved.