Skip to content

Commit 0a42adc

Browse files
committed
Docs updated
- add support for Bash 4.4
1 parent 9a37bfa commit 0a42adc

File tree

2 files changed

+61
-33
lines changed

2 files changed

+61
-33
lines changed

coderunner/coderunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import requests
99

1010
# language IDs on judge0, see Documentation
11-
languages = {"C++": 10, "Java": 27, "Python": 34, "C": 4}
11+
languages = {"C++": 10, "Java": 27, "Python": 34, "C": 4, "Bash": 1}
1212

1313
api_params = {
1414
"number_of_runs": "1",

docs/api-usage.md

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
coderunner provides the following class constructors
44

5-
### Run(source, lang, output, inp)
5+
### code(source, lang, output, inp, path)
66

77
* **Parameters** :
88
- source : The Source Code
99
- lang : The Programming Language
1010
- output : Expected Output of the Program
1111
- inp : Standard Input to the program (optional).
12-
- path : specify mode of input.Set this to `False` if you are not using file paths (optional)
12+
- path : specify mode of input. Set this to `False` if you are not using file paths (optional)
1313

1414
**Demo**:
1515
```python
1616

1717
import coderunner
1818

19-
program_name = "path-to/test_python.py"
19+
source_code = "path-to/test_python.py"
2020
language = "Python"
21-
output = "path-to/output.txt"
22-
Input = "path-to/input.txt"
21+
expected_output = "path-to/output.txt"
22+
standard_input = "path-to/input.txt"
2323

2424
# use this if you have a standard input to Program
25-
r = coderunner.Run(program_name, language, output, Input)
25+
r = coderunner.code(source_code, language, expected_output, standard_input)
2626

2727
# otherwise
28-
r = coderunner.Run(program_name, language, output)
28+
r = coderunner.code(source_code, language, expected_output)
2929

30-
# if not using file paths
31-
r = coderunner.Run("Hello, World", language, "Hello, World", path=False)
30+
# Use path=False if not using file paths
31+
r = coderunner.code("Hello, World", language, "Hello, World", path=False)
3232
```
3333

3434
**Pointers ✏**
@@ -39,33 +39,61 @@ r = coderunner.Run("Hello, World", language, "Hello, World", path=False)
3939
- C++ (g++ 7.2.0)
4040
- Java (OpenJDK 8)
4141
- Python (3.6.0)
42+
- Bash (4.4)
4243
- Languages should be specified as string like "C++", "Java" etc.
4344

4445

45-
Methods available in class `Run()`.
46+
Methods available in class `code()`.
4647

47-
### 1. getStatus()
48+
### 1. run()
49+
**Parameters** : `None` <br>
50+
**Return Type** : `None` <br>
51+
**Description**: Submits the program on Judge0's server.<br>
52+
**Demo**:
53+
```python
54+
55+
r.run()
56+
57+
```
58+
59+
### 2. getStatus()
4860

4961
**Parameters** : `None` <br>
5062
**Return Type** : `String` <br>
51-
**Description**: Submits the program on Judge0's server and returns its status. Returns either `Accepted` or `Runtime Error (NZEC)`.<br>
63+
**Description**: Returns submission status.<br>
64+
65+
- List of Statuses :
66+
- In Queue
67+
- Processing
68+
- Accepted
69+
- Wrong Answer
70+
- Time Limit Exceeded
71+
- Compilation Error
72+
- Runtime Error (SIGSEGV)
73+
- Runtime Error (SIGXFSZ)
74+
- Runtime Error (SIGFPE)
75+
- Runtime Error (SIGABRT)
76+
- Runtime Error (NZEC)
77+
- Runtime Error (Other)
78+
- Internal Error
79+
- Exec Format Error
80+
5281
**Demo**:
5382
```python
5483

55-
r.getStatus()
56-
# Accepted or Runtime Error (NZEC)
84+
status = r.getStatus()
85+
# Accepted, Wrong Answet etc.
5786
```
5887

59-
### 2. getError()
88+
### 3. getError()
6089

6190
**Parameters** : `None` <br>
6291
**Return Type** : `String` <br>
6392
**Description**: Returns any error occured during program execution.
6493
**Demo**:
6594
```python
6695

67-
r.getError()
68-
# For e.g
96+
error = r.getError()
6997
"""
7098
'Error : File "main.py", line 2\n'
7199
' print("Hello, " name)\n'
@@ -74,62 +102,62 @@ r.getError()
74102
"""
75103
```
76104

77-
### 3. getOutput()
105+
### 4. getOutput()
78106

79107
**Parameters** : `None` <br>
80108
**Return Type** : `String` <br>
81109
**Description**: Returns the standard output of the program.<br>
82110
**Demo**:
83111
```python
84112

85-
r.getOutput()
86-
# For e.g 'Hello, World\n'
113+
stdout = r.getOutput()
114+
# 'Hello, World\n'
87115
```
88116

89-
### 4. getMemory()
117+
### 5. getMemory()
90118

91119
**Parameters** : `None` <br>
92120
**Return Type** : `String` <br>
93121
**Description**: Returns the memory used by the program (in kilobytes).<br>
94122
**Demo**:
95123
```python
96124

97-
r.getMemory()
98-
# For e.g 3688
125+
memory = r.getMemory()
126+
# 3688
99127
```
100128

101-
### 5. getTime()
129+
### 6. getTime()
102130

103131
**Parameters** : `None` <br>
104132
**Return Type** : `String` <br>
105133
**Description**: Returns execution time of the program. <br>
106134
**Demo**:
107135
```python
108136

109-
r.getTime()
110-
# For e.g 0.031 seconds
137+
time_consumed = r.getTime()
138+
# 0.031 seconds
111139
```
112140

113-
### 6. getExitCode()
141+
### 7. getExitCode()
114142

115143
**Parameters** : `None` <br>
116144
**Return Type** : `String` <br>
117145
**Description**: Returns exit code of program. <br>
118146
**Demo**:
119147
```python
120148

121-
r.getExitCode()
122-
# For e.g 0 on Accepted and 1 on Run Time Error
149+
exit_code = r.getExitCode()
150+
# 0 on Accepted and 1 on Run Time Error
123151
```
124152

125-
### 7. getSubmissionDate()
153+
### 8. getSubmissionDate()
126154

127155
**Parameters** : `None` <br>
128156
**Return Type** : `String` <br>
129157
**Description**: Returns submission date/time of the program on Judge0's Server. <br>
130158
**Demo**:
131159
```python
132160

133-
r.getSubmissionDate()
134-
# For e.g 2019-11-11T13:27:15.909Z
161+
sub_date = r.getSubmissionDate()
162+
# 2019-11-11T13:27:15.909Z
135163
```

0 commit comments

Comments
 (0)