Skip to content

Inappropriate use of print #57

Description

@Toreno96

In multiple places in your SDK, you're using print outside the examples:

$ fd --exclude 'example' -X rg print
./HttpClient.py
95: print("Non 200 response:%s RequestId:%s URL:%s response:%s" %
./ObsoleteSmartlingFileApi.py
34: for k,v in response.items(): print k, ':' ,v
./MultipartPostHandler.py
78: print("Replacing %s with %s" % (request.get_header('content-type'), 'multipart/form-data'))
./SmartlingProjectsApiV2.py
32: for k,v in response.items(): print k, ':' ,v
./SmartlingFileApiV2.py
33: for k,v in response.items(): print k, ':' ,v
./AuthClient.py
53: print(e)
./FileApiBase.py
98: print ("code:%d RequestId:%s jsonBody=%s" % (code, rId, jsonBody))

e.g.

print("Non 200 response:%s RequestId:%s URL:%s response:%s"%
(status_code, headers.get("X-SL-Requestid","Unknown"), url, response_data)
)

That leads to unexpected results for the users (myself included):

In [18]: resp, status=jobs_api.getJobDetails('foo')
Non200response:404RequestId:UnknownURL:https://api.smartling.com/jobs-api/v3/projects/3bea86d16/jobs/fooresponse:b'{"response":{"code":"NOT_FOUND_ERROR","errors":[{"key":"not.found","message":"Translation job is not found","details":null}]}}'

Note that the error is printed to the standard output. This is unexpected because in the app I'm integrating Smartling into, I would check for status and then log resp.errors or raise an exception. That print would be a redundant noise injected into the app normal output (logs and warnings, primarily).

I think you should consider either removing those prints (if those are accidental debug prints) or replacing them with (debug-level?) logging (which I know you're already configured and use in other places)—depending on each case, I believe.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions