python-ami icon indicating copy to clipboard operation
python-ami copied to clipboard

How to pass parameters via "-"

Open spikelo opened this issue 4 years ago • 3 comments

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 avatar Jul 30 '21 11:07 spikelo

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])

spikelo avatar Jul 30 '21 11:07 spikelo

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'

krisak8911 avatar Apr 08 '22 13:04 krisak8911

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: https://github.com/ettoreleandrotognoli/python-ami/blob/31309d8e329b161b34f9b52f2f3fbd933d859a03/asterisk/ami/action.py#L30-L32

ettoreleandrotognoli avatar Apr 08 '22 13:04 ettoreleandrotognoli