Skip to content

Commit

Permalink
Deleted files, re-add distributer
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsmie committed Nov 28, 2023
1 parent 807c5ba commit 1db5346
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 50 deletions.
2 changes: 0 additions & 2 deletions .buildpacks

This file was deleted.

1 change: 0 additions & 1 deletion Procfile

This file was deleted.

3 changes: 0 additions & 3 deletions config/local.example.json

This file was deleted.

4 changes: 0 additions & 4 deletions config/production.example.json

This file was deleted.

4 changes: 0 additions & 4 deletions config/production.json

This file was deleted.

18 changes: 0 additions & 18 deletions run.py

This file was deleted.

18 changes: 0 additions & 18 deletions runlocal.py

This file was deleted.

36 changes: 36 additions & 0 deletions src/rollbot/plottenbakker/distributer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys
from datetime import timedelta
from rollbot.interpreter.calculator import distribute, EvaluationError
from rollbot.varenv import VarEnv
from lark.exceptions import UnexpectedInput


if __name__ == "__main__":
varenv_name = sys.stdin.readline().strip()
expression = sys.stdin.readline().strip()

try:
env = VarEnv(varenv_name)
except:
print("No such environment")
sys.exit(1)

try:
data = distribute(expression, timedelta(seconds=5), env)
if not data:
print(f"Unprocessable input")
sys.exit(1)
xbins, data, num_rolls = data
except EvaluationError as e:
print(e.args[0])
sys.exit(1)
except UnexpectedInput as e:
print(f"Unexpected input: ```\n{e.get_context(expression)}```")
sys.exit(1)
except:
print("Server error")
sys.exit(1)

print(" ".join(str(x) for x in xbins))
print(" ".join(str(x) for x in data))
print(num_rolls)

0 comments on commit 1db5346

Please sign in to comment.