Skip to content

Inappropriate use of print #57

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

Open
Toreno96 opened this issue Oct 12, 2023 · 0 comments
Open

Inappropriate use of print #57

Toreno96 opened this issue Oct 12, 2023 · 0 comments
Assignees

Comments

@Toreno96
Copy link

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')
Non 200 response:404   RequestId:Unknown   URL:https://api.smartling.com/jobs-api/v3/projects/3bea86d16/jobs/foo   response: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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants