Comments (2)
The issue with github seems to be that for unknown reason the Internet connection gets lost while downloading files larger than 700 kByte up to 1.2 MByte on a slow connection, so it is neither possible to get the master .zip file of the repository nor a release download.
A work around that currently works for me is to use the github api to download the repository one single file after another (assuming they are each smaller then 1.2 MByte) instead of trying to get its entire content as one file as it is also the case when using git clone
:
import hashlib, os, requests
githubUser = "orbitalquark"
githubUserRepo = "textadept"
userHOMEdir = os.path.expanduser("~")
githubRepoContentURL = f"https://api.github.com/repos/{githubUser}/{githubUserRepo}/contents"
baseDownloadDir = f"{userHOMEdir}/Downloads/githubUser_{githubUser}__Repo_{githubUserRepo}"
os.system(f"mkdir {baseDownloadDir}")
def getAndSaveFilesListedInURLresponse(url):
print(f" ===###===###=== {url=} {baseDownloadDir=} ")
objURLresponse = requests.get(url)
lstObjURLjson = objURLresponse.json()
print(f" {objURLresponse=} {lstObjURLjson=}")
print("------------------------------------------")
for dct in lstObjURLjson:
print(f" >>>IF>>> {dct['type']=}: {dct=}")
if dct["type"] == "dir":
newURL = dct["_links"]["self"]
newDownloadDir = baseDownloadDir+"/"+dct["path"]
os.system(f"mkdir {newDownloadDir}")
print(f" === >>> {newURL=} CREATED {newDownloadDir=} recursionCall() ")
getAndSaveFilesListedInURLresponse(newURL)
continue
if dct["type"] == "file":
downloadURL = dct["download_url"]
fileName = dct["name"]
fullPathFileName = baseDownloadDir+"/"+dct["path"]
objURLresponse = requests.get(downloadURL)
print(f" type==file size={dct['size']}: {objURLresponse.status_code=} {fileName=} {downloadURL=} {fullPathFileName=}")
if objURLresponse.status_code == 200:
# Save the content to a file
with open(fullPathFileName, 'wb') as fwb:
fwb.write(objURLresponse.content)
print(" got: "+fullPathFileName)
# github prepends the file content with fb"blob {fileSize}\x00" before calculating sha1
githubSHA1prefix = b"blob " + f"{len(objURLresponse.content)}".encode("utf-8") + b"\x00"
print(" with sha= " + hashlib.sha1(githubSHA1prefix + objURLresponse.content).hexdigest())
# print(response.content.decode('utf-8')) # Print without escaping non-printable bytes
else:
print(f" statusCode: "+str(response.status_code)+") retrieving: "+fullPathFileName)
print(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
getAndSaveFilesListedInURLresponse(githubRepoContentURL)
def getGithubSHAofFile(fpFName):
with open(fpFName, 'rb') as frb:
fileContent = frb.read()
githubSHA1prefix = b"blob " + f"{len(fileContent)}".encode("utf-8") + b"\x00"
sha1sum = hashlib.sha1(githubSHA1prefix + fileContent).hexdigest()
return sha1sum
""" bash ( next line behaves in dash other way than in bash )
~ $ f=/full/path/file/name.ext
~ $ echo -e "blob $(stat -c '%s' $f)\0$(cat $f)" | sha1sum
"""
"""
f=baseDownloadDir+"/"+".clang-format"
sha1sum = getGithubSHAofFile(f)
print(type(sha1sum), sha1sum)
"""
It would be sure nice to have another repository with resumable downloads, but at the moment the Python script I have put together for this purpose above runs and downloads the repositories on my slow connection. Issue solved?
from textadept.
Sorry, I don't know of any mirrors. My ISP blocks access to SourceForge, so I set up a GitHub mirror of a SourceForge project that uses GitHub Actions to pull in new changes every night so I can use that project. Perhaps you could do something similar using another git hosting service. Perhaps your clever workaround is enough though.
I'm going to close this because I'm not going to set up a mirror and GitHub network issues are out of my control.
from textadept.
Related Issues (20)
- Horizontal scrolling in textadept-curses HOT 2
- Different toggle comment behaviour HOT 6
- Error when saving in a Windows path localised region HOT 8
- Add iconv library for FreeBSD HOT 1
- Segfault on FreeBSD HOT 1
- 建议textadept增加简体中文 HOT 1
- Multiple cursors disappear on undo & redo HOT 7
- ui.dialogs.input too small and not resizable HOT 1
- Tabs Management HOT 1
- buffer:set_encoding('UTF-8') causes marking buffer as changed HOT 5
- Compilation on Ubuntu 18.04 failed when trying to build scintilla HOT 3
- Making syntax highlighting in Textadept providing features supported in SciTE Python lexer HOT 7
- Request change of behaviour for rectangular selection to ignore line ends HOT 2
- Latest textadept crashes on Win7 HOT 2
- HTML files missing from docs in 12.2-Linux release HOT 1
- When `~/.textadept/locale.conf` is present, **Edit** > **Preferences** followed by **Quick Open User Home** shows a single tab in the tab bar HOT 3
- Keypad / numpad's Enter sometimes doesn't behave like regular Enter/Return. HOT 1
- Crash on text-paste HOT 8
- Typing causes CPU heating at 500 lines 28 kByte large bash lexed file with large string areas. HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textadept.