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)