# Python Hook Print to Standard Out?

**URL:** <https://community.openpbs.org/t/python-hook-print-to-standard-out/3703>\
**Category:** Users/Site Administrators\
**Created:** [November 9, 2023, 5:22pm UTC](https://community.openpbs.org/t/python-hook-print-to-standard-out/3703 "2023-11-09T17:22:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeyHey](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@HeyHey](https://community.openpbs.org/u/HeyHey)\
**Post date:** [November 9, 2023, 5:22pm UTC](https://community.openpbs.org/t/python-hook-print-to-standard-out/3703/1 "2023-11-09T17:22:10Z")

</div>

Want to send a friendly message to the requestor when they submit something and I think I know better and make a mod to the job

Seems like one of the only ways to send feedback to the end user cli is `pbs_event.reject` but I want the job to run. Seem harsh.

`print("hi")` and `print("hi", file=sys.stderr)`

Doesn’t do it. Of course I can log it too discrete. Was wondering about letting the end user know about a modification I make make on queue submit.

I have been through the hooks docs and I don’t see it (actually, that reminds me to see if there is any sphinx style docs for their hooks)

---

<div class="post-metadata">

**Author:** ![dtalcott](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/dtalcott/32/410_2.png) [@dtalcott](https://community.openpbs.org/u/dtalcott)\
**Post date:** [November 10, 2023, 1:14am UTC](https://community.openpbs.org/t/python-hook-print-to-standard-out/3703/2 "2023-11-10T01:14:57Z")

</div>

> [@HeyHey](#):
>
> Want to send a friendly message to the requestor when they submit something and I think I know better and make a mod to the job

This is an often requested feature, but it doesn’t exist (to my knowledge). Many ugly hacks have been suggested.

One ugly suggestion is to check the job specification for the “site” resource. If site includes the string “no\_nags”, you let the job pass. Otherwise, you reject it with an explanation. The user can either change the job to match your preferred way, or add -l site=“no\_nags” to the qsub.

Another suggestion is to have the hook put something in the pbs logs. Then have a script that runs once a day that checks for these messages and sends email to the user. The smart version of the script sends only one email per day per user.

---

<div class="post-metadata">

**Author:** ![HeyHey](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@HeyHey](https://community.openpbs.org/u/HeyHey)\
**Post date:** [November 10, 2023, 1:52am UTC](https://community.openpbs.org/t/python-hook-print-to-standard-out/3703/3 "2023-11-10T01:52:59Z")

</div>

Oh yeah, so it is leveraging .reject()… think I like that better for immediacy. But still too harsh a reaction. lol.

a shame, not sure where print to std out and error went (?) but too harsh, more a gentle FYI… e.g. we use bright cluster and the deeper you get into the config the hazier it gets. So… rather than use config2 to set the default placement packing, one of the clauses to set something like “free” and let them know. (like why that cann’t be set in queue manager is a curiosity).

Something like… (and the code can be off… just… you know. off memory

```auto
# code to get the job object.... then
pbs_place_str = str(pbs_job.resource_list["place"])
...
...
        if not any(placement in pbs_place for placement in ["scatter","pack","free", "whatever"]):
            pbs_job.resource_list["place"] = pbs.place("free:" + pbs_place_str)
            # this next pbs function does not exist future readers, for example
            pbs.usermsg(f"job placement updated to free:{pbs_place_str} cause we wanted to")

```

btw, “place” is a null object if old resource syntax is used.
