task()为关键字参数' appdynhost'提供了多个值。

时间:2016-03-16 09:25:31

标签: python python-2.7

我只是试图接收一个输入,通过一些if,elif条件运行它并从一堆行中替换某些文本:

    def task(appdynhost):
        if (appdynhost) == "security":
            appdynpass = 'xxxxxxxx'
        elif (appdynhost) == "security2":
            appdynpass = 'yyyyyyyy'
        elif (appdynhost) == "security3":
            appdynpass = 'zzzzzzzz'
        elif (appdynhost) == "security4":
            appdynpass = 'wwwwwwww'
        replacements = {'<controller_name>':appdynhost,'<controller_password>';appdynpass}

        s = r"""
"standardenv::v2_0_0_0_0":
"appgroups::v1_0_0_0_0":
definitions:
jdk: {gid: 5007}
app: {gid: 5008}
"appusers::v1_0_0_0_0":
definitions:
jdk: {group: jdk, uid: 5007}
app: {group: app, uid: 5008}
"jdk::v1_7_45_2_0::standard":
instance_owner: jdk
instance_group: jdk
"app::v1_1_2_1_0::standard":
instance_owner: app
instance_group: app
controller_host: "<controller_name>.saas.com"
account_name: "<controller_name>"
account_password: "<controller_password>" """
        line=s.split()
        for line in s.splitlines():
            for src, target in replacements.iteritems():
                line = line.replace(src, target)
            lines.append(line)
        with open('DC_mcp.yaml', 'w') as outfile:
            for line in lines:
                outfile.write(line + '\n')
                print (line)

我收到此错误:

Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/bdblib/task_runner.py", line 72, in run_bdblib_task
File "build/bdist.linux-x86_64/egg/bdblib/run.py", line 38, in run
return task_module.task(env, **inputs)
TypeError: task() got multiple values for keyword argument 'appdynhost'

我将appdynhost的输入作为原始输入。我不确定哪里出错了。

1 个答案:

答案 0 :(得分:0)

“task”函数的定义只有一个名为“appdynhost”的参数。

    def task(appdynhost):
            ...

你的电话有几个:

    return task_module.task(env, **inputs)
    TypeError: task() got multiple values for keyword argument 'appdynhost'

无论是功能还是通话,您都需要修复输入。