Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass parameters via "-" #45

Open
spikelo opened this issue Jul 30, 2021 · 3 comments
Open

How to pass parameters via "-" #45

spikelo opened this issue Jul 30, 2021 · 3 comments

Comments

@spikelo
Copy link

spikelo commented Jul 30, 2021

Action: UpdateConfig
ActionID:
SrcFilename:
DstFilename:
Reload:
PreserveEffectiveContext:
Action-000000:
Cat-000000:
Var-000000:
Value-000000:
Match-000000:
Line-000000:
Options-000000:

action = SimpleAction('UpdateConfig',
        reload='yes',
        dstfilename='test.conf',
        srcfilename='test.conf',
        Action-000000='NewCat',
        Cat-000000='test',
        Var-000000='foo',
        Value-000000='bar')

SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

@spikelo
Copy link
Author

spikelo commented Jul 30, 2021

Maybe it's not right but I did it this way

Passed the argument via _

action = SimpleAction('UpdateConfig',
        reload='yes',
        dstfilename='test.conf',
        srcfilename='test.conf',
        Action_000000='NewCat',
        Cat_000000='test',
        Var_000000='foo',
        Value_000000='bar')

replace _ to -

            key = key.replace('_', '-')
            package += '%s: %s\r\n' % (key, self.keys[key])

@krisak8911
Copy link

Maybe it's not right but I did it this way

Passed the argument via _

action = SimpleAction('UpdateConfig',
        reload='yes',
        dstfilename='test.conf',
        srcfilename='test.conf',
        Action_000000='NewCat',
        Cat_000000='test',
        Var_000000='foo',
        Value_000000='bar')

replace _ to -

            key = key.replace('_', '-')
            package += '%s: %s\r\n' % (key, self.keys[key])

The solution didn't work for me.

exception 'action-000000'

@ettoreleandrotognoli
Copy link
Owner

ettoreleandrotognoli commented Apr 8, 2022

I'm not sure about this exception that you said, sorry =/

But you can set the parameters using **

action = SimpleAction('UpdateConfig', **{ 'Action-00000' : 'test' })

Take a look at:

class SimpleAction(Action):
def __init__(self, name, **kwargs):
super(SimpleAction, self).__init__(name=name, keys=kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants