Skip to content

Commit 16f3246

Browse files
authored
Merge pull request #279 from gainskills/master
update samples with param: 'domain'
2 parents 1dd9af4 + 5008665 commit 16f3246

File tree

10 files changed

+57
-34
lines changed

10 files changed

+57
-34
lines changed

ebaysdk/parallel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import sys
99
from ebaysdk.exception import ConnectionError
1010

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

1516

1617
class Parallel(object):

samples/calls_with_unicode.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ def init_options():
3030
parser.add_option("-a", "--appid",
3131
dest="appid", default=None,
3232
help="Specifies the eBay application id to use.")
33-
33+
parser.add_option("-n", "--domain",
34+
dest="domain", default='svcs.ebay.com',
35+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3436
(opts, args) = parser.parse_args()
3537
return opts, args
3638

3739

3840
def run(opts):
3941

4042
try:
41-
api = finding(debug=opts.debug, appid=opts.appid,
43+
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
4244
config_file=opts.yaml, warnings=True)
4345

4446
api_request = {
@@ -65,7 +67,7 @@ def run(opts):
6567
def run_unicode(opts):
6668

6769
try:
68-
api = finding(debug=opts.debug, appid=opts.appid,
70+
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
6971
config_file=opts.yaml, warnings=True)
7072

7173
api_request = {
@@ -83,7 +85,7 @@ def run_unicode(opts):
8385
except ConnectionError as e:
8486
print(e)
8587
print(e.response.dict())
86-
88+
8789
if __name__ == "__main__":
8890
print("Unicode samples for SDK version %s" % ebaysdk.get_version())
8991
(opts, args) = init_options()

samples/finditem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def init_options():
3636
parser.add_option("-c", "--consumer_id",
3737
dest="consumer_id", default=None,
3838
help="Specifies the eBay consumer_id id to use.")
39+
parser.add_option("-n", "--domain",
40+
dest="domain", default='svcs.ebay.com',
41+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3942

4043
(opts, args) = parser.parse_args()
4144
return opts, args
@@ -45,7 +48,7 @@ def run(opts):
4548

4649
try:
4750

48-
shopping = Shopping(debug=opts.debug, appid=opts.appid,
51+
shopping = Shopping(debug=opts.debug, appid=opts.appid, domain=opts.domain,
4952
config_file=opts.yaml, warnings=False)
5053

5154
response = shopping.execute('FindPopularItems',

samples/merchandising.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ def init_options():
3030
parser.add_option("-a", "--appid",
3131
dest="appid", default=None,
3232
help="Specifies the eBay application id to use.")
33+
parser.add_option("-n", "--domain",
34+
dest="domain", default='svcs.ebay.com',
35+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3336

3437
(opts, args) = parser.parse_args()
3538
return opts, args
3639

3740

3841
def run(opts):
3942
try:
40-
api = merchandising(debug=opts.debug, appid=opts.appid,
43+
api = merchandising(debug=opts.debug, appid=opts.appid, domain=opts.domain,
4144
config_file=opts.yaml, warnings=True)
4245

4346
response = api.execute('getMostWatchedItems', {'maxResults': 4})

samples/parallel.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def init_options():
3131
parser.add_option("-a", "--appid",
3232
dest="appid", default=None,
3333
help="Specifies the eBay application id to use.")
34-
34+
parser.add_option("-n", "--domain",
35+
dest="domain", default='svcs.ebay.com',
36+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3537
(opts, args) = parser.parse_args()
3638
return opts, args
3739

@@ -42,7 +44,7 @@ def run(opts):
4244
p = Parallel()
4345
apis = []
4446

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

54-
api2 = finding(parallel=p, debug=opts.debug,
56+
api2 = finding(parallel=p, debug=opts.debug, domain=opts.domain,
5557
appid=opts.appid, config_file=opts.yaml)
5658
api2.execute('findItemsAdvanced', {'keywords': 'perl'})
5759
apis.append(api2)
5860

59-
api3 = finding(parallel=p, debug=opts.debug,
61+
api3 = finding(parallel=p, debug=opts.debug, domain=opts.domain,
6062
appid=opts.appid, config_file=opts.yaml)
6163
api3.execute('findItemsAdvanced', {'keywords': 'php'})
6264
apis.append(api3)

samples/parallel_gevent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def init_options():
3232
parser.add_option("-a", "--appid",
3333
dest="appid", default=None,
3434
help="Specifies the eBay application id to use.")
35+
parser.add_option("-n", "--domain",
36+
dest="domain", default='svcs.ebay.com',
37+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3538

3639
(opts, args) = parser.parse_args()
3740
return opts, args
@@ -46,7 +49,7 @@ def run(opts):
4649
calls = []
4750

4851
for page in range(1, 10):
49-
api = finding(debug=opts.debug, appid=opts.appid,
52+
api = finding(debug=opts.debug, appid=opts.appid, domain=opts.domain,
5053
config_file=opts.yaml)
5154
call = gevent.spawn(api.execute,
5255
'findItemsAdvanced',

samples/policies.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ def init_options():
3939
parser.add_option("-c", "--certid",
4040
dest="certid", default=None,
4141
help="Specifies the eBay cert id to use.")
42+
parser.add_option("-n", "--domain",
43+
dest="domain", default='svcs.ebay.com',
44+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
4245

4346
(opts, args) = parser.parse_args()
4447
return opts, args
4548

4649

4750
def getSellerProfiles(opts):
4851
try:
49-
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
52+
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
5053
certid=opts.certid, devid=opts.devid)
5154

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

6063
def getConsolidationJobStatus(opts):
6164
try:
62-
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
65+
api = Policies(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
6366
certid=opts.certid, devid=opts.devid)
6467

6568
api.execute('getConsolidationJobStatus')

samples/shopping.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ def init_options():
3636
parser.add_option("-a", "--appid",
3737
dest="appid", default=None,
3838
help="Specifies the eBay application id to use.")
39+
parser.add_option("-n", "--domain",
40+
dest="domain", default='svcs.ebay.com',
41+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
3942

4043
(opts, args) = parser.parse_args()
4144
return opts, args
4245

4346

4447
def run(opts):
45-
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
48+
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
4649
warnings=True)
4750

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

6467
def popularSearches(opts):
6568

66-
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
69+
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
6770
warnings=True)
6871

6972
choice = True
@@ -93,15 +96,13 @@ def popularSearches(opts):
9396
'QueryKeywords': term, 'MaxEntries': 3})
9497

9598
print("Term: %s" % term)
96-
9799
try:
98100
for item in response.reply.ItemArray.Item:
99101
print(item.Title)
100102
except AttributeError:
101103
pass
102104

103105
dump(api)
104-
105106
print("\n")
106107

107108
except ConnectionError as e:
@@ -112,7 +113,7 @@ def popularSearches(opts):
112113
def categoryInfo(opts):
113114

114115
try:
115-
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml,
116+
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
116117
warnings=True)
117118

118119
response = api.execute('GetCategoryInfo', {"CategoryID": 3410})

samples/storeMeta.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def init_options():
4646
parser.add_option("-e", "--line_end",
4747
dest="line_end", default=None,
4848
help="Input file lines.")
49+
parser.add_option("-n", "--domain",
50+
dest="domain", default='svcs.ebay.com',
51+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
4952

5053
(opts, args) = parser.parse_args()
5154
return opts, args
@@ -129,7 +132,7 @@ def get_store_meta(store_name):
129132

130133
try:
131134
api = finding(debug=opts.debug, appid=opts.appid,
132-
config_file=opts.yaml)
135+
config_file=opts.yaml, domain=opts.domain)
133136

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

samples/trading.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def init_options():
3939
parser.add_option("-c", "--certid",
4040
dest="certid", default=None,
4141
help="Specifies the eBay cert id to use.")
42+
parser.add_option("-n", "--domain",
43+
dest="domain", default='svcs.ebay.com',
44+
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
4245

4346
(opts, args) = parser.parse_args()
4447
return opts, args
@@ -47,7 +50,7 @@ def init_options():
4750
def run(opts):
4851

4952
try:
50-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
53+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
5154
certid=opts.certid, devid=opts.devid)
5255

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

6265
def feedback(opts):
6366
try:
64-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
67+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
6568
certid=opts.certid, devid=opts.devid, warnings=False)
6669

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

8285
try:
83-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
86+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
8487
certid=opts.certid, devid=opts.devid, warnings=False)
8588

8689
api.execute('GetTokenStatus')
@@ -96,7 +99,7 @@ def verifyAddItem(opts):
9699
"""
97100

98101
try:
99-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
102+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
100103
certid=opts.certid, devid=opts.devid, warnings=False)
101104

102105
myitem = {
@@ -167,7 +170,7 @@ def verifyAddItemErrorCodes(opts):
167170
"""
168171

169172
try:
170-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
173+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
171174
certid=opts.certid, devid=opts.devid, warnings=False)
172175

173176
myitem = {
@@ -244,7 +247,7 @@ def verifyAddItemErrorCodes(opts):
244247
def uploadPicture(opts):
245248

246249
try:
247-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
250+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
248251
certid=opts.certid, devid=opts.devid, warnings=True)
249252

250253
pictureData = {
@@ -264,7 +267,7 @@ def uploadPicture(opts):
264267
def uploadPictureFromFilesystem(opts, filepath):
265268

266269
try:
267-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
270+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
268271
certid=opts.certid, devid=opts.devid, warnings=True)
269272

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

289292
try:
290-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
293+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
291294
certid=opts.certid, devid=opts.devid, warnings=True)
292295

293296
now = datetime.datetime.now()
@@ -325,7 +328,7 @@ def memberMessages(opts):
325328
def getUser(opts):
326329
try:
327330

328-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
331+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
329332
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid='101')
330333

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

341344
try:
342-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
345+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
343346
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20)
344347

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

355358
try:
356-
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
359+
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, domain=opts.domain,
357360
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid='0')
358361

359362
callData = {
@@ -392,6 +395,6 @@ def categories(opts):
392395
uploadPictureFromFilesystem(opts, ("%s/test_image.jpg" % os.path.dirname(__file__)))
393396
memberMessages(opts)
394397
categories(opts)
395-
398+
396399
# getUser(opts)
397400
# getOrders(opts)

0 commit comments

Comments
 (0)