]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
Notify over HTTP (not well tested).
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 7 Mar 2007 19:18:32 +0000 (19:18 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    PLD_Builder/config.py -> 1.34
    PLD_Builder/file_sender.py -> 1.17
    PLD_Builder/notify.py -> 1.5
    PLD_Builder/notifyq.py -> 1.1
    PLD_Builder/path.py -> 1.14
    PLD_Builder/request_handler.py -> 1.37
    PLD_Builder/rpm_builder.py -> 1.47
    admin/fresh-queue.sh -> 1.14
    config/builder.conf -> 1.33

PLD_Builder/config.py
PLD_Builder/file_sender.py
PLD_Builder/notify.py
PLD_Builder/notifyq.py [new file with mode: 0644]
PLD_Builder/path.py
PLD_Builder/request_handler.py
PLD_Builder/rpm_builder.py
admin/fresh-queue.sh
config/builder.conf

index 3ff2fc31f046ad1bf96769e5647611467ccc5367..814798f2e301a70d46b3fcea2c175138f419286d 100644 (file)
@@ -89,6 +89,7 @@ class Builder_Conf:
         self.email = get("email")
         self.buildlogs_url = get("buildlogs_url", "/dev/null")
         self.ftp_url = get("ftp_url")
+        self.notify_url = get("notify_url")
         self.test_ftp_url = get("test_ftp_url", "/dev/null")
         self.rpmqa_url = get("rpmqa_url", "/dev/null")
         self.rpmqa_filename = get("rpmqa_filename")
index bced895e29c684a83d8d0e93cab634871620dd83..335c04e811001427e106323968455bbf093bf544 100644 (file)
@@ -8,6 +8,7 @@ import time
 import shutil
 import sys
 import traceback
+import urllib2
 
 from config import config, init_conf
 import mailer
@@ -72,7 +73,25 @@ def rsync_file(src, target, host):
     res = f.close()
     if password != None: os.unlink(".rsync.pass")
     return f.close()
-    
+
+def post_file(src, url):
+    global problem
+    try:
+        f = open(src, 'r')
+        data = f.read()
+        f.close()
+        req = urllib2.Request(url, data)
+        f = urllib2.urlopen(req)
+        code = f.code
+        f.close()
+    except Exception, e:
+        problem = e
+        return e
+    if code == 200:
+        return 0
+    else:
+        return code
+
 def send_file(src, target):
     log.notice("sending %s (size %d bytes)" % (target, os.stat(src).st_size))
     m = re.match('rsync://([^/]+)/.*', target)
@@ -83,6 +102,9 @@ def send_file(src, target):
     m = re.match('scp://([^@:]+@[^/:]+)(:|)(.*)', target)
     if m:
         return scp_file(src, m.group(1) + ":" + m.group(3))
+    m = re.match('http://.*', target)
+    if m:
+        return post_file(src, target)
     log.alert("unsupported protocol: %s" % target)
     # pretend everything went OK, so file is removed from queue,
     # and doesn't cause any additional problems
@@ -168,6 +190,7 @@ def main():
     if lock.lock("sending-files", non_block = 1) == None:
         return
     init_conf()
+    maybe_flush_queue(path.notify_queue_dir)
     maybe_flush_queue(path.buildlogs_queue_dir)
     maybe_flush_queue(path.ftp_queue_dir)
 
index 8b71103a04d172b9527c6ea0b5afe9121d9ecc5d..763de067748548752202d7c6a90dc4523b3fd1d6 100644 (file)
@@ -5,6 +5,7 @@ import StringIO
 import mailer
 import gpg
 import util
+import notifyq
 from config import config
 
 class Notifier:
@@ -13,15 +14,16 @@ class Notifier:
         self.xml.write("<notification group-id='%s' builder='%s'>\n" % \
                         (g.id, config.builder))
     
-    def send(self):
+    def send(self, r):
+        sio = StringIO.StringIO()
         self.xml.write("</notification>\n")
-        msg = mailer.Message()
-        msg.set_headers(to = config.notify_email, subject = "status notification")
-        msg.set_header("X-New-PLD-Builder", "status-notification")
         self.xml.seek(0)
-        util.sendfile(gpg.sign(self.xml), msg)
-        msg.send()
+        util.sendfile(gpg.sign(self.xml), sio)
         self.xml = None
+        sio.seek(0)
+        notifyq.init(r)
+        notifyq.add(sio)
+        notifyq.flush()
     
     def add_batch(self, b, s):
         self.xml.write("  <batch id='%s' status='%s' />\n" % (b.b_id, s))
@@ -35,5 +37,5 @@ def begin(group):
 def add_batch(batch, status):
     n.add_batch(batch, status)
 
-def send():
-    n.send()
+def send(r):
+    n.send(r)
diff --git a/PLD_Builder/notifyq.py b/PLD_Builder/notifyq.py
new file mode 100644 (file)
index 0000000..848a12d
--- /dev/null
@@ -0,0 +1,65 @@
+# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+
+import path
+import os
+import shutil
+import time
+
+from config import config
+import util
+
+class Notify_Queue:
+    def __init__(self):
+        self.queue = None
+        self.some_failed = 0
+
+    def init(self, g=None):
+        self.queue = []
+        self.requester_email = g.requester_email
+        self.notify_url = config.notify_url
+        
+    def add(self, file):
+        id = util.uuid()
+        f = open(path.notify_queue_dir + id, 'w')
+        f.write(file.read())
+        f.close()
+        self.queue.append({'id': id})
+
+    def flush(self):
+        def desc(l):
+            return """Target: %s
+Id: %s
+Builder: %s
+Time: %d
+Requester: %s
+END
+""" % (self.notify_url, l['id'], config.builder, time.time(), self.requester_email)
+        
+        for l in self.queue:
+            f = open(path.notify_queue_dir + l['id'] + ".desc", "w")
+            f.write(desc(l))
+            f.close()
+
+    def kill(self):
+        for l in self.queue:
+            os.unlink(path.notify_queue_dir + l)
+
+queue = Notify_Queue()
+
+def add(notify):
+    queue.add(notify)
+
+def flush():
+    queue.flush()
+    
+def kill():
+    queue.kill()
+
+def init(r):
+    queue.init(r)
+
+def status():
+    return queue.status
+    
+def clear_status():
+    queue.status = ""
index 6f2226e006eb923835c4c3cf8b39bd0caf3b25e8..ff9766b9395ded2b52e94caac15d8f6e10f1283a 100644 (file)
@@ -16,6 +16,7 @@ rsync_password_file = conf_dir + "rsync-passwords"
 queue_file = spool_dir + "queue"
 req_queue_file = spool_dir + "req_queue"
 processed_ids_file = spool_dir + "processed_ids"
+notify_queue_dir = spool_dir + "notify/"
 buildlogs_queue_dir = spool_dir + "buildlogs/"
 ftp_queue_dir = spool_dir + "ftp/"
 build_dir = spool_dir + "builds/"
index 787a2bba03a6d48e021f8b383d4065aea731092c..daa1f8b78c6b0d2b0ebb40498d2c97c00258849c 100644 (file)
@@ -161,12 +161,15 @@ def handle_request(f):
     status.pop()
     return True
 
-def main():
+def handle_request_main(stream):
     init_conf("src")
     status.push("handling email request")
-    ret = handle_request(sys.stdin)
+    ret = handle_request(stream)
     status.pop()
-    sys.exit(not ret)
+    return ret
+
+def main():
+    sys.exit(not handle_request_main(sys.stdin))
 
 if __name__ == '__main__':
     wrap.wrap(main)
index 6ebff0433741fbfc1b799b7a9b4cdcf920a57f75..c2831e892ea1581ac384b7e8cadb1fd16fdacc6f 100644 (file)
@@ -172,7 +172,7 @@ def handle_request(r):
     build.build_all(r, build_rpm)
     report.send_report(r, is_src = False)
     ftp.flush()
-    notify.send()
+    notify.send(r)
 
 def check_load():
     do_exit = 0
index dc089de4badb2ad966a9939d0e0468bd02d7d8c5..0fbd4c1f7a0d973f7a338ca90043671cc809defa 100755 (executable)
@@ -20,7 +20,7 @@ if [ "$1" != "y" ] ; then
   exit 1
 fi
 
-mkdir -p spool/{builds,buildlogs,ftp} www/srpms lock
+mkdir -p spool/{builds,buildlogs,notify,ftp} www/srpms lock
 echo 0 > www/max_req_no
 echo 0 > spool/last_req_no
 echo -n > spool/processed_ids
index 3e16a8adb943cea3be84b6f692c9bdc7df12f723..27257546d32098c56edce164700c739065f1aa4e 100644 (file)
@@ -62,6 +62,7 @@ arch = i686
 chroot = /home/pld/builderth/chroots/chroot-src/
 buildlogs_url = rsync://blogs-th@buildlogs.pld-linux.org/pld-buildlogs-th-SRPMS/
 ftp_url = scp://pldth@ep09.pld-linux.org:ftp/.incoming/SRPMS/
+notify_url = http://ep09.pld-linux.org:1234/
 test_ftp_url = scp://pldth@ep09.pld-linux.org:ftp/.test-builds/SRPMS/
 rpmqa_url = scp://pldth@ep09.pld-linux.org:ftp/.stat/builder/th/
 rpmqa_filename = rpmqa-SRPMS.txt
@@ -70,6 +71,7 @@ rpmqa_filename = rpmqa-SRPMS.txt
 arch = athlon
 chroot = /home/users/builderth/chroot-athlon/
 buildlogs_url = /dev/null
+notify_url = http://ep09.pld-linux.org:1234/
 ftp_url = scp://pldth@ep09.pld-linux.org:ftp/.incoming/athlon/
 test_ftp_url = /dev/null
 rpmqa_url = /dev/null
This page took 0.152012 seconds and 4 git commands to generate.