kopia lustrzana https://github.com/biobootloader/wolverine
commit
10fd162ce3
|
@ -0,0 +1,31 @@
|
||||||
|
const subtractNumbers = (a, b) => {
|
||||||
|
return a - b;
|
||||||
|
};
|
||||||
|
|
||||||
|
const multiplyNumbers = (a, b) => {
|
||||||
|
return a * b;
|
||||||
|
};
|
||||||
|
|
||||||
|
const divideNumbers = (a, b) => {
|
||||||
|
return a / b;
|
||||||
|
};
|
||||||
|
|
||||||
|
function calculate(operation, num1, num2) {
|
||||||
|
let result = '';
|
||||||
|
if (operation == 'add') {
|
||||||
|
result = addNumbers(num1, num2);
|
||||||
|
} else if (operation == 'subtract') {
|
||||||
|
result = subtractNumbers(num1, num2);
|
||||||
|
} else if (operation == 'multiply') {
|
||||||
|
result = multiplyNumbers(num1, num2);
|
||||||
|
} else if (operation == 'divide') {
|
||||||
|
result = divideNumbers(num1, num2);
|
||||||
|
} else {
|
||||||
|
console.log('Invalid operation');
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [, , operation, num1, num2] = process.argv;
|
||||||
|
calculate(operation, num1, num2);
|
14
wolverine.py
14
wolverine.py
|
@ -23,10 +23,18 @@ with open("prompt.txt") as f:
|
||||||
|
|
||||||
def run_script(script_name, script_args):
|
def run_script(script_name, script_args):
|
||||||
script_args = [str(arg) for arg in script_args]
|
script_args = [str(arg) for arg in script_args]
|
||||||
try:
|
"""
|
||||||
result = subprocess.check_output(
|
If script_name.endswith(".py") then run with python
|
||||||
[sys.executable, script_name, *script_args], stderr=subprocess.STDOUT
|
else run with node
|
||||||
|
"""
|
||||||
|
subprocess_args = (
|
||||||
|
[sys.executable, script_name, *script_args]
|
||||||
|
if script_name.endswith(".py")
|
||||||
|
else ["node", script_name, *script_args]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = subprocess.check_output(subprocess_args, stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return e.output.decode("utf-8"), e.returncode
|
return e.output.decode("utf-8"), e.returncode
|
||||||
return result.decode("utf-8"), 0
|
return result.decode("utf-8"), 0
|
||||||
|
|
Ładowanie…
Reference in New Issue