Giter Club home page Giter Club logo

cli50's People

Contributors

ashenm avatar cmlsharp avatar coderigo17 avatar dmalan avatar kzidane avatar rongxin-liu avatar ummcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli50's Issues

version UNKNOWN

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.

mount current working directory when logging into a running container

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.

Example:

1. My case

I already have a running container, and I don't want to delete this (not after the course):

image

I'm going to try logging in and hoping it mounts my current working dir. (I'm using VSCode btw):

image

Result:

image

2. Standard usage

Here is the standard usage of cli50

image

...and it launched up a new instance

image

Have a nice day! :D

can't run cli50 on windows 10

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'

cli50 bash sometimes ignores first letter

When I start cli50 it is not possible to enter comands as the first letter is sometimes ignored.

Here I use Cmder as console application:
git-test

Using cmd it is even worse
git-test

I have the lastest docker/cli50 image and did upgrade cli50 via pip.

Max

Make output is not colored

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.

On M1 Mac, cli50 thinks newer version is available but there isn't

$ 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/ $

cli50 hangs if port is in use

This line currently hangs if, e.g., port 5000 is in use:

cli50/cli50/__main__.py

Lines 262 to 264 in 4b0f08a

container = subprocess.check_output(["docker", "run"] + options +
[item for sublist in [['--publish', f'{port}:{port}'] for port in args["port"]] for item in sublist] +
[f"{IMAGE}:{args['tag']}"] + cmd, stderr=subprocess.STDOUT).decode("utf-8").rstrip()

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.

Add -I, --ide flags that start and open cs50/ide?

Even though we have -i and --image, I would envision these flags additionally:

  1. ensuring only one cs50/ide image is running at a time
  2. executing an open http://localhost:1337 once the container is running

cli50 keeps indicating that a newer version of cs50/cli:latest is available

E.g., adding

            print(digest)
            print(RepoDigest)

below

elif digest and RepoDigest and f"{IMAGE}@{digest}" != RepoDigest:
results in output like

$ 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

catch exceptions when no internet connection

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',))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.