Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install/run with pipenv #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
105 changes: 105 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# See https://github.com/github/gitignore/blob/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
19 changes: 19 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pdf = "*"
PyPDF2 = "*"
Reportlab = "*"
nameparser = "*"
PyYaml = "*"
pyyaml = "*"
"e1839a8" = {path = ".", editable = true}

[dev-packages]
"e1839a8" = {path = ".", editable = true}

[requires]
python_version = "3.6"
149 changes: 149 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 54 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,79 @@ Sort and watermark PDFs exported by GradeScope

# Installation

## Virtual environment
Clone this github repository to your machine.

Use a [python virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/)
## Python virtual environment

$ virtualenv ~/Library/virtualenvs/wsm

(you can call it whatever you want and place it wherever you want.) Activate the virtual environment:
Use the [`pipenv`](https://docs.pipenv.org/#install-pipenv-today) command to manage a [python virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/).

$ source ~/Library/virtualenvs/wsm/bin/activate
(wsm):$ which python
/Users/matthew/Library/virtualenvs/wsm/bin/python

Now anything you do is in the virtual environment, and won't require root access or cluttering your user
python library.
On macOS with MacPorts:

$ sudo port install pipenv

On macOS with HomeBrew:

$ sudo brew install pipenv

On generic Unix, [install pip](https://pip.pypa.io/en/stable/installing/) if not installed and use:

$ pip install pipenv

Then, within this project directory, run:

$ pipenv install .

## Helper packages

Someday: package the script with an installer that does this automatically.
The `pipenv install` command above should import the packages below into the virtual environment automatically:

$ pip install PyYaml
$ pip install pdf
$ pip install pyPDF
$ pip install Reportlab
$ pip install nameparser
* PyYaml
* pdf
* pyPDF
* ReportLab
* nameparser

## Script

Download the python script. Or, you can clone the full github repository.
The `pipenv install` command above will also install an executable module called `watermarkGradeScopeExport.py`. This is normally what you would run.

# Usage

Within the project folder, run:

$ pipenv shell

This will activate the virtual environment. You'll get a message such as:

Spawning environment shell (/bin/bash). Use 'exit' to leave.
bash-3.2$ . /Users/matthew/.local/share/virtualenvs/watermark-pdfs-bOgaLKHv/bin/activate
(watermark-pdfs-bOgaLKHv) bash-3.2$

From now on, until you run `exit`, the script `watermarkGradeScopeExport.py` is in scope.

You will need to download submissions from a (presumably graded) Gradescope assignment.

1. Go to the assignment and click "Review Grades" on the left menu column.
2. Look for the "Export Submissions" button in the bottom toolbar.
3. It takes some time, so you'll get a "please wait..." screen. Once it's finished, you'll get a download link on the webpage, and through email.
4. Download the `submissions.zip` file.
5. Unzip it into some working directory. You should see a directory called `assignment_nnnnn_export`, with a bunch of PDFs and a `.yml` file.
5. Unzip it into some working directory. You should see a directory called `assignment_nnnnn_export`, with a bunch of PDFs and a YAML (`.yml`) file.

Change into that directory and run `watermarkGradeScopeExport.py`. If all goes well, you'll get a directory for each student, with their watermarked PDF therein.

If you'd rather not use the pipenv shell, you can run the script out of its
vitual environment directory. This requires some extra typing and tabbing:

$ /Users/matthew/.local/share/virtualenvs/watermark-pdfs-bOgaLKHv/bin/watermarkGradeScopeExport.py

(Use the directory indicated the first time you run `pipenv shell`) You can
also do fancy things like

Change into that directory and run:
* make a shell alias to that long file path
* make a symbolic link from one of the directories in `$PATH` to the
virtual environment, or
* add the virtual environment's `bin` directory to your `$PATH`
environment variable in your `.login` or `.profile` or similar
file

$ python path/to/script

If all goes well, you'll get a directory for each student, with their watermarked PDF therein.
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from distutils.core import setup

setup(
name="Watermark GradeScope Export",
version='0.1',
scripts=['watermarkGradeScopeExport.py']
)

2 changes: 2 additions & 0 deletions watermarkGradeScopeExport.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

#need to install PyYaml, pyPDF, Reportlab.pdfgen, nameparser
from PyPDF2 import PdfFileWriter, PdfFileReader
from reportlab.pdfgen import canvas
Expand Down