When I run the command manually without yes | I get prompted to specify yes 
in my terminal when I run the command with yes | command in the terminal it 
works fine, but through python subprocess command it hangs, not sure how to 
resolve this one:

Code executing the command 

def run_command(command):
    p = subprocess.Popen(command, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=True)
    out, err = p.communicate()
    if err:
        if "bash" in command:
            return err
        else:
            print err
    return out





the command being executed:

yes | bash review 'feature-signature' 'PR_Reviewers' 'myrepo' 'myuser' 
'mypassword' 'update' 'development' 'PR user' 'Egg NEB-4257 actually handle 
non happy paths* Fix edge cases around signature upload and fetch* Test 
fixes* Address pr feedback* LINTApproved-by: Martin [email protected] 
Approved-by: Justin [email protected] jira url 
https://myjira.atlassian.net/browse/NEB-4257' 
'https://myjira.atlassian.net/browse/NEB-4257' 'Egg NEB-4257 actually 
handle non happy paths* Fix edge cases around signature upload and fetch* 
Test fixes* Address pr feedback* LINTApproved-by: Martin [email protected] 
Approved-by: Justin [email protected] jira link 
https://myjira.atlassian.net/browse/NEB-4257'


is the command to execute the following bash script, this works when I do 
it manually but locks up when I do it through python like the yes answer 
isn't getting piped into the script as it runs. I don't see a way in the 
docs to auto yes either.


def generate_bash_file():
    review_generation_bash = """#!/usr/bin/env bash

    BRANCH_NAME=$1
    REVIEWERS=$2
    REPO=$3
    rb_user=$4
    rb_password=$5
    action=$6
    base_branch=$7
    
    #added these options
    submit_as=$8
    summary=$9
    jira_id=$10
    desc=$11

    echo "Jira Link: $jira_id"
    echo "Desc: $desc"
    echo "Repo: $repo"
    echo "Submit as: $submit_as"
    echo "Summary $summary"
    echo "Branch name $BRANCH_NAME"


    cd $REPO
    git checkout $BRANCH_NAME

    if [ "$action" == "post" ]; then

        rbt post --repository=$REPO \
                       --tracking-branch="origin/$BRANCH_NAME" \
                       --parent="origin/$base_branch" \
                       --branch="$BRANCH_NAME" \
                       --guess-fields=auto \
                       --target-groups=$REVIEWERS \
                       --publish \
                       --server="http://reviews.domain"; \
                       --username="$rb_user" \
                       --password=$rb_password \
                       --submit-as="$submit_as" \
                       --bugs-closed="$jira_id" \
                       --description="$summary" \
                       -d
    else
       yes | rbt post --update --repository=$REPO \
                       --tracking-branch="origin/$BRANCH_NAME" \
                       --parent="origin/$base_branch" \
                       --branch="$BRANCH_NAME" \
                       --guess-fields="auto" \
                       --target-groups="$REVIEWERS" \
                       --publish \
                       --server="http://reviews.domain"; \
                       --username="$rb_user" \
                       --password="$rb_password" \
                       --submit-as="$submit_as" \
                       --bugs-closed="$jira_id" \
                       --description="$summary" \
                       -d
    fi

    cd ../
    exit 0

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to