<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run_script_on_server( script_name, server_name, inputs=None, timeout_s=10, output=sys.stdout ):
 """ Runs a RightScript and polls for status. Sample usage:: from rightscale import run_script_on_server run_script_on_server( 'my cool bob lol script', 'some server', inputs={'BOB': 'blah blah', 'LOL': 'fubar'}, ) Sample output:: status: Querying tags status: Querying tags status: Preparing execution status: RightScript: 'my cool bob lol script' status: completed: my cool bob lol script Defaults to printing status message to stdout, but will accept any object that implements ``write()`` passed in to :attr:`output`. """

    api = get_api()
    script = find_by_name(api.right_scripts, script_name)
    server = find_by_name(api.servers, server_name)
    path = server.links['current_instance'] + '/run_executable'

    data = {
            'right_script_href': script.href,
            }
    if inputs:
        for k, v in inputs.items():
            data['inputs[%s]' % k] = 'text:' + v
    response = api.client.post(path, data=data)
    status_path = response.headers['location']
    for i in range(timeout_s):
        status = api.client.get(status_path).json()
        summary = status.get('summary', '')
        output.write('status: %s\n' % summary)
        if summary.startswith('completed'):
            return
        time.sleep(1)
    output.write('Done waiting. Poll %s for status.\n' % status_path)