Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:43:17+00:00 2026-05-25T00:43:17+00:00

Thus far I was handling multiple arguments via Optparse as a string, Eg: –update_entities=host_group

  • 0

Thus far I was handling multiple arguments via Optparse as a string,
Eg:

--update_entities="host_group hostname entity_type entities2monitor"

where entities2monitor has variable arguments, grabbing them inside the callback function via (notice the [3:]),

host = value.split()
(host_group, hostname, entity_type, entities2monitor) = (host[0], host[1], host[2], host[3:])

But how should I approach it when I need to feed parameters of the following form into a callback?
(I have control over the SQL which will generate the Optparse input string)

  • action_name: a space delimited string. (Eg: 'TEST ACTION')

  • hostgroup: a string

  • actions_holder: a list comprised by:

    • condition_type (string)
    • condition_operator (string)
    • condition_filter (space delimited string)

and

  • operations_holder: a list comprised by:
    • operation_type: (string)
    • operation_sendto: (string)

Example:

--create_action='''TEST ACTION | client_service_platform | "CONDITION_TYPE_TRIGGER_NAME CONDITION_OPERATOR_LIKE Weighted Successful" "CONDITION_TYPE_HOST CONDITION_OPERATOR_EQUAL host01" | "OPERATION_TYPE_MESSAGE userid1" "OPERATION_TYPE_EMAIL userid1" "OPERATION_TYPE_EMAIL userid2"'''

This is what I have so far,

actions_splits = actions_parameters.split(" | ")
action_name = actions_splits[0]
hostgroup = actions_splits[1]
actions_holder = actions_splits[2].strip('"').split('" "')
operations_holder = actions_splits[3].strip('"').split('" "')

which kind of works but is there a more seamless way to get these parameters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:43:17+00:00Added an answer on May 25, 2026 at 12:43 am

    what about using a namedtuple here:

    import collections
    Action = collections.namedtuple('Action', 'name hostgroup actions operations')
    

    use ; and , to differentiate your command components:

    command= "TEST ACTION;client_service_platform;CONDITION_TYPE_TRIGGER_NAME CONDITION_OPERATOR_LIKE Weighted Successful,CONDITION_TYPE_HOST CONDITION_OPERATOR_EQUAL tt1scp1; OPERATION_TYPE_MESSAGE userid1,OPERATION_TYPE_EMAIL userid1,OPERATION_TYPE_EMAIL userid2"
    

    now instantiate with:

    a = Action(*command.split(';'))
    

    which allows you to call:

    a.name
    a.hostgroup
    a.actions.split(',')
    a.operations.split(',')
    

    of which the elements of last two can then be split again with just .split()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most of my experience with Django thus far has been with MySQL and mysqldb.
I thus far used concatenated Id string like 1,2,3 and updated in my table
My employer has a database committee and we've been discussing different platforms. Thus far
I have been following this convention thus far: std::string line; while(std::getline(in,line)) { if(line.size() &&
My experience thus far has shown me that even with multi-core processors, parallelizing an
Thus far used sql server stored procedures for all my web applications... Now thought
thus far i've only been using some basic jquery selectors and functions. but i'm
Thus far you guys have been wildly helpful with me getting this little ditty
I have thus far built an Editor and a Viewer that both work on
Here is what I have tried thus far: > cd /Applications/MAMP/bin/php5/bin/ > ./pear channel-discover

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.