You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webhook_test.py 700B

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