Skip to content

Commit 55f7071

Browse files
author
Wasin Waeosri
committed
Merge branch 'v14_python2'
1.Update code style to close Python3 2. Fix outdated TRKD REST endpoints
2 parents e1d0f9b + 0f0f215 commit 55f7071

File tree

8 files changed

+16
-26
lines changed

8 files changed

+16
-26
lines changed

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The following softwares are required to use this script
2121
- Python 2.7
2222
- The [requests](http://docs.python-requests.org/en/master/) library
2323

24-
The scripts are based on Python 2 but you can modify it to run with Python 3 (see "Optional - How to run with Python 3" section).
24+
The scripts support Python 2 only, not Python 3.
2525

2626
## How to run the script
2727
Run the script via the command line (or shell)
@@ -41,16 +41,6 @@ The best way is via the pip package management tool
4141
export https_proxy="http://<proxy.server>:<port>"
4242
$>pip install requests
4343
```
44-
## Optional - How to run with Python 3
45-
You can modify the scripts to run with Python 3 (with requests library installed) by just change the code from "**raw_input()**" to "**input()**" as the following example
46-
- Python 2
47-
```
48-
username = raw_input('Please input username: ')
49-
```
50-
- Python 3
51-
```
52-
username = input('Please input username: ')
53-
```
5444

5545
## Release Note
5646
- Version 1: 6 Sep 2016

trkd_chart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def doSendRequest(url, requestMsg, headers):
2828
if result.status_code == 500: ## if username or password or appid is wrong
2929
print('Error: %s'%(result.json()))
3030
result.raise_for_status()
31-
except requests.exceptions.RequestException, e:
31+
except requests.exceptions.RequestException as e:
3232
print('Exception!!!')
3333
print(e)
3434
sys.exit(1)
@@ -274,7 +274,7 @@ def RetrieveChart(token, appid):
274274
'ReturnPrivateNetworkURL': False,
275275
}}}
276276
##construct Chart URL and header
277-
chartURL = 'http://api.rkd.reuters.com/api/Charts/Charts.svc/REST/Charts_1/GetChart_2BB'
277+
chartURL = 'http://api.trkd.thomsonreuters.com/api/Charts/Charts.svc/REST/Charts_1/GetChart_2'
278278
headers = {'content-type': 'application/json;charset=utf-8' ,'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token' : token}
279279

280280
print('############### Sending Chart request message to TRKD ###############')

trkd_interday.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def doSendRequest(url, requestMsg, headers):
2727
if result.status_code == 500: ## if username or password or appid is wrong
2828
print('Error: %s'%(result.json()))
2929
result.raise_for_status()
30-
except requests.exceptions.RequestException, e:
30+
except requests.exceptions.RequestException as e:
3131
print('Exception!!!')
3232
print(e)
3333
sys.exit(1)
@@ -74,7 +74,7 @@ def RetrieveInteraday(token, appid):
7474
}
7575
}
7676
##construct Time Series Interday URL and header
77-
interdayURL = 'http://api.rkd.reuters.com/api/TimeSeries/TimeSeries.svc/REST/TimeSeries_1/GetInterdayTimeSeries_4'
77+
interdayURL = 'http://api.trkd.thomsonreuters.com/api/TimeSeries/TimeSeries.svc/REST/TimeSeries_1/GetInterdayTimeSeries_4'
7878
headers = {'content-type': 'application/json;charset=utf-8' ,'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token' : token}
7979

8080
print('############### Sending Time Series Interday request message to TRKD ###############')

trkd_intraday.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def doSendRequest(url, requestMsg, headers):
2727
if result.status_code == 500: ## if username or password or appid is wrong
2828
print('Error: %s'%(result.json()))
2929
result.raise_for_status()
30-
except requests.exceptions.RequestException, e:
30+
except requests.exceptions.RequestException as e:
3131
print('Exception!!!')
3232
print(e)
3333
sys.exit(1)
@@ -74,7 +74,7 @@ def RetrieveIntraday(token, appid):
7474
}
7575
}
7676
##construct Time Series Intraday URL and header
77-
intradayURL = 'http://api.rkd.reuters.com/api/TimeSeries/TimeSeries.svc/REST/TimeSeries_1/GetIntradayTimeSeries_4'
77+
intradayURL = 'http://api.trkd.thomsonreuters.com/api/TimeSeries/TimeSeries.svc/REST/TimeSeries_1/GetIntradayTimeSeries_4'
7878
headers = {'content-type': 'application/json;charset=utf-8' ,'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token' : token}
7979

8080
print('############### Sending Time Series Intraday request message to TRKD ###############')

trkd_newsheadline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def doSendRequest(url, requestMsg, headers):
2626
if result.status_code == 500: ## if username or password or appid is wrong
2727
print('Error: %s'%(result.json()))
2828
result.raise_for_status()
29-
except requests.exceptions.RequestException, e:
29+
except requests.exceptions.RequestException as e:
3030
print('Exception!!!')
3131
print(e)
3232
sys.exit(1)
@@ -40,7 +40,7 @@ def CreateAuthorization(username, password, appid):
4040
authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}
4141
authenURL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1'
4242
headers = {'content-type': 'application/json;charset=utf-8'}
43-
print '############### Sending Authentication request message to TRKD ###############'
43+
print('############### Sending Authentication request message to TRKD ###############')
4444
authenResult = doSendRequest(authenURL, authenMsg, headers)
4545
if authenResult is not None and authenResult.status_code == 200:
4646
print('Authen success')

trkd_newsstory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def doSendRequest(url, requestMsg, headers):
2727
if result.status_code == 500: # if username or password or appid is wrong
2828
print('Error: %s' % (result.json()))
2929
result.raise_for_status()
30-
except requests.exceptions.RequestException, e:
30+
except requests.exceptions.RequestException as e:
3131
print('Exception!!!')
3232
print(e)
3333
sys.exit(1)
@@ -42,7 +42,7 @@ def CreateAuthorization(username, password, appid):
4242
'ApplicationID': appid, 'Username': username, 'Password': password}}
4343
authenURL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1'
4444
headers = {'content-type': 'application/json;charset=utf-8'}
45-
print '############### Sending Authentication request message to TRKD ###############'
45+
print('############### Sending Authentication request message to TRKD ###############')
4646
authenResult = doSendRequest(authenURL, authenMsg, headers)
4747
if authenResult is not None and authenResult.status_code == 200:
4848
print('Authen success')
@@ -55,7 +55,7 @@ def CreateAuthorization(username, password, appid):
5555
# Perform News Story request
5656
def RetrieveNewsStory(token, appid):
5757
# construct news story URL and header
58-
newsURL = 'http://api.rkd.reuters.com/api/News/News.svc/REST/News_1/RetrieveStoryML_1'
58+
newsURL = 'http://api.trkd.thomsonreuters.com/api/News/News.svc/REST/News_1/RetrieveStoryML_1'
5959
headers = {'content-type': 'application/json;charset=utf-8',
6060
'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token': token}
6161
# construct a news story request message

trkd_onlinereport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def doSendRequest(url, requestMsg, headers):
2727
if result.status_code == 500: # if username or password or appid is wrong
2828
print('Error: %s' % (result.json()))
2929
result.raise_for_status()
30-
except requests.exceptions.RequestException, e:
30+
except requests.exceptions.RequestException as e:
3131
print('Exception!!!')
3232
print(e)
3333
sys.exit(1)
@@ -57,7 +57,7 @@ def CreateAuthorization(username, password, appid):
5757

5858
def RetrieveOnlineReport(token, appid):
5959
# construct Online Report URL and header
60-
onlinereportURL = 'http://api.rkd.reuters.com/api/OnlineReports/OnlineReports.svc/REST/OnlineReports_1/GetSummaryByTopic_1'
60+
onlinereportURL = 'http://api.trkd.thomsonreuters.com/api/OnlineReports/OnlineReports.svc/REST/OnlineReports_1/GetSummaryByTopic_1'
6161
headers = {'content-type': 'application/json;charset=utf-8',
6262
'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token': token}
6363
# construct a Online Report request message
@@ -86,7 +86,7 @@ def RetrieveOnlineReport(token, appid):
8686
appid = raw_input('Please input appid: ')
8787

8888
token = CreateAuthorization(username, password, appid)
89-
print 'Token = %s' % (token)
89+
print('Token = %s' % (token))
9090

9191
# if authentiacation success, continue subscribing Online Report
9292
if token is not None:

trkd_quote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def doSendRequest(url, requestMsg, headers):
3232
#print('response status %s' % result.status_code)
3333
#print('Error: %s' % result.json())
3434
#sys.exit(1)
35-
except requests.exceptions.RequestException, e:
35+
except requests.exceptions.RequestException as e:
3636
print('Exception!!!')
3737
print(e)
3838
sys.exit(1)

0 commit comments

Comments
 (0)