FAQ
Hi,

I have following code executed on bpython. I have salt-master running in
open mode on the machine. I am using python API to get the jobs list. The
API is getting the jobs list in the jobList object below in json format,
but it is also printing the same info on the console. Please see the
highlighted prints below. How can i avoid this print on the console or in
my log.



import salt.config
import salt.client
import salt.runner
import salt.modules
master_opts = salt.config.client_config('/etc/salt/master')
runner = salt.runner.RunnerClient(master_opts)
jobList= runner.cmd('jobs.list_jobs',[])













*'20141002165003618812': Arguments: [] Function: state.highstate
StartTime: 2014, Oct 02 16:50:03.618812 Target:
pepper.admin.pod1.hq.kumo.local Target-type: glob User:
root'20141002165003662798': Arguments: - roles.nameserver Function:
state.sls StartTime: 2014, Oct 02 16:50:03.662798 Target: pepper.*
Target-type: glob User: root*
jobList
{'20141002165003618812': {'Function': 'state.highstate', 'Target':
'pepper.admin.pod1.hq.kumo.local', 'User': 'root', 'StartTime': '2014, Oct
02 16:50:03.618812
', 'Target-type': 'glob', 'Arguments': []}, '20141002165003662798':
{'Function': 'state.sls', 'Target': 'pepper.*', 'User': 'root',
'StartTime': '2014, Oct 02 1
6:50:03.662798', 'Target-type': 'glob', 'Arguments': ['roles.nameserver']}}
>>>


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Seth House at Oct 22, 2014 at 3:44 pm
    Very slow reply, sorry.

    Until we can revamp the runner system so that runner modules don't
    handle their own output, your best bet is to either: temporarily
    redirect stdout when you run the function or extract the relevant code
    (omitting the print statements) from the other runner into your own.

    import sys
    f = open('/dev/null', 'w')
    sys.stdout = f

    On Oct 2, 2014 2:56 PM, "Kumar Rajnish" wrote:
    How can i avoid this print on the console or in my log.



    import salt.config
    import salt.client
    import salt.runner
    import salt.modules
    master_opts = salt.config.client_config('/etc/salt/master')
    runner = salt.runner.RunnerClient(master_opts)
    jobList= runner.cmd('jobs.list_jobs',[])
    '20141002165003618812':
    Arguments: []
    Function: state.highstate
    StartTime: 2014, Oct 02 16:50:03.618812
    Target: pepper.admin.pod1.hq.kumo.local
    Target-type: glob
    User: root
    '20141002165003662798':
    Arguments:
    - roles.nameserver
    Function: state.sls
    StartTime: 2014, Oct 02 16:50:03.662798
    Target: pepper.*
    Target-type: glob
    User: root
    jobList
    {'20141002165003618812': {'Function': 'state.highstate', 'Target': 'pepper.admin.pod1.hq.kumo.local', 'User': 'root', 'StartTime': '2014, Oct 02 16:50:03.618812
    ', 'Target-type': 'glob', 'Arguments': []}, '20141002165003662798': {'Function': 'state.sls', 'Target': 'pepper.*', 'User': 'root', 'StartTime': '2014, Oct 02 1
    6:50:03.662798', 'Target-type': 'glob', 'Arguments': ['roles.nameserver']}}
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Kumar Rajnish at Nov 4, 2014 at 5:22 pm
    Thanks a lot for the reply. It works.
    On Wednesday, October 22, 2014 11:44:43 AM UTC-4, Seth House wrote:

    Very slow reply, sorry.

    Until we can revamp the runner system so that runner modules don't
    handle their own output, your best bet is to either: temporarily
    redirect stdout when you run the function or extract the relevant code
    (omitting the print statements) from the other runner into your own.

    import sys
    f = open('/dev/null', 'w')
    sys.stdout = f


    On Oct 2, 2014 2:56 PM, "Kumar Rajnish" <rajni...@gmail.com <javascript:>>
    wrote:
    How can i avoid this print on the console or in my log.



    import salt.config
    import salt.client
    import salt.runner
    import salt.modules
    master_opts = salt.config.client_config('/etc/salt/master')
    runner = salt.runner.RunnerClient(master_opts)
    jobList= runner.cmd('jobs.list_jobs',[])
    '20141002165003618812':
    Arguments: []
    Function: state.highstate
    StartTime: 2014, Oct 02 16:50:03.618812
    Target: pepper.admin.pod1.hq.kumo.local
    Target-type: glob
    User: root
    '20141002165003662798':
    Arguments:
    - roles.nameserver
    Function: state.sls
    StartTime: 2014, Oct 02 16:50:03.662798
    Target: pepper.*
    Target-type: glob
    User: root
    jobList
    {'20141002165003618812': {'Function': 'state.highstate', 'Target':
    'pepper.admin.pod1.hq.kumo.local', 'User': 'root', 'StartTime': '2014, Oct
    02 16:50:03.618812
    ', 'Target-type': 'glob', 'Arguments': []}, '20141002165003662798':
    {'Function': 'state.sls', 'Target': 'pepper.*', 'User': 'root',
    'StartTime': '2014, Oct 02 1
    6:50:03.662798', 'Target-type': 'glob', 'Arguments':
    ['roles.nameserver']}}
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedOct 2, '14 at 8:56p
activeNov 4, '14 at 5:22p
posts3
users2

2 users in discussion

Kumar Rajnish: 2 posts Seth House: 1 post

People

Translate

site design / logo © 2022 Grokbase