Loading src/lib/archversion/__init__.py.in +8 −2 Original line number Diff line number Diff line Loading @@ -39,5 +39,11 @@ CACHE_PACKAGES = "packages.cache" # Annouced version (from autoconf) VERSION = "@VERSION@" # user agent using with http request USER_AGENT = "archversion v%s" % VERSION # Http request headers # Advertise archversion version # Try to disable caching HTTP_HEADERS = { "User-Agent": "archversion v%s" % VERSION, "Pragma": "no-cache", "Cache-Control": "no-cache, no-store, must-revalidate" } No newline at end of file src/lib/archversion/version.py +4 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ '''Version Module''' from archversion import USER_AGENT, CONFIG_PACKAGES, CACHE_PACKAGES from archversion import HTTP_HEADERS, CONFIG_PACKAGES, CACHE_PACKAGES from archversion.config import BaseConfigFile from archversion.database import JsonDatabase from archversion.error import InvalidConfigFile, VersionNotFound Loading Loading @@ -204,7 +204,7 @@ class VersionController(object): try: logging.debug("Requesting url: %s (try %d/%d)" % (url, n, ntry)) logging.debug("Timeout is %s" % timeout) url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) url_fd = urlopen(url_req, timeout=timeout) logging.debug("Version regex: %s" % regex) v = re.findall(regex, url_fd.read().decode("utf-8")) Loading Loading @@ -271,7 +271,7 @@ class VersionController(object): for repo in repos: url = "http://www.archlinux.org/packages/%s/%s/%s/json" % ( repo, arch, name) url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) logging.debug("Requesting url: %s" % url) logging.debug("Timeout is %s" % timeout) try: Loading @@ -292,7 +292,7 @@ class VersionController(object): # retrieve config timeout timeout = float(value["timeout"]) if "timeout" in value else None url = "http://aur.archlinux.org/rpc.php?type=info&arg=%s" % name url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) logging.debug("Requesting url: %s" % url) logging.debug("Timeout is %s" % timeout) url_fd = urlopen(url_req, timeout=timeout) Loading Loading
src/lib/archversion/__init__.py.in +8 −2 Original line number Diff line number Diff line Loading @@ -39,5 +39,11 @@ CACHE_PACKAGES = "packages.cache" # Annouced version (from autoconf) VERSION = "@VERSION@" # user agent using with http request USER_AGENT = "archversion v%s" % VERSION # Http request headers # Advertise archversion version # Try to disable caching HTTP_HEADERS = { "User-Agent": "archversion v%s" % VERSION, "Pragma": "no-cache", "Cache-Control": "no-cache, no-store, must-revalidate" } No newline at end of file
src/lib/archversion/version.py +4 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ '''Version Module''' from archversion import USER_AGENT, CONFIG_PACKAGES, CACHE_PACKAGES from archversion import HTTP_HEADERS, CONFIG_PACKAGES, CACHE_PACKAGES from archversion.config import BaseConfigFile from archversion.database import JsonDatabase from archversion.error import InvalidConfigFile, VersionNotFound Loading Loading @@ -204,7 +204,7 @@ class VersionController(object): try: logging.debug("Requesting url: %s (try %d/%d)" % (url, n, ntry)) logging.debug("Timeout is %s" % timeout) url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) url_fd = urlopen(url_req, timeout=timeout) logging.debug("Version regex: %s" % regex) v = re.findall(regex, url_fd.read().decode("utf-8")) Loading Loading @@ -271,7 +271,7 @@ class VersionController(object): for repo in repos: url = "http://www.archlinux.org/packages/%s/%s/%s/json" % ( repo, arch, name) url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) logging.debug("Requesting url: %s" % url) logging.debug("Timeout is %s" % timeout) try: Loading @@ -292,7 +292,7 @@ class VersionController(object): # retrieve config timeout timeout = float(value["timeout"]) if "timeout" in value else None url = "http://aur.archlinux.org/rpc.php?type=info&arg=%s" % name url_req = Request(url, headers={"User-Agent": USER_AGENT}) url_req = Request(url, headers=HTTP_HEADERS) logging.debug("Requesting url: %s" % url) logging.debug("Timeout is %s" % timeout) url_fd = urlopen(url_req, timeout=timeout) Loading