Skip to content

Commit 5d0bf1d

Browse files
committed
ready for 0.6 release
1 parent 8ffba2a commit 5d0bf1d

File tree

9 files changed

+223
-38
lines changed

9 files changed

+223
-38
lines changed

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.6] - Jan x, 2020
5+
## [0.6] - Jan 5, 2020
66

77
### Added
88

9-
- New optional argument, `number_of_runs` in `run()` method, use this to specify no.of times you want to run the code.
10-
- Ported NEW Languages. CodeRunner now supports all languages, judge0 provides.
11-
- New method `setFlags(options)` for setting ptions for the compiler (i.e. compiler flags).
9+
- New optional argument, `number_of_runs` in `run()` method, use this to specify no.of times you want to run the code. Default is set to 1.
10+
- Ported NEW Languages. CodeRunner now supports all languages provided by Judge0.
11+
- `setFlags(options)` for setting options for the compiler (i.e. compiler flags).
12+
- `setArguments(arguments)` for setting Command line arguments for the program.
1213

1314
### Changed
1415
- Minor internal improvemets.

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ python tests.py
7777
5. Lint the project with
7878
```bash
7979
flake8 coderunner --max-line-length=88 --ignore=F401
80-
pylint coderunner --disable=bad-continuation,invalid-name,too-many-instance-attributes
80+
black --check --diff coderunner
8181
```
8282

8383
## πŸ“ Changelog

β€Žcoderunner/coderunner.pyβ€Ž

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,36 @@
99
import urllib.request
1010

1111
# language IDs on judge0, see Documentation
12-
languages = {'Assembly': 45, 'Bash': 46, 'Basic': 47, 'C': 50, 'C++': 54, 'C#': 51, 'Common Lisp': 55, 'D': 56, 'Elixir': 57, 'Erlang': 58, 'Executable': 44, 'Fortran': 59, 'Go': 60, 'Haskell': 61, 'Java': 62, 'JavaScript': 63, 'Lua': 64, 'OCaml': 65, 'Octave': 66, 'Pascal': 67, 'PHP': 68, 'Plain Text': 43, 'Prolog': 69, 'Python2': 70, 'Python3': 71, 'Ruby': 72, 'Rust': 73, 'TypeScript': 74}
12+
languages = {
13+
"Assembly": 45,
14+
"Bash": 46,
15+
"Basic": 47,
16+
"C": 50,
17+
"C++": 54,
18+
"C#": 51,
19+
"Common Lisp": 55,
20+
"D": 56,
21+
"Elixir": 57,
22+
"Erlang": 58,
23+
"Executable": 44,
24+
"Fortran": 59,
25+
"Go": 60,
26+
"Haskell": 61,
27+
"Java": 62,
28+
"JavaScript": 63,
29+
"Lua": 64,
30+
"OCaml": 65,
31+
"Octave": 66,
32+
"Pascal": 67,
33+
"PHP": 68,
34+
"Plain Text": 43,
35+
"Prolog": 69,
36+
"Python2": 70,
37+
"Python3": 71,
38+
"Ruby": 72,
39+
"Rust": 73,
40+
"TypeScript": 74,
41+
}
1342

1443
api_params = {
1544
"cpu_time_limit": "2",
@@ -27,6 +56,12 @@
2756
FIELDS = "?fields=stdout,memory,time,status,stderr,exit_code,created_at"
2857

2958

59+
class ValueTooLargeError(Exception):
60+
"""Raised when the input value is too large"""
61+
62+
pass
63+
64+
3065
class code:
3166
"""
3267
Args:
@@ -157,7 +192,21 @@ def getTime(self):
157192

158193
def setFlags(self, options: str):
159194
"""Options for the compiler (i.e. compiler flags)"""
160-
api_params["compiler_options"] = options
195+
try:
196+
if len(options) > 128:
197+
raise ValueTooLargeError
198+
api_params["compiler_options"] = options
199+
except ValueTooLargeError:
200+
print("Maximum 128 characters allowed")
201+
202+
def setArguments(self, arguments: str):
203+
"""Command line arguments for the program"""
204+
try:
205+
if len(arguments) > 128:
206+
raise ValueTooLargeError
207+
api_params["command_line_arguments"] = arguments
208+
except ValueTooLargeError:
209+
print("Maximum 128 characters allowed")
161210

162211
def run(self, number_of_runs: int = 1):
163212
"""Submit the source code on judge0's server & return status"""

β€Ždemo.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import pprint
33

44
source_code = "testfiles/" + "test_python_input.py"
5-
language = "Python"
5+
language = "Python3"
66
output = "testfiles/output/" + "output2.txt"
77
Input = "testfiles/input/" + "input.txt"
88
r = coderunner.code(source_code, language, output, Input)
99

10-
r2 = coderunner.code("print(\"yo\")", "Python", "YO", path=False)
10+
r2 = coderunner.code("print(\"yo\")", "Python3", "YO", path=False)
1111

1212
# run the code
1313
r.run()

β€Ždocs/changelog.mdβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33

44

5+
## [0.6] - Jan 5, 2020
6+
7+
### Added
8+
9+
- New optional argument, `number_of_runs` in `run()` method, use this to specify no.of times you want to run the code. Default is set to 1.
10+
- Ported NEW Languages. CodeRunner now supports all languages provided by Judge0.
11+
- [`setFlags(options)`](/usage/#9-setflagsoptions) for setting options for the compiler (i.e. compiler flags).
12+
- [`setArguments(arguments)`](/usage/#10-setargumentsarguments) for setting Command line arguments for the program.
13+
14+
### Changed
15+
- Minor internal improvemets.
16+
17+
518
## [0.5] - Dec 20, 2019
619

720
### Added

β€Ždocs/index.mdβ€Ž

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,102 @@
22

33
> A judge πŸ‘¨πŸ½β€βš–οΈ for your programs, run and test your programs through Python
44
5-
[![Build Status](https://travis-ci.org/codeclassroom/CodeRunner.svg?branch=master)](https://travis-ci.org/codeclassroom/CodeRunner)
5+
66
![PyPI](https://img.shields.io/pypi/v/coderunner?color=blue)
7+
[![Build Status](https://travis-ci.org/codeclassroom/CodeRunner.svg?branch=master)](https://travis-ci.org/codeclassroom/CodeRunner)
8+
[![codecov](https://codecov.io/gh/codeclassroom/CodeRunner/branch/master/graph/badge.svg)](https://codecov.io/gh/codeclassroom/CodeRunner)
9+
![PyPI - Format](https://img.shields.io/pypi/format/coderunner?color=orange)
10+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/coderunner)
711
[![Documentation Status](https://readthedocs.org/projects/coderunner/badge/?version=latest)](https://coderunner.readthedocs.io/en/latest/?badge=latest)
8-
[![GitHub license](https://img.shields.io/github/license/codeclassroom/CodeRunner)](https://github.com/codeclassroom/CodeRunner/blob/master/LICENSE)
9-
[![GitHub issues](https://img.shields.io/github/issues/codeclassroom/CodeRunner?color=blueviolet)](https://github.com/codeclassroom/CodeRunner/issues)
10-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com)
12+
![PyPI - Downloads](https://img.shields.io/pypi/dm/coderunner?color=blue)
13+
14+
15+
## Installation
16+
17+
Install using `pip` from PyPI
18+
19+
```bash
20+
pip install coderunner
21+
```
22+
23+
or directly from GitHub if you cannot wait to test new features
24+
25+
```bash
26+
pip install git+https://github.com/codeclassroom/CodeRunner.git
27+
```
28+
29+
## Usage
30+
31+
```python
32+
33+
import coderunner
34+
35+
source_code = "path-to/test_python.py"
36+
language = "Python"
37+
expected_output = "path-to/output.txt"
38+
standard_input = "path-to/input.txt"
39+
40+
# use this if you have a standard input to Program
41+
r = coderunner.code(source_code, language, expected_output, standard_input)
42+
43+
# otherwise
44+
r = coderunner.code(source_code, language, expected_output)
45+
46+
# Use path=False if not using file paths
47+
r = coderunner.code("Hello, World", language, "Hello, World", path=False)
48+
```
49+
50+
## Documentation
51+
52+
> [CodeRunner Documentation](https://coderunner.readthedocs.io/en/latest/)
53+
54+
55+
## Development
56+
57+
##### Prerequisites
58+
- Python 3.6+
59+
- virtualenv
60+
61+
1. Create virtual environment.
62+
```bash
63+
virtualenv -p python3 venv && cd venv && source bin/activate
64+
```
65+
2. Clone the repository.
66+
```bash
67+
git https://github.com/codeclassroom/CodeRunner.git
68+
```
69+
3. Install Dependencies.
70+
```bash
71+
pip install -r requirements.txt
72+
```
73+
4. Run tests.
74+
```bash
75+
python tests.py
76+
```
77+
5. Lint the project with
78+
```bash
79+
flake8 coderunner --max-line-length=88 --ignore=F401
80+
black --check --diff coderunner
81+
```
82+
83+
## πŸ“ Changelog
84+
85+
See the [CHANGELOG.md](CHANGELOG.md) file for details.
86+
87+
88+
## Author
89+
90+
πŸ‘₯ **Bhupesh Varshney**
91+
92+
- Twitter: [@bhupeshimself](https://twitter.com/bhupeshimself)
93+
- DEV: [bhupesh](https://dev.to/bhupesh)
94+
95+
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
96+
97+
## πŸ“œ License
98+
99+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
100+
101+
## πŸ‘‹ Contributing
102+
103+
Please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines for the process of submitting pull requests to us.

β€Ždocs/judge0.mdβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ CodeRunner is powered by Judge0 api.<br>
99
The following api parameters are set default by coderunner:
1010
```python
1111

12-
api_params = {
13-
"number_of_runs": "1",
12+
{
1413
"cpu_time_limit": "2",
1514
"cpu_extra_time": "0.5",
1615
"wall_time_limit": "5",

0 commit comments

Comments
Β (0)