gpt4 book ai didi

python - 文件传送器错误 - UnboundLocalError : local variable 'classname' referenced before assignment

转载 作者:太空宇宙 更新时间:2023-11-03 18:28:34 25 4
gpt4 key购买 nike

我正在使用 fileconbayor 形式 https://github.com/wimleers/fileconveyor

但是当我运行脚本时出现以下错误。

Traceback (most recent call last):
File "arbitrator.py", line 1185, in <module>
run_file_conveyor()
File "arbitrator.py", line 1168, in run_file_conveyor
arbitrator = Arbitrator(os.path.join(FILE_CONVEYOR_PATH, "config.xml"), rest
art)
File "arbitrator.py", line 142, in __init__
transporter_class = self._import_transporter(transporter_name)
File "arbitrator.py", line 1162, in _import_transporter
self.logger.error("The Transporter module '%s' was found, but its Transporte
r class '%s' could not be found." % (module_name, classname))
UnboundLocalError: local variable 'classname' referenced before assignment
[root@af-server fileconveyor]#

这是仲裁者.py 第 142 行的代码

   # Verify that all referenced transporters are available.
transporters_not_found = 0
for server in self.config.servers.keys():
transporter_name = self.config.servers[server]["transporter"]
transporter_class = self._import_transporter(transporter_name)
if not transporter_class:
transporters_not_found += 1
if transporters_not_found > 0:
raise TransporterAvailabilityTestError("Consult the log file for details")

以及第 1162 行的代码

transporter_class = None
module = None
alternatives = [transporter]
default_prefix = 'transporters.transporter_' # Not 'fileconveyor.transporters.transporter_'!
if not transporter.startswith(default_prefix):
alternatives.append('%s%s' % (default_prefix, transporter))
for module_name in alternatives:
try:
module = __import__(module_name, globals(), locals(), ["TRANSPORTER_CLASS"], -1)
except ImportError:
pass
if not module:
msg = "The transporter module '%s' could not be found." % transporter
if len(alternatives) > 1:
msg = '%s Tried (%s)' % (msg, ', '.join(alternatives))
self.logger.error(msg)
else:
try:
classname = module.TRANSPORTER_CLASS
module = __import__(module_name, globals(), locals(), [classname])
transporter_class = getattr(module, classname)
except AttributeError:
self.logger.error("The Transporter module '%s' was found, but its Transporter class '%s' could not be found." % (module_name, classname))
return transporter_class

这是该文件的完整代码

http://pastebin.com/ctsLrckq

最佳答案

当我安装 fileconveyor 或按照指南 INSTALL.txt 时,我遇到了同样的错误。看起来有一些 Unresolved 依赖关系。尝试用以下方法解决:

pip install django-cumulus==1.0.10

关于python - 文件传送器错误 - UnboundLocalError : local variable 'classname' referenced before assignment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22761891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com