Extension is unable to run external python script - [Errno 13] Permission denied

17 views
Skip to first unread message

Petr Grenar

unread,
Apr 15, 2020, 9:40:48 AM4/15/20
to Review Board Community
Hello,

now I have a running extension. As you can see down below I am trying to run an external python file. I even tried to write to a file. Both times I got the same error. I tried to change the permissions of the files test.py and actionlog.txt using chmod +x. It didn't help. Do I need to do it elsewhere? Or is there another way how to run external scripts? My goal is to run a terminal command after a review request is shipped and submitted.

from reviewboard.extensions.base import Extension
import logging
import os
from reviewboard.extensions.hooks import ReviewRequestApprovalHook
from reviewboard.extensions.hooks import SignalHook
from reviewboard.reviews.signals import review_request_closed
from reviewboard.reviews.models import ReviewRequest
from datetime import datetime

class SampleApprovalHook(ReviewRequestApprovalHook):
<------>now = datetime.now()
<------>current_time = now.strftime(" %d/%m/%Y : %H:%M:%S ")
<------>def is_approved(self, review_request, prev_approved, prev_failure):
<------><------>if review_request.shipit_count > 0:
<------><------><------>logging.critical("TRUE Je tam SHIPIT %s", review_request.shipit_count)
<------><------><------>logging.critical("SHIP IT JEAH %s, Pocet SHIPIT: %s", review_request.display_id, review_request.shipit_count)
<-----><------><------>os.system("python /home/pgrenar/Plocha/test.py")
<------><------><------>f = open("/home/pgrenar/Plocha/actionlog.txt", "a")
<------><------><------>f.write("Request created =" + current_time + "___\n")
<------><------><------>f.close()
<------><------><------>return True
<------><------>else:
<------><------><------>logging.critical("FALSE Je tam SHIPIT %s", review_request.shipit_count)
<------><------><------>return False

class SampleSignalExtension(Extension):
<------>def initialize(self):
<------><------>SignalHook(self, review_request_closed, self.on_closed)
<------><------>logging.critical("Initialize")
<------>def shutdown(self):
<------><------>logging.critical("Shutdown")
<------>def on_closed(self, user, review_request, type,  **kwargs):
<------><------>if type == ReviewRequest.SUBMITTED:
<------><------><------>approvalHook = SampleApprovalHook(self)

Christian Hammond

unread,
Apr 15, 2020, 4:01:31 PM4/15/20
to revie...@googlegroups.com
Hi Petr,

My first guess would be that Apache isn't able to read your home directory, or that you're running on an OS with SELinux enabled, which would limit the directories that Apache is allowed to even look at.

You'd be better off keeping any data files or scripts within your Review Board site directory, probably under the data/ directory. It should have permission to read/write there.

Christian

--
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 reviewboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/083ec591-1d9e-4d5d-a40b-93863b796e2b%40googlegroups.com.


--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board
Reply all
Reply to author
Forward
0 new messages