Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #75 from mitodl/upgrade-to-python3
Browse files Browse the repository at this point in the history
* Upgrade to Python 3
* Add `venv` exclusion to `.gitignore`
  • Loading branch information
markbreedlove committed Nov 13, 2019
2 parents b798b86 + da10ede commit 866963b
Show file tree
Hide file tree
Showing 20 changed files with 421 additions and 287 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -60,4 +60,6 @@ docs/_build/
# PyBuilder
target/
#PyCharm
.idea
.idea
# Virtualenv
venv/
1 change: 1 addition & 0 deletions .python-version
@@ -0,0 +1 @@
3.7.5
3 changes: 2 additions & 1 deletion .travis.yml
@@ -1,8 +1,9 @@
language: python
python:
- 2.7
- 3.7
install:
- pip install tox
- pip install coveralls
script:
- tox
after_success:
Expand Down
24 changes: 24 additions & 0 deletions Development.rst
@@ -0,0 +1,24 @@

Upgrading or changing package dependencies
==========================================

``setup.py`` specifies acceptable constraints for package versions, which
usually follow Semantic Versioning conventions. The ``requirements`` files
specify exact versions for consistency between development, CI, and deployments.

1. Delete out and recreate your virtualenv environment, or uninstall packages. (E.g. ``pip uninstall -r requirements.txt``, etc.)
2. Edit ``setup.py``, specifying acceptable version constraints. The ``dev`` group of ``extras_require`` is for development and unit testing.
3. ``pip install -e .``
4. ``pip freeze >> requirements.txt`` and edit ``requirements.txt`` to preserve the ``--index-url`` and ``-e .`` lines.
5. ``pip install -e .[dev] >> test_requirements.txt`` and edit the file as above.
6. ``pip install -e .[doc] >> doc_requirements.txt`` and edit the file as above.

Running Tests
=============

Use ``tox``:

.. code-block:: sh
pip install -r test_requirements.txt
tox
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2014, Massachusetts Institute of Technology
Copyright (c) 2019, Massachusetts Institute of Technology
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -65,6 +65,10 @@ grades. PyLmod was created to support MIT's
use of OpenedX for residential courses, but the library is open source
to enable easier access for Python application developers at MIT.

Development
===========
See the `Development Notes <https://github.com/mitodl/PyLmod/Development.rst>`_

Licensing
=========
PyLmod is licensed under the BSD license, version January 9, 2008. See
Expand Down
55 changes: 51 additions & 4 deletions doc_requirements.txt
@@ -1,6 +1,53 @@
--index-url https://pypi.python.org/simple/
# Handy for development to install both

alabaster==0.7.12
apipkg==1.5
atomicwrites==1.3.0
attrs==19.3.0
Babel==2.7.0
certifi==2019.9.11
chardet==3.0.4
coverage==4.5.4
ddt==1.2.1
docutils==0.15.2
execnet==1.7.1
httpretty==0.9.7
idna==2.8
imagesize==1.1.0
importlib-metadata==0.23
Jinja2==2.10.3
MarkupSafe==1.1.1
mock==3.0.5
more-itertools==7.2.0
packaging==19.2
pep8==1.7.1
pluggy==0.13.0
pockets==0.9.1
py==1.8.0
pyflakes==2.1.1
Pygments==2.4.2
pyparsing==2.4.4
pytest==5.2.2
pytest-cache==1.0
pytest-cov==2.8.1
pytest-flakes==4.0.0
pytest-pep8==1.0.6
pytz==2019.3
requests==2.22.0
semantic-version==2.8.2
six==1.13.0
snowballstemmer==2.0.0
Sphinx==2.2.1
sphinx-bootstrap-theme==0.7.1
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-napoleon==0.7
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
urllib3==1.25.6
wcwidth==0.1.7
zipp==0.6.0

-e .
sphinx>=1.2.3
sphinx_bootstrap_theme>=0.4.5
sphinxcontrib-napoleon
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -37,7 +37,7 @@

# General information about the project.
project = u'PyLmod'
copyright = u'2015, MIT Office of Digital Learning'
copyright = u'2019, MIT Office of Digital Learning'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -121,7 +121,7 @@
epub_title = u'PyLmod'
epub_author = u'MIT Office of Digital Learning'
epub_publisher = u'MIT Office of Digital Learning'
epub_copyright = u'2015, MIT Office of Digital Learning'
epub_copyright = u'2019, MIT Office of Digital Learning'

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
Expand Down
5 changes: 5 additions & 0 deletions docs/development.rst
@@ -0,0 +1,5 @@
Development Notes
-----------------

.. include:: ../Development.rst

1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -12,6 +12,7 @@ Table of Contents
:maxdepth: 3

api
development

Indices and Search
==================
Expand Down
6 changes: 3 additions & 3 deletions pylmod/base.py
Expand Up @@ -72,7 +72,7 @@ def _data_to_json(data):
Args:
data (str): data to convert to json
"""
if type(data) not in [str, unicode]:
if type(data) != str:
data = json.dumps(data)
return data

Expand Down Expand Up @@ -107,15 +107,15 @@ def rest_action(self, func, url, **kwargs):
"""
try:
response = func(url, timeout=self.TIMEOUT, **kwargs)
except requests.RequestException, err:
except requests.RequestException as err:
log.exception(
"[PyLmod] Error - connection error in "
"rest_action, err=%s", err
)
raise err
try:
return response.json()
except ValueError, err:
except ValueError as err:
log.exception('Unable to decode %s', response.content)
raise err

Expand Down

0 comments on commit 866963b

Please sign in to comment.