Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions SoftLayer/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
from SoftLayer import exceptions
from SoftLayer import utils

import base64

import importlib
import json
import logging
import time

import requests

import sys

LOGGER = logging.getLogger(__name__)
# transports.Request does have a lot of instance attributes. :(
# pylint: disable=too-many-instance-attributes
Expand Down Expand Up @@ -108,6 +112,15 @@ def __call__(self, request):

largs.insert(0, {'headers': headers})

# In Python 2 xmlrpc_client.dumps(...) does not
# automatically perform base64 encoding.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to tackle too many local variable restriction of landscape .. you could may be direclty compare
if sys.version_info[0] <3

not sure who/why the limit of 15 local variables is/was enforced

if sys.version_info[0] < 3:
for index, dictionary in enumerate(largs):
if 'data' in dictionary:
data = dictionary['data']
largs[index]['data'] = base64.b64encode(data)
break

url = '/'.join([request.endpoint, request.service])
payload = utils.xmlrpc_client.dumps(tuple(largs),
methodname=request.method,
Expand Down