Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task files in Json response for Windows #391

Closed
paulwinex opened this issue Dec 3, 2017 · 1 comment
Closed

Task files in Json response for Windows #391

paulwinex opened this issue Dec 3, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@paulwinex
Copy link

Error in server response on Windows 10
Example Code:

# get task files
cmd = af.Cmd()
cmd.data['type'] = 'jobs'
cmd.data['mode'] = 'files'
cmd.data['block_ids'] = [0]
cmd.data['task_ids'] = [0]
cmd.data['ids'] = [2]
cmd.action = 'get'
r = cmd._sendRequest()

Response

fnetwork.py: Received data:
{"task_files":{
"job_id":2,
"block_id":0,
"task_id":0,
"files":[
{"name":"c:/temp/afanasy\jobs\0\2.test.afanasy1\tasks\0.0\files\test.hip_test.afanasy1.1203-114446-072.hip.mantra1.0001.exr.jpg"}
]}}
JSON loads error:
Invalid \escape: line 6 column 25 (char 89)

Windows slashes should be escaped!
Temporary fix in afnetwork.py :
replace all to /

120:    data = data[data.find('JSON') + 4:]
ins>:  if os.name=='nt':data = re.sub(r'(?<=[^\\])(\\)(?=[^\\])', '/', data)
121:    struct = json.loads(data, strict=False)

or replace all to \

120:    data = data[data.find('JSON') + 4:]
ins>:   if os.name=='nt':data = re.sub(r'(?<=[^\\])(\\)(?=[^\\])', r'\\', data).replace('/', r'\\')
121:    struct = json.loads(data, strict=False)

But of course server should be sent correct data.

CGRU 2.2.3 Windows 10.

@timurhai
Copy link
Member

timurhai commented Dec 3, 2017

Yes, server should escape filenames. It is an afserver bug.

@timurhai timurhai self-assigned this Dec 3, 2017
@timurhai timurhai added the bug label Dec 3, 2017
@timurhai timurhai added this to the 2.3.0 milestone Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants