buggnubg - Bugs: bug #62320, How to capture output of gnubg...

 
 

bug #62320: How to capture output of gnubg Python command

Submitter:  None
Submitted:  Sat 16 Apr 2022 07:49:08 AM UTC
   
 
Originator Name:  mbr22 Originator Email:  * -email is unavailable-
Item Group:  Feature Request Category:  Command line interface
Release:  * 1.06 Privacy:  Public
Operating System:  All Severity:  3 - Normal
Open/Closed:  Closed Assigned to:  None
Priority:  5 - Normal Status:  Please Upgrade
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 16 Nov 2022 10:50:32 PM UTC, comment #2: 

The folowing python function is available in the just released 1.07 version :

Add a gnubg.show() python function to return the result of a "show" command(minus the final(s) \n) as a string.

The result is "as is", subject to i18n. The caller has to parse it if needed.

Doing this for "command" does not seem reasonable since its output is potentially illimited.

Philippe Michel <plm>
Group administrator
Thu 21 Apr 2022 10:04:12 PM UTC, comment #1: 

There is no obvious way to get what is printed by gnubg.command() in a python variable. gnubg.command is really a kind of minimal catch-all to run whatever CLI command that has not equivalent in the python API.

It would make sense for it to do this, or to have a gnubg.show() function retunrning a string, but neither is currently available.

What you could do is to start with gnubg.board() and compute the pip counts, percentage difference and cube decision according to the 8/9/12 rule yourself.

Philippe Michel <plm>
Group administrator
Sat 16 Apr 2022 07:49:08 AM UTC, original submission:  

Hi

I'm trying to create a GNUbg Python script that takes the 8912 theory output of a specific move and then add to the comments section of that move. The reason I need it in the comments is that I am trying to make the 8912 output show on the HTML export as an Annotation.

I have tried the following code:
s = gnubg.command('show 8912')
gnubg.command('annotate move comment "' + s + '"')

But it does not work because gnubg.command does not return anything. The output is written to the screen. I tried to capture stdout using regular Python stdout code, but it didn't work, so I assume because the script is running inside gnubg itself? I am launching the script using 'load python script_name.py' at the gnubg command prompt.

Any help would be appreciated on how to capture output from gnubg.command().

Thank you.

MBR

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by plm (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-16 plm Open/ClosedOpen Closed
        StatusNone Please Upgrade
    2022-04-21 plm Item GroupOther bug Feature Request
        Operating SystemLinux All

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code