|
@@ -1,4 +1,5 @@
|
|
|
import time as python_time
|
|
|
+import json
|
|
|
|
|
|
class PrimitiveFinished(Exception):
|
|
|
"""Exception to indicate the result value of a primitive, as a return cannot be used."""
|
|
@@ -209,13 +210,12 @@ def cast_e2s(a, **remainder):
|
|
|
|
|
|
def cast_v2s(a, **remainder):
|
|
|
a_value, = yield [("RV", [a])]
|
|
|
- if isinstance(a_value, (str, unicode)):
|
|
|
- # String should be encoded to distinguish between 3 and "3"
|
|
|
- a_value = '"%s"' % a_value
|
|
|
- elif isinstance(a_value, dict):
|
|
|
+ if isinstance(a_value, dict):
|
|
|
# Action or type
|
|
|
- a_value = a_value["value"]
|
|
|
- result, = yield [("CNV", ["%s" % (a_value)])]
|
|
|
+ value = a_value["value"]
|
|
|
+ else:
|
|
|
+ value = json.dumps(a_value)
|
|
|
+ result, = yield [("CNV", [value])]
|
|
|
raise PrimitiveFinished(result)
|
|
|
|
|
|
def cast_id2s(a, **remainder):
|
|
@@ -409,3 +409,10 @@ def __sleep(a, b, **remainder):
|
|
|
timeout, interruptable = yield [("RV", [a]), ("RV", [b])]
|
|
|
yield [("SLEEP", [timeout, interruptable])]
|
|
|
raise PrimitiveFinished(a)
|
|
|
+
|
|
|
+def is_error(a, **remainder):
|
|
|
+ if a is None:
|
|
|
+ result, = yield [("CNV", [True])]
|
|
|
+ else:
|
|
|
+ result, = yield [("CNV", [False])]
|
|
|
+ raise PrimitiveFinished(result)
|