kou commented on code in PR #14848:
URL: https://github.com/apache/arrow/pull/14848#discussion_r1040296509


##########
dev/release/download_rc_binaries.py:
##########
@@ -125,6 +140,67 @@ class Maven(Downloader):
         "/content/repositories/staging/org/apache/arrow"
 
 
+class GitHub(Downloader):
+    def __init__(self, repository, tag):
+        super().__init__()
+        if repository is None:
+            raise ValueError("--repository is required")
+        if tag is None:
+            raise ValueError("--tag is required")
+        self.repository = repository
+        self.tag = tag
+
+    def get_file_list(self, prefix, filter=None):
+        url = 
f"https://api.github.com/repos/{self.repository}/releases/tags/{self.tag}";
+        print("Fetching release from", url)
+        request = urllib.request.Request(
+            url,
+            method="GET",
+            headers={
+                "Accept": "application/vnd.github+json",
+                "User-Agent": "apache/arrow 
dev/release/download_rc_binaries.py",
+            },
+        )
+        raw_response = urllib.request.urlopen(request).read().decode()
+        response = json.loads(raw_response)
+
+        files = []
+        for asset in response["assets"]:
+            if filter and not filter(asset["name"]):
+                continue
+            # Don't use the API URL since it has a fairly strict rate
+            # limit unless logged in, and we have a lot of tiny
+            # artifacts
+            url = (
+                f"https://github.com/{self.repository}/";
+                f"releases/download/{self.tag}/{asset['name']}"
+            )
+            files.append((asset["name"], url))
+        return files
+
+    def _download_file(self, dest, asset):
+        name, url = asset
+
+        os.makedirs(dest, exist_ok=True)
+        dest_path = os.path.join(dest, name)
+        print("Downloading {} to {}".format(url, dest_path))

Review Comment:
   ```suggestion
           print(f"Downloading {url} to {dest_path}")
   ```



##########
dev/release/download_rc_binaries.py:
##########
@@ -125,6 +140,67 @@ class Maven(Downloader):
         "/content/repositories/staging/org/apache/arrow"
 
 
+class GitHub(Downloader):
+    def __init__(self, repository, tag):
+        super().__init__()
+        if repository is None:
+            raise ValueError("--repository is required")
+        if tag is None:
+            raise ValueError("--tag is required")
+        self.repository = repository
+        self.tag = tag

Review Comment:
   Should we use `_` prefix here?
   
   ```suggestion
           self._repository = repository
           self._tag = tag
   ```



##########
dev/release/download_rc_binaries.py:
##########
@@ -125,6 +140,67 @@ class Maven(Downloader):
         "/content/repositories/staging/org/apache/arrow"
 
 
+class GitHub(Downloader):
+    def __init__(self, repository, tag):
+        super().__init__()
+        if repository is None:
+            raise ValueError("--repository is required")
+        if tag is None:
+            raise ValueError("--tag is required")
+        self.repository = repository
+        self.tag = tag
+
+    def get_file_list(self, prefix, filter=None):
+        url = 
f"https://api.github.com/repos/{self.repository}/releases/tags/{self.tag}";
+        print("Fetching release from", url)
+        request = urllib.request.Request(
+            url,
+            method="GET",
+            headers={
+                "Accept": "application/vnd.github+json",
+                "User-Agent": "apache/arrow 
dev/release/download_rc_binaries.py",
+            },
+        )
+        raw_response = urllib.request.urlopen(request).read().decode()
+        response = json.loads(raw_response)
+
+        files = []
+        for asset in response["assets"]:
+            if filter and not filter(asset["name"]):
+                continue
+            # Don't use the API URL since it has a fairly strict rate
+            # limit unless logged in, and we have a lot of tiny
+            # artifacts
+            url = (
+                f"https://github.com/{self.repository}/";
+                f"releases/download/{self.tag}/{asset['name']}"
+            )
+            files.append((asset["name"], url))
+        return files
+
+    def _download_file(self, dest, asset):
+        name, url = asset
+
+        os.makedirs(dest, exist_ok=True)
+        dest_path = os.path.join(dest, name)
+        print("Downloading {} to {}".format(url, dest_path))
+
+        if os.path.isfile(dest_path):
+            print("Already downloaded", dest_path)
+            return
+
+        return self._download_url(
+            url,
+            dest_path,
+            extra_args=[
+                "--header",
+                "Accept: application/octet-stream",
+                "--header",
+                "User-Agent: apache/arrow-adbc 
dev/release/download_release.py",

Review Comment:
   Do we still need this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to