Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .coveragerc

This file was deleted.

10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ ok
*.ok_history
misUcount.json

# OAuth configuration
client/utils/oauth_config.py

# IPython
.ipynb_checkpoints/

# IDE
*.iml
.idea/

# demo files
demo/
uv.lock
.python-version
.mypy_cache
.claude
.pytest_cache
5 changes: 0 additions & 5 deletions .ok_storage.bak

This file was deleted.

Binary file removed .ok_storage.dat
Binary file not shown.
5 changes: 0 additions & 5 deletions .ok_storage.dir

This file was deleted.

15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
ok client
=========
ok
==

The ok client script (written in Python) supports programming projects
by running tests, tracking progress, and assisting in debugging.

Visit [http://okpy.org](http://okpy.org) to use our hosted service for
your course.

The ok client software was developed for CS 61A at UC Berkeley.
The ok script is a wrapper around pytest (with the pytest-grader extension)
that provides AI assistance when test cases fail.

[![Build Status](https://travis-ci.org/okpy/ok-client.svg?branch=master)](https://travis-ci.org/okpy/ok-client)
[![PyPI Version](http://img.shields.io/pypi/v/okpy.svg)](https://pypi.python.org/pypi/okpy)
Expand All @@ -17,7 +12,7 @@ The ok client software was developed for CS 61A at UC Berkeley.
### Installation

1. Clone this repo
2. Install [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/)
2. Use `uv` to create a virtual env:
3. Create a virtual environment:

virtualenv -p python3 env
Expand Down
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")"
uv build --out-dir dist

# Create standalone zipapp
TEMP_DIR=$(mktemp -d)
uv pip install --target "$TEMP_DIR" dist/ok-*.whl
echo "from client.cli.ok import main; main()" > "$TEMP_DIR/__main__.py"
uv run python -m zipapp --output dist/ok --python "/usr/bin/env python3" "$TEMP_DIR"
rm -rf "$TEMP_DIR"
50 changes: 5 additions & 45 deletions client/__main__.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,6 @@
import sys
import os
#!/usr/bin/env python3
"""Entry point for ok zipapp."""
from client.cli.ok import main

VERSION_MESSAGE = """
ERROR: You are using Python {}.{}, but OK requires Python 3.4 or higher.
Make sure you are using the right command (e.g. `python3 ok` instead of
`python ok`) and that you have Python 3 installed.
""".strip()

if sys.version_info[:2] < (3, 4):
print(VERSION_MESSAGE.format(*sys.version_info[:2]))
sys.exit(1)

from client.cli import ok
from client.utils import config
import certifi

def patch_requests():
""" Customize the cacerts.pem file that requests uses.
Automatically updates the cert file if the contents are different.
"""
config.create_config_directory()
ca_certs_file = config.CERT_FILE
ca_certs_contents = certifi.__loader__.get_data('certifi/cacert.pem')

should_write_certs = True

if os.path.isfile(ca_certs_file):
with open(ca_certs_file, 'rb') as f:
existing_certs = f.read()
if existing_certs != ca_certs_contents:
should_write_certs = True
print("Updating local SSL certificates")
else:
should_write_certs = False

if should_write_certs:
with open(ca_certs_file, 'wb') as f:
f.write(ca_certs_contents)

os.environ['REQUESTS_CA_BUNDLE'] = ca_certs_file

patch_requests()

if __name__ == '__main__':
ok.main()
if __name__ == "__main__":
main()
Empty file removed client/api/__init__.py
Empty file.
Loading
Loading