【问题标题】:TypeError: __init__() got an unexpected keyword argument 'options'TypeError: __init__() 得到了一个意外的关键字参数“选项”
【发布时间】:2017-08-09 16:08:41
【问题描述】:

我收到来自 python 脚本的错误。错误如下所示。在下面的源代码中,我有一个来自 session.py 和 ssh_session.py 的 python 脚本的 sn-p 来自问题中的行。根据错误,似乎参数选项被赋予了一个由 super 表示的类,而该类不知道参数选项。令人费解的是,虽然这是我第一次使用这组脚本,但我知道其他人一直成功地使用这组脚本。所以我开始想,也许我有一个与 python 模块相关的版本问题。任何人都可以阐明错误的性质,即 __init__ 会因为意外的关键字参数而大喊大叫,而它似乎对其他所有人都有效?如果是模块问题,我怎么才能知道参数何时或在哪个版本存在或被删除?

2017-03-17 16:23:36,303-07 ERROR        -   File "/home/rmaes/.local/lib/python2.7/site-packages/ctf/ssh_session.py", line 92, in __init__
2017-03-17 16:23:36,303-07 ERROR        -   interactOnFailure=interactOnFailure, verbose=verbose, logLevel=logLevel)
2017-03-17 16:23:36,303-07 ERROR        -   File "/home/rmaes/.local/lib/python2.7/site-packages/ctf/session.py", line 376, in __init__
2017-03-17 16:23:36,303-07 ERROR        -   env=self.env)
2017-03-17 16:23:36,303-07 ERROR        -   TypeError: __init__() got an unexpected keyword argument 'options'
2017-03-17 16:23:36,303-07 ERROR        -   End traceback.
2017-03-17 16:23:36,304-07 INFO         - END ANCILLARY "_testRunSuite"
2017-03-17 16:23:36,304-07 INFO         - Exception forces exit because exit-on-error is True.

ssh_session 第 92 行

super (Ssh, self).__init__(timeout=timeout, maxread=maxread,
       searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env,
       ignore_sighup=ignore_sighup, echo=echo, options=options,
       encoding=encoding, codec_errors=codec_errors,
       interactOnFailure=interactOnFailure, verbose=verbose, logLevel=logLevel)


def login (self, host, username, password='', terminal_type='ansi',
           original_prompt=r"[#$]", login_timeout=10, port=22,
           auto_prompt_reset=True, ssh_key=None, quiet=True,
           sync_multiplier=1, check_local_ip=True):

session.py 第 375-376 行

 # Instantiate the pxssh sub-class
        super (PxsshSession, self).__init__(timeout=self.timeout,
                                            maxread=self.maxread,
                                            searchwindowsize=self.searchwindowsize,
                                            logfile=self.logfile,
                                            options=self.options,
                                            ignore_sighup=self.ignore_sighup,
                                            cwd=self.cwd,
                                            env=self.env)

【问题讨论】:

    标签: python python-2.7 pxssh


    【解决方案1】:

    因此,pexpect 4.0.1 中引入的更改似乎解决了我看到的问题,但是,我仍然无法确定该更改是什么。 GITHUB 有一个为 4.0.1 创建的标签,但没有正式发布,也没有发布说明。 4.1.0 的官方发行说明似乎没有暗示与“选项”作为参数添加或删除有关的任何事情。但很明显,任何比 pexpect 4.0.1 更远的东西都可以解决这个问题。

    【讨论】:

      猜你喜欢
      • 2012-12-11
      • 1970-01-01
      • 2017-10-16
      • 2020-10-22
      • 2021-11-17
      • 2016-11-01
      • 2021-10-21
      • 2021-10-15
      • 2021-12-30
      相关资源
      最近更新 更多