Files
linux-kernel-module-cheat/release-download-latest
Ciro Santilli 六四事件 法轮功 8217e55087 cli_function: clarify copyright
2019-01-22 00:00:01 +00:00

29 lines
956 B
Python
Executable File

#!/usr/bin/env python3
import urllib.request
import common
from shell_helpers import LF
class Main(common.LkmcCliFunction):
def __init__(self):
super().__init__(
description='''\
Usage: https://github.com/cirosantilli/linux-kernel-module-cheat#prebuilt
Implementation:
https://stackoverflow.com/questions/24987542/is-there-a-link-to-github-for-downloading-a-file-in-the-latest-release-of-a-repo/50540591#50540591
''',
)
def timed_main(self):
# This would be better, but impossible:
# https://stackoverflow.com/questions/51212/how-to-write-a-download-progress-indicator-in-python
self.log_info('Downloading the release, this may take several seconds / a few minutes.')
_json = self.github_make_request(path='/releases')
asset = _json[0]['assets'][0]
urllib.request.urlretrieve(asset['browser_download_url'], asset['name'])
if __name__ == '__main__':
Main().cli()