Skip to content

Commit

Permalink
refactor how system scrypt make the call to cr.server
Browse files Browse the repository at this point in the history
  • Loading branch information
aless10 committed Aug 1, 2024
1 parent 0fc82b9 commit 47c520c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion integration/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def test_define_view_strict_subvariable_syntax(self):

scrunch_dataset = get_mutable_dataset(ds.body.id, self.site)
project.move_here([scrunch_dataset])
project.execute(script_body, strict_subvariable_syntax=True)
resp = project.execute(script_body, strict_subvariable_syntax=True)
wait_progress(resp, self.site.session)
view = scrunch_dataset.views.get_by_name("My view")
assert view.project.name == project.name

Expand Down
10 changes: 5 additions & 5 deletions scrunch/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def execute(self, script_body, strict_subvariable_syntax=None):

class SystemScript(BaseScript):

def format_request_url(self, execute, strict_subvariable_syntax=None):
def format_request_url(self, request_url, strict_subvariable_syntax=None):
strict_subvariable_syntax_flag = self.get_default_syntax_flag(strict_subvariable_syntax)
if strict_subvariable_syntax_flag:
execute.self += "?strict_subvariable_syntax=true"
request_url += "?strict_subvariable_syntax=true"
return request_url

def execute(self, script_body, strict_subvariable_syntax=None):
"""
Expand All @@ -70,9 +71,8 @@ def execute(self, script_body, strict_subvariable_syntax=None):
# The script execution endpoint is a shoji:view
payload = shoji_view_wrapper(script_body)
try:
execute = self.resource.execute
self.format_request_url(execute, strict_subvariable_syntax)
return execute.post(payload)
execute_url = self.format_request_url(self.resource.views['execute'], strict_subvariable_syntax)
return self.resource.session.post(execute_url, json=payload)
except pycrunch.ClientError as err:
resolutions = err.args[2]["resolutions"]
raise ScriptExecutionError(err, resolutions)
Expand Down

0 comments on commit 47c520c

Please sign in to comment.