mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
add check_url scripts for appcast stanzas in both sever-cgi and local-cli versions (#59688)
* add check_url scripts as used for appcast stanzas in both sever-cgi as local-cli variants * Update check_url_filename.py
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
import cgi
|
||||
import urllib2
|
||||
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
url = form.getvalue("url", "")
|
||||
ua = form.getvalue("user_agent", "Mozilla")
|
||||
|
||||
try:
|
||||
headers = { 'User-Agent' : ua }
|
||||
req = urllib2.Request(url, None, headers)
|
||||
response = urllib2.urlopen(req)
|
||||
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
|
||||
filename = params['filename']
|
||||
except Exception:
|
||||
import traceback
|
||||
filename = 'generic exception: ' + traceback.format_exc()
|
||||
|
||||
print "Content-type: text/html"
|
||||
print
|
||||
|
||||
print """
|
||||
<html>
|
||||
<head><title></title></head>
|
||||
<body>
|
||||
%s
|
||||
|
||||
</body>
|
||||
</html>
|
||||
""" % cgi.escape(filename)
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
import cgi
|
||||
import urllib2
|
||||
|
||||
|
||||
url = sys.argv[1]
|
||||
headers = {'User-Agent' : 'Mozilla'}
|
||||
if len(sys.argv) > 2:
|
||||
ua = sys.argv[2]
|
||||
headers = { 'User-Agent' : ua }
|
||||
|
||||
|
||||
try:
|
||||
req = urllib2.Request(url, None, headers)
|
||||
response = urllib2.urlopen(req)
|
||||
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
|
||||
filename = params['filename']
|
||||
except Exception:
|
||||
import traceback
|
||||
filename = 'generic exception: ' + traceback.format_exc()
|
||||
|
||||
print filename
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
import cgi
|
||||
import urllib2
|
||||
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
url = form.getvalue("url", "")
|
||||
try:
|
||||
response = urllib2.urlopen(url)
|
||||
redir = response.geturl()
|
||||
except Exception:
|
||||
import traceback
|
||||
redir = 'generic exception: ' + traceback.format_exc()
|
||||
|
||||
print "Content-type: text/html"
|
||||
print
|
||||
|
||||
print """
|
||||
<html>
|
||||
<head><title></title></head>
|
||||
<body>
|
||||
%s
|
||||
|
||||
</body>
|
||||
</html>
|
||||
""" % cgi.escape(redir)
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
import cgi
|
||||
import urllib2
|
||||
|
||||
|
||||
url = sys.argv[1]
|
||||
|
||||
try:
|
||||
response = urllib2.urlopen(url)
|
||||
redir = response.geturl()
|
||||
except Exception:
|
||||
import traceback
|
||||
redir = 'generic exception: ' + traceback.format_exc()
|
||||
|
||||
print redir
|
||||
Reference in New Issue
Block a user