cs50 / cli50 Goto Github PK
View Code? Open in Web Editor NEWThis is CS50's command-line interface.
Home Page: https://cs50.readthedocs.io/cli50
License: GNU General Public License v3.0
This is CS50's command-line interface.
Home Page: https://cs50.readthedocs.io/cli50
License: GNU General Public License v3.0
Mostly because doing docker exec -it CONTAINER bash -l
yields a misconfigured terminal lately, per #35.
Looks like https://stackoverflow.com/a/17638236/5156190 doesn't work for us for cli50
, since our setup.py
ends up installing it in /usr/local/bin
, per scripts=["cli50"]
. The result is:
# Get version
# https://stackoverflow.com/a/17638236/5156190
try:
_dist = pkg_resources.get_distribution("cli50")
print(_dist)
dist_loc = os.path.normcase(_dist.location)
print(dist_loc)
here = os.path.normcase(__file__)
print(here)
if not here.startswith(os.path.join(dist_loc, "cli50")):
raise pkg_resources.DistributionNotFound
except pkg_resources.DistributionNotFound:
__version__ = "UNKNOWN"
else:
__version__ = _dist.version
yields
$ cli50 -V
cli50 1.9.0
/Library/Python/2.7/site-packages
/usr/local/bin/cli50
cli50 UNKNOWN
because cli50
isn't actually in site-packages
.
I'm spinning up a development env on my local machine cuz I wanna try NOT using cs50 ide, cs50 sandbox, or cs50 lab.
I want this environment to be stable for the next activities, that way I won't need to launch any new instances when mounting a directory for psets.
Also, I want my git account authenticated via SSH. So I don't always input my user & pass every time I use submit50 or just even compare50.
I already have a running container, and I don't want to delete this (not after the course):
I'm going to try logging in and hoping it mounts my current working dir. (I'm using VSCode btw):
Result:
Here is the standard usage of cli50
...and it launched up a new instance
Have a nice day! :D
I am trying to run cli 50 to mount a directory for test and learning purposes but I get this error:
NamelessKing@DESKTOP-namelessking MINGW64 /e/Users/NamelessKing/docker_mount_test
$ cli50
Using default tag: latest
latest: Pulling from cs50/cli
Digest: sha256:d7abc5ac7f9d557aa25bebaee1234e28722cac153d1a7dc2fe0ea28280d58c0f
Status: Image is up to date for cs50/cli:latest
Traceback (most recent call last):
File "C:\Users\NamelessKing\AppData\Local\Programs\Python\Python37\Scripts\cli50-script.py", line 11, in
load_entry_point('cli50==3.0.0', 'console_scripts', 'cli50')()
File "c:\users\namelessking\appdata\local\programs\python\python37\lib\site-packages\cli50_main_.py", line 172, in main
child = pexpect.spawn("docker", ["start", "--attach", "--interactive", container], dimensions=(lines, columns),
AttributeError: module 'pexpect' has no attribute 'spawn'
As by checking hash of latest image on Docker Hub via API, https://hackernoon.com/inspecting-docker-images-without-pulling-them-4de53d34a604, thus only executing docker pull
and outputting, e.g.,
Using default tag: latest
latest: Pulling from cs50/cli
Digest: sha256:d9bc084486eb3cbe444416625dff1737afa5a187e0199d8395b57ecd5f77d1cb
Status: Image is up to date for cs50/cli:latest
if a newer image is actually being pulled.
When running commands like make
inside cli50, the output does not have color. I tried replacing the subprocess.call
line with pexpect.spawn("docker", ["run"] + options + ["cs50/cli"]).interact()
, which uses a pseudo-tty, but this didn't fix the issue. Colorful output from make
and friends would be nice for using cli50 in section.
It would be nice if we can add our own vimrc.local file.. How can I do that? I don't find any way.. By the way, I am newbie in docker...
Once moby/moby#25450 resolved for Docker for Mac, per moby/moby#35407 and moby/moby#37172.
$ cli50
A newer version of cs50/cli:latest is available. Pull now? [Y/n] y
latest: Pulling from cs50/cli
Digest: sha256:0c3b7185b76b40198b4580d7368729a484cb2b9891edbc4e2636d0abb12d2168
Status: Image is up to date for cs50/cli:latest
docker.io/cs50/cli:latest
0.0.0.0:55007->5000/tcp, 0.0.0.0:55006->8080/tcp
/mnt/ $
This line currently hangs if, e.g., port 5000 is in use:
Lines 262 to 264 in 4b0f08a
Can see symptom by running docker
manually as follows (with some process already bound to TCP 5000):
$ docker run --detach --env WORKDIR=/mnt --interactive --label cli50 --rm --security-opt seccomp=unconfined --tty --volume /Users/malan/cs50.ly:/mnt --workdir /mnt --expose 5000 --publish 5000:5000 cs50/cli:latest bash --login
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
a201cd887381690cebdb239fa08c6f5c5dcd871ee1b9cb0fb27f74db9d5fd73e
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use.
The above indeed hangs, without returning the user to a prompt. If you omit --detatch
, you get this instead:
$ docker run --env WORKDIR=/mnt --interactive --label cli50 --rm --security-opt seccomp=unconfined --tty --volume /Users/malan/cs50.ly:/mnt --workdir /mnt --expose 5000 --publish 5000:5000 cs50/cli:latest bash --login
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use.
ERRO[0000] error waiting for container: context canceled
$ echo $?
125
I'm currently using an M1 iMac, but problem seems to relate to port, not the WARNING.
Even though we have -i
and --image
, I would envision these flags additionally:
cs50/ide
image is running at a timeopen http://localhost:1337
once the container is runningE.g., adding
print(digest)
print(RepoDigest)
below
Line 185 in 0f313f3
$ cli50
sha256:f3809a9479eafe7e3bc200da6bb48d0660333f05dc63ef652ae4b8f7b19d7496
cs50/cli@sha256:8b809e8a270af188ae5713e811d2dd05c44d6ceefdf8d558c400959956ee8043
wherein the hashes don't match. But updating via cli50
(or running docker pull cs50/cli:latest
) yields:
$ docker pull cs50/cli
Using default tag: latest
latest: Pulling from cs50/cli
Digest: sha256:8b809e8a270af188ae5713e811d2dd05c44d6ceefdf8d558c400959956ee8043
Status: Image is up to date for cs50/cli:latest
docker.io/cs50/cli:latest
In https://github.com/cs50/cs50.readthedocs.io as well.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 316, in connect
conn = self._new_conn()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x10f9f5828>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='auth.docker.io', port=443): Max retries exceeded with url: /token?scope=repository:cs50/cli:pull&service=registry.docker.io (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10f9f5828>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/cli50", line 11, in <module>
load_entry_point('cli50==3.3.0', 'console_scripts', 'cli50')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cli50/__main__.py", line 157, in main
response = requests.get(f"https://auth.docker.io/token?scope=repository:{IMAGE}:pull&service=registry.docker.io")
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='auth.docker.io', port=443): Max retries exceeded with url: /token?scope=repository:cs50/cli:pull&service=registry.docker.io (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10f9f5828>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.