-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParse.py
More file actions
29 lines (26 loc) · 727 Bytes
/
Parse.py
File metadata and controls
29 lines (26 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import tempfile
import subprocess
import os
'''
File parser, takes in code in a language and runs it
'''
def run_command(filename, contents):
fileext = filename.split(".")[1]
scriptFile = tempfile.NamedTemporaryFile(delete=False)
scriptFile.write(str.encode(contents))
scriptFile.close()
scriptFileLocation = scriptFile.name
language = {
"js": run_js(scriptFileLocation),
"py": "one",
"clj": "two",
}
language.get(fileext, "clj")
def run_js(scriptFileLocation):
str = os.popen('node '+ scriptFileLocation).read()
print(str)
return str
def run_py(scriptFileLocation):
str = os.popen('python3 ' + scriptFileLocation).read()
print(str)
return str