Skip to content
Merged
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
5 changes: 3 additions & 2 deletions ebaysdk/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import sys
from ebaysdk.exception import ConnectionError

# pylint: disable=import-error

if sys.version_info[0] >= 3:
raise ImportError('grequests does not work with python3+')
import grequests
# pylint: enable=import-error


class Parallel(object):
Expand Down
10 changes: 6 additions & 4 deletions samples/calls_with_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ def init_options():
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")

parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
(opts, args) = parser.parse_args()
return opts, args


def run(opts):

try:
api = finding(debug=opts.debug, appid=opts.appid,
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
config_file=opts.yaml, warnings=True)

api_request = {
Expand All @@ -65,7 +67,7 @@ def run(opts):
def run_unicode(opts):

try:
api = finding(debug=opts.debug, appid=opts.appid,
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
config_file=opts.yaml, warnings=True)

api_request = {
Expand All @@ -83,7 +85,7 @@ def run_unicode(opts):
except ConnectionError as e:
print(e)
print(e.response.dict())

if __name__ == "__main__":
print("Unicode samples for SDK version %s" % ebaysdk.get_version())
(opts, args) = init_options()
Expand Down
5 changes: 4 additions & 1 deletion samples/finditem.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def init_options():
parser.add_option("-c", "--consumer_id",
dest="consumer_id", default=None,
help="Specifies the eBay consumer_id id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args
Expand All @@ -45,7 +48,7 @@ def run(opts):

try:

shopping = Shopping(debug=opts.debug, appid=opts.appid,
shopping = Shopping(debug=opts.debug, appid=opts.appid, domain=opts.domain,
config_file=opts.yaml, warnings=False)

response = shopping.execute('FindPopularItems',
Expand Down
5 changes: 4 additions & 1 deletion samples/merchandising.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ def init_options():
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args


def run(opts):
try:
api = merchandising(debug=opts.debug, appid=opts.appid,
api = merchandising(debug=opts.debug, appid=opts.appid, domain=opts.domain,
config_file=opts.yaml, warnings=True)

response = api.execute('getMostWatchedItems', {'maxResults': 4})
Expand Down
10 changes: 6 additions & 4 deletions samples/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def init_options():
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")

parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
(opts, args) = parser.parse_args()
return opts, args

Expand All @@ -42,7 +44,7 @@ def run(opts):
p = Parallel()
apis = []

api1 = finding(parallel=p, debug=opts.debug,
api1 = finding(parallel=p, debug=opts.debug, domain=opts.domain,
appid=opts.appid, config_file=opts.yaml)
api1.execute('findItemsAdvanced', {'keywords': 'python'})
apis.append(api1)
Expand All @@ -51,12 +53,12 @@ def run(opts):
api4.execute('http://www.ebay.com/sch/i.html?_nkw=Shirt&_rss=1')
apis.append(api4)

api2 = finding(parallel=p, debug=opts.debug,
api2 = finding(parallel=p, debug=opts.debug, domain=opts.domain,
appid=opts.appid, config_file=opts.yaml)
api2.execute('findItemsAdvanced', {'keywords': 'perl'})
apis.append(api2)

api3 = finding(parallel=p, debug=opts.debug,
api3 = finding(parallel=p, debug=opts.debug, domain=opts.domain,
appid=opts.appid, config_file=opts.yaml)
api3.execute('findItemsAdvanced', {'keywords': 'php'})
apis.append(api3)
Expand Down
5 changes: 4 additions & 1 deletion samples/parallel_gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def init_options():
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args
Expand All @@ -46,7 +49,7 @@ def run(opts):
calls = []

for page in range(1, 10):
api = finding(debug=opts.debug, appid=opts.appid,
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
config_file=opts.yaml)
call = gevent.spawn(api.execute,
'findItemsAdvanced',
Expand Down
7 changes: 5 additions & 2 deletions samples/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ def init_options():
parser.add_option("-c", "--certid",
dest="certid", default=None,
help="Specifies the eBay cert id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args


def getSellerProfiles(opts):
try:
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid)

api.execute('getSellerProfiles')
Expand All @@ -59,7 +62,7 @@ def getSellerProfiles(opts):

def getConsolidationJobStatus(opts):
try:
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid)

api.execute('getConsolidationJobStatus')
Expand Down
11 changes: 6 additions & 5 deletions samples/shopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ def init_options():
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args


def run(opts):
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
warnings=True)

print("Shopping samples for SDK version %s" % ebaysdk.get_version())
Expand All @@ -63,7 +66,7 @@ def run(opts):

def popularSearches(opts):

api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
warnings=True)

choice = True
Expand Down Expand Up @@ -93,15 +96,13 @@ def popularSearches(opts):
'QueryKeywords': term, 'MaxEntries': 3})

print("Term: %s" % term)

try:
for item in response.reply.ItemArray.Item:
print(item.Title)
except AttributeError:
pass

dump(api)

print("\n")

except ConnectionError as e:
Expand All @@ -112,7 +113,7 @@ def popularSearches(opts):
def categoryInfo(opts):

try:
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
warnings=True)

response = api.execute('GetCategoryInfo', {"CategoryID": 3410})
Expand Down
6 changes: 4 additions & 2 deletions samples/storeMeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def init_options():
parser.add_option("-e", "--line_end",
dest="line_end", default=None,
help="Input file lines.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args
Expand Down Expand Up @@ -129,7 +132,7 @@ def get_store_meta(store_name):

try:
api = finding(debug=opts.debug, appid=opts.appid,
config_file=opts.yaml)
config_file=opts.yaml, domain=opts.domain)

response = api.execute('findItemsIneBayStores', {
'storeName': store_name,
Expand Down Expand Up @@ -278,5 +281,4 @@ def analyze_items(items, category_id, agg_data):
if __name__ == "__main__":
print("Finding samples for SDK version %s" % ebaysdk.get_version())
(opts, args) = init_options()

run(opts)
27 changes: 15 additions & 12 deletions samples/trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def init_options():
parser.add_option("-c", "--certid",
dest="certid", default=None,
help="Specifies the eBay cert id to use.")
parser.add_option("-n", "--domain",
dest="domain", default='svcs.ebay.com',
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")

(opts, args) = parser.parse_args()
return opts, args
Expand All @@ -47,7 +50,7 @@ def init_options():
def run(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid)

api.execute('GetCharities', {'CharityID': 3897})
Expand All @@ -61,7 +64,7 @@ def run(opts):

def feedback(opts):
try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=False)

api.execute('GetFeedback', {'UserID': 'tim0th3us'})
Expand All @@ -80,7 +83,7 @@ def feedback(opts):
def getTokenStatus(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=False)

api.execute('GetTokenStatus')
Expand All @@ -96,7 +99,7 @@ def verifyAddItem(opts):
"""

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=False)

myitem = {
Expand Down Expand Up @@ -167,7 +170,7 @@ def verifyAddItemErrorCodes(opts):
"""

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=False)

myitem = {
Expand Down Expand Up @@ -244,7 +247,7 @@ def verifyAddItemErrorCodes(opts):
def uploadPicture(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True)

pictureData = {
Expand All @@ -264,7 +267,7 @@ def uploadPicture(opts):
def uploadPictureFromFilesystem(opts, filepath):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True)

# pass in an open file
Expand All @@ -287,7 +290,7 @@ def uploadPictureFromFilesystem(opts, filepath):
def memberMessages(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True)

now = datetime.datetime.now()
Expand Down Expand Up @@ -325,7 +328,7 @@ def memberMessages(opts):
def getUser(opts):
try:

api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid='101')

api.execute('GetUser', {'UserID': 'sallyma789'})
Expand All @@ -339,7 +342,7 @@ def getUser(opts):
def getOrders(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20)

api.execute('GetOrders', {'NumberOfDays': 30})
Expand All @@ -353,7 +356,7 @@ def getOrders(opts):
def categories(opts):

try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid='0')

callData = {
Expand Down Expand Up @@ -392,6 +395,6 @@ def categories(opts):
uploadPictureFromFilesystem(opts, ("%s/test_image.jpg" % os.path.dirname(__file__)))
memberMessages(opts)
categories(opts)

# getUser(opts)
# getOrders(opts)