shraddheya shrivastava
shraddheya shrivastava

Reputation: 187

Gramex "$YAMLPATH" failing crashing

WORKING SCENARIO

When the gramex is ran with the following gramex.yaml:

schedule:
  create-job-startup:
    thread: true
    function: >
      logging.critical("hello world")
    startup: "*"

The output we get, as expected, is:

DEBUG   CRITICAL20-Sep 19:27:22 20-Sep 19:27:22 gramex__init__ hello world

FAILING SCENARIO

When the gramex is ran with the following gramex.yaml:

schedule:
  create-job-startup:
    thread: true
    function: >
      logging.critical("$YAMLPATH")
    startup: "*"

The output we get, as expected, is:

ERROR   20-Sep 19:33:25 __init__ 9988 (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (<unknown>, line 1)
Traceback (most recent call last):
  File "C:\Users\shraddheya.shrivasta\Anaconda3\lib\site-packages\gramex\services\__init__.py", line 242, in schedule
    ioloop=info._main_ioloop)
  File "C:\Users\shraddheya.shrivasta\Anaconda3\lib\site-packages\gramex\services\scheduler.py", line 31, in __init__
    self.function = build_transform(schedule, vars={}, filename='schedule:%s' % name)
  File "C:\Users\shraddheya.shrivasta\Anaconda3\lib\site-packages\gramex\transforms\transforms.py", line 183, in build_transform
    tree = ast.parse(expr)
  File "C:\Users\shraddheya.shrivasta\Anaconda3\lib\ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Upvotes: 0

Views: 25

Answers (1)

shraddheya shrivastava
shraddheya shrivastava

Reputation: 187

Use raw (r"...") string, For example:

schedule:
  create-job-startup:
    thread: true
    function: >
      logging.critical(r"$YAMLPATH")

Upvotes: 2

Related Questions