Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ebay.yaml
timebay.yaml
build/
dist/
Expand All @@ -12,3 +13,4 @@ ebaysdk.egg-info/
\.tox
venv/
venv*
\.virtualenvs
27 changes: 27 additions & 0 deletions ebay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ebay_api_config

# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
compatability: 719
appid: ENTER_YOUR_APPID_HERE
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
compatability: 719
appid: ENTER_YOUR_APPID_HERE
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Finding API - https://www.x.com/developers/ebay/products/finding-api
svcs.ebay.com:
appid: ENTER_YOUR_APPID_HERE
version: 1.0.0

# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
open.api.ebay.com:
appid: ENTER_YOUR_APPID_HERE
version: 671
4 changes: 2 additions & 2 deletions ebaysdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import platform
import logging

__version__ = '2.1.4'
Version = __version__ # for backware compatibility
__version__ = '2.1.5'
Version = __version__ # for backward compatibility

try:
from logging import NullHandler
Expand Down
2 changes: 0 additions & 2 deletions ebaysdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Config(object):
"""Config Class for all APIs connections

>>> c = Config(domain='api.ebay.com')
>>> print(c.file())
ebay.yaml
>>> c.set('fname', 'tim')
>>> c.get('fname')
'tim'
Expand Down
6 changes: 3 additions & 3 deletions ebaysdk/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Licensed under CDDL 1.0
'''
import sys
from ebaysdk.exception import ConnectionError
import grequests

if sys.version_info[0] >= 3:
raise ImportError('grequests does not work with python3+')

import grequests
from ebaysdk.exception import ConnectionError


class Parallel(object):
"""
Expand Down
8 changes: 5 additions & 3 deletions ebaysdk/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ def get(self, name, default=None):

def _setattr(self, name, value, datetime_nodes):
if name.lower() in datetime_nodes:
assert value.endswith('Z')
try:
ts = "%s %s" % (value.partition(
'T')[0], value.partition('T')[2].partition('.')[0])
value = datetime.datetime.strptime(ts, '%Y-%m-%d %H:%M:%S')
value = datetime.datetime.strptime(
value.replace('Z', 'UTC'),
'%Y-%m-%dT%H:%M:%S.%f%Z'
).replace(tzinfo=datetime.timezone.utc)
Comment on lines +50 to +53
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value = datetime.datetime.strptime(
value.replace('Z', 'UTC'),
'%Y-%m-%dT%H:%M:%S.%f%Z'
).replace(tzinfo=datetime.timezone.utc)
ts = value.replace('Z', '+0000')
value = datetime.datetime.strptime(ts, '%Y-%m-%dT%H:%M:%S.%f%z')

except ValueError:
pass

Expand Down
2 changes: 1 addition & 1 deletion ebaysdk/shopping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, **kwargs):
uri -- API endpoint uri (default: /shopping)
appid -- eBay application id
siteid -- eBay country site id (default: 0 (US))
compatibility -- version number (default: 799)
version -- version number (default: 799)
https -- execute of https (default: True)
proxy_host -- proxy hostname
proxy_port -- proxy port number
Expand Down
18 changes: 0 additions & 18 deletions ebaysdk/soa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ def load_from_app_config(self, app_config):
def response_dict(self):
return self.response.dict()

'''
if self._response_dict:
return self._response_dict

if self._response_content:

mydict = self.response.dict()

try:
verb = self.verb + 'Response'
self._response_dict = mydict['Envelope']['Body'][verb]

except KeyError:
self._response_dict = mydict.get(self.verb + 'Response', mydict)

return self._response_dict
'''

def build_request_headers(self, verb):
return {
'Content-Type': self.config.get('content_type'),
Expand Down
4 changes: 2 additions & 2 deletions ebaysdk/trading/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def build_request_headers(self, verb):
"X-EBAY-API-DEV-NAME": self.config.get('devid', ''),
"X-EBAY-API-APP-NAME": self.config.get('appid', ''),
"X-EBAY-API-CERT-NAME": self.config.get('certid', ''),
"X-EBAY-API-SITEID": self.config.get('siteid', ''),
"X-EBAY-API-SITEID": str(self.config.get('siteid', '')),
"X-EBAY-API-CALL-NAME": self.verb,
"Content-Type": "text/xml"
}
Expand Down Expand Up @@ -785,7 +785,7 @@ def _get_resp_body_errors(self):
.format(eClass=eClass, severity=eSeverity, code=eCode, shortMsg=eShortMsg,
longMsg=eLongMsg)

#from IPython import embed; embed()
# from IPython import embed; embed()

if eSeverity == 'Warning':
warnings.append(msg)
Expand Down
19 changes: 19 additions & 0 deletions samples/trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ def verifyAddItemErrorCodes(opts):
}
}

motors_item = {
'Item': {
'Category': '101',
'Title': 'My Title',
'ItemCompatibilityList': {
'Compatibility': [
{
'CompatibilityNotes': 'Fits for all trims and engines.',
'NameValueList': [
{'Name': 'Year', 'Value': '2001'},
{'Name': 'Make', 'Value': 'Honda'},
{'Name': 'Model', 'Value': 'Accord'}
]
},
]
}
}
}

api.execute('VerifyAddItem', myitem)

except ConnectionError as e:
Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@

PKG = 'ebaysdk'

# Get the version
VERSIONFILE = os.path.join(PKG, "__init__.py")
version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
open(VERSIONFILE, "rt").read(), re.M).group(1)

version = __import__(PKG).get_version()

long_desc = """This SDK is a programatic inteface into the eBay
APIs. It simplifies development and cuts development time by standerizing
Expand Down
57 changes: 0 additions & 57 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
# -*- coding: utf-8 -*-

'''
© 2012-2013 eBay Software Foundation
Authored by: Tim Keefer
Licensed under CDDL 1.0
'''

import sys
import unittest
import doctest
import ebaysdk.utils
import ebaysdk.config
import ebaysdk.response
import ebaysdk.connection
import ebaysdk.http
import ebaysdk.shopping
import ebaysdk.trading
import ebaysdk.merchandising
import ebaysdk.soa.finditem
import ebaysdk.finding
import ebaysdk.poller.orders
import ebaysdk.inventorymanagement

# does not pass with python3.3
try:
import ebaysdk.parallel
except ImportError:
pass


def getTestSuite():
suite = unittest.TestSuite()

suite.addTest(doctest.DocTestSuite(ebaysdk.poller.orders))
suite.addTest(doctest.DocTestSuite(ebaysdk.utils))
suite.addTest(doctest.DocTestSuite(ebaysdk.config))
suite.addTest(doctest.DocTestSuite(ebaysdk.response))
suite.addTest(doctest.DocTestSuite(ebaysdk.connection))
# suite.addTest(doctest.DocTestSuite(ebaysdk.http))
suite.addTest(doctest.DocTestSuite(ebaysdk.shopping))
suite.addTest(doctest.DocTestSuite(ebaysdk.trading))
suite.addTest(doctest.DocTestSuite(ebaysdk.merchandising))
suite.addTest(doctest.DocTestSuite(ebaysdk.finding))
suite.addTest(doctest.DocTestSuite(ebaysdk.inventorymanagement))

if not sys.version_info[0] >= 3 \
and sys.modules.has_key('grequests') is True:
# suite.addTest(doctest.DocTestSuite(ebaysdk.parallel))
pass

# inside only
# suite.addTest(doctest.DocTestSuite(ebaysdk.soa.finditem))

return suite

runner = unittest.TextTestRunner()
runner.run(getTestSuite())
85 changes: 85 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-

'''
© 2012-2013 eBay Software Foundation
Authored by: Tim Keefer
Licensed under CDDL 1.0
'''

from __future__ import absolute_import
import os
import sys
import unittest
import doctest
import ebaysdk.utils
import ebaysdk.config
import ebaysdk.response
import ebaysdk.connection
import ebaysdk.http
import ebaysdk.shopping
import ebaysdk.trading
import ebaysdk.merchandising
import ebaysdk.soa.finditem
import ebaysdk.finding
import ebaysdk.poller.orders
import ebaysdk.inventorymanagement

# does not pass with python3.3
try:
import ebaysdk.parallel
except ImportError:
pass

# os.environ.setdefault("EBAY_YAML", "ebay.yaml")


class TestBase(unittest.TestCase):

def doctest(self, module):
doctest.testmod(module, raise_on_error=True, verbose=False)

def test_run_doctest_poller(self):
self.doctest(ebaysdk.poller.orders)

def test_run_doctest_utils(self):
self.doctest(ebaysdk.utils)

def test_run_doctest_config(self):
self.doctest(ebaysdk.config)

def test_run_doctest_response(self):
self.doctest(ebaysdk.response)

def test_run_doctest_connection(self):
self.doctest(ebaysdk.connection)

def test_run_doctest_shopping(self):
s = ebaysdk.shopping.Connection(config_file=os.environ.get('EBAY_YAML'))
resp = s.execute('GetCategoryInfo',
{'CategoryID': '-1',
'IncludeSelector': ['ChildCategories']})
self.assertEqual(s.response.reply.Ack, 'Success')
self.assertEqual(s.error(), None)
#self.doctest(ebaysdk.shopping)

def test_run_doctest_trading(self):
self.doctest(ebaysdk.trading)

def test_run_doctest_merchandising(self):
self.doctest(ebaysdk.merchandising)

def test_run_doctest_finding(self):
self.doctest(ebaysdk.finding)

def test_run_doctest_inventorymanagement(self):
self.doctest(ebaysdk.inventorymanagement)

def test_grequests(self):
if not sys.version_info[0] >= 3 \
and sys.modules.has_key('grequests') is True:

# self.doctest(ebaysdk.parallel)
pass

if __name__ == '__main__':
unittest.main()
72 changes: 72 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-

'''
© 2012-2013 eBay Software Foundation
Authored by: Tim Keefer
Licensed under CDDL 1.0
'''

from __future__ import absolute_import
import os
import unittest
import ebaysdk.shopping
import lxml

os.environ.setdefault("EBAY_YAML", "ebay.yaml")

class TestErrors(unittest.TestCase):

def DISABLE_test_single_item(self):
connection = ebaysdk.shopping.Connection(version='799', config_file=os.environ.get('EBAY_YAML'))

for i in range(20):
connection.execute('GetSingleItem', {
'ItemID': '262809803926',
'version': '981',
'IncludeSelector': ['Variations']
})
self.assertEqual(connection.response.status_code, 200)
self.assertEqual(type(connection.response.dom()), lxml.etree._Element)

if __name__ == '__main__':
unittest.main()

"""
<?xml version='1.0' encoding='utf-8'?><GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"><IncludeSelector>Variations</I
ncludeSelector><ItemID>262809803926</ItemID><version>981</version></GetSingleItemRequest>
2017-02-28 06:18:42,156 ebaysdk [DEBUG]:total time=0.478377819061
2017-02-28 06:18:42,156 ebaysdk [DEBUG]:execute: verb=GetSingleItem data={'ItemID': '262809803926', 'version': 981, 'IncludeSelector': 'Variations'}
2017-02-28 06:18:42,157 ebaysdk [DEBUG]:REQUEST (3ff5f071-04c3-40c0-a4f0-57f04a9e9972): POST http://open.api.ebay.com/shopping
2017-02-28 06:18:42,157 ebaysdk [DEBUG]:headers={'Content-Length': '219', 'X-EBAY-API-REQUEST-ENCODING': 'XML', 'X-EBAY-API-VERSION': '799', 'User-Agent': 'eBaySDK/2.1.4 Pytho
n/2.7.6 Linux/3.13.0-91-generic', 'X-EBAY-SDK-REQUEST-ID': '3ff5f071-04c3-40c0-a4f0-57f04a9e9972', 'X-EBAY-API-SITE-ID': '0', 'X-EBAY-API-CALL-NAME': 'GetSingleItem', 'Content
-Type': 'text/xml', 'X-EBAY-API-APP-ID': 'LogoGrab-logograb-PRD-42f530923-a70f22b2'}
2017-02-28 06:18:42,157 ebaysdk [DEBUG]:body=<?xml version='1.0' encoding='utf-8'?><GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"><IncludeSelector>Variations</I
ncludeSelector><ItemID>262809803926</ItemID><version>981</version></GetSingleItemRequest>
2017-02-28 06:18:42,511 ebaysdk [DEBUG]:RESPONSE (3ff5f071-04c3-40c0-a4f0-57f04a9e9972):
2017-02-28 06:18:42,511 ebaysdk [DEBUG]:elapsed time=0:00:00.354254
2017-02-28 06:18:42,511 ebaysdk [DEBUG]:status code=500
2017-02-28 06:18:42,511 ebaysdk [DEBUG]:headers={'breadcrumbid': 'ID-slc4b03c-6483-stratus-slc-ebay-com-53764-1487075486325-0-1105919761', 'content-length': '25', 'accept-enco
ding': 'identity', 'x-ebay-api-request-encoding': 'XML', 'x-ebay-api-version': '799', 'user-agent': 'eBaySDK/2.1.4 Python/2.7.6 Linux/3.13.0-91-generic', 'connection': 'keep-a
live', 'x-ebay-sdk-request-id': '3ff5f071-04c3-40c0-a4f0-57f04a9e9972', 'x-ebay-api-site-id': '0', 'x-ebay-api-call-name': 'GetSingleItem', 'content-type': 'text/plain;charset
=utf-8', 'x-forwarded-for': '52.19.146.95', 'x-ebay-api-app-id': 'LogoGrab-logograb-PRD-42f530923-a70f22b2'}
2017-02-28 06:18:42,511 ebaysdk [DEBUG]:content=an internal error occured
2017-02-28 06:18:42,512 ebaysdk [DEBUG]:response parse failed: Start tag expected, '<' not found, line 1, column 1
ERROR - 2017-02-28 06:18:42,512 - utils.firehose_util - MainProcess - MainThread: Shopping Call error: {"ItemID": "262809803926", "version": 981, "IncludeSelector": "Variation
s"}
Traceback (most recent call last):
File "/home/ubuntu/logograb2-detection-server/utils/firehose_util.py", line 235, in make_ebay_request
r = Shopping(appid=app_id, config_file=None, debug=True).execute('GetSingleItem', api_pars)
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/connection.py", line 124, in execute
self.error_check()
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/connection.py", line 209, in error_check
estr = self.error()
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/connection.py", line 321, in error
error_array.extend(self._get_resp_body_errors())
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/shopping/__init__.py", line 188, in _get_resp_body_errors
dom = self.response.dom()
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/response.py", line 233, in dom
return self._dom
File "/usr/local/lib/python2.7/dist-packages/ebaysdk/response.py", line 220, in __getattr__
return getattr(self._obj, name)
AttributeError: 'Response' object has no attribute '_dom'
"""
Loading