Pārlūkot izejas kodu

Webhook test script

tags/v0.4.0
Russ Garrett 5 gadus atpakaļ
vecāks
revīzija
c35a8d623d
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 29 papildinājumiem un 0 dzēšanām
  1. 29
    0
      webhook_test_data/github/webhook_test.py

+ 29
- 0
webhook_test_data/github/webhook_test.py Parādīt failu

@@ -0,0 +1,29 @@
1
+#!/usr/bin/env python3
2
+# Simple script to send test webhooks
3
+import sys
4
+import requests
5
+
6
+if len(sys.argv) != 2:
7
+    print("Provide name of webhook as argument")
8
+    sys.exit(1)
9
+
10
+webhook_type = sys.argv[1]
11
+
12
+try:
13
+    with open("./{}.json".format(webhook_type), "r") as f:
14
+        json = f.read()
15
+except FileNotFoundError:
16
+    print("Can't find {}.json".format(webhook_type))
17
+    sys.exit(1)
18
+
19
+url = "http://localhost:8045/github"
20
+print("Posting to {}...".format(url))
21
+
22
+res = requests.post(url, data=json, headers={"X-GitHub-Event": webhook_type})
23
+
24
+if res.status_code != 200:
25
+    print("Webhook error (status {}):".format(res.status_code))
26
+    print(res.text)
27
+    sys.exit(2)
28
+else:
29
+    print("Success!")

Notiek ielāde…
Atcelt
Saglabāt