|
64 | 64 | }, |
65 | 65 | { |
66 | 66 | "cell_type": "code", |
67 | | - "execution_count": 11, |
| 67 | + "execution_count": 2, |
68 | 68 | "id": "51fad442", |
69 | 69 | "metadata": {}, |
70 | 70 | "outputs": [], |
|
83 | 83 | }, |
84 | 84 | { |
85 | 85 | "cell_type": "code", |
86 | | - "execution_count": 8, |
| 86 | + "execution_count": null, |
87 | 87 | "id": "62485c4a", |
88 | 88 | "metadata": {}, |
89 | 89 | "outputs": [], |
|
108 | 108 | }, |
109 | 109 | { |
110 | 110 | "cell_type": "code", |
111 | | - "execution_count": 9, |
| 111 | + "execution_count": null, |
112 | 112 | "id": "76a9f215", |
113 | 113 | "metadata": {}, |
114 | | - "outputs": [ |
115 | | - { |
116 | | - "ename": "AttributeError", |
117 | | - "evalue": "Please provide 'grant' attribute or set 'username' and 'password' in config.", |
118 | | - "output_type": "error", |
119 | | - "traceback": [ |
120 | | - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
121 | | - "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", |
122 | | - "\u001b[1;32m<ipython-input-9-ee4ef0316817>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m session = rd.session.platform.Definition(\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mapp_key\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mAPP_KEY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mdeployed_platform_host\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mDEPLOYED_PLATFORM_HOST\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mdeployed_platform_username\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mDEPLOYED_PLATFORM_USER_NAME\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m ).get_session()\n", |
123 | | - "\u001b[1;32m~\\Anaconda3\\envs\\dev6\\lib\\site-packages\\refinitiv\\data\\_data\\core\\session\\_platform_session_definition.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, session_name, app_key, grant, signon_control, deployed_platform_host, deployed_platform_username, dacs_position, dacs_application_id)\u001b[0m\n\u001b[0;32m 93\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mgrant\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_valid\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 95\u001b[1;33m raise AttributeError(\n\u001b[0m\u001b[0;32m 96\u001b[0m \u001b[1;34m\"Please provide 'grant' attribute or set 'username' and 'password' in config.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m )\n", |
124 | | - "\u001b[1;31mAttributeError\u001b[0m: Please provide 'grant' attribute or set 'username' and 'password' in config." |
125 | | - ] |
126 | | - } |
127 | | - ], |
| 114 | + "outputs": [], |
128 | 115 | "source": [ |
129 | 116 | "session = rd.session.platform.Definition(\n", |
130 | 117 | " app_key = APP_KEY, \n", |
|
153 | 140 | "outputs": [], |
154 | 141 | "source": [ |
155 | 142 | "session = rd.session.platform.Definition(\n", |
156 | | - " APP_KEY, \n", |
| 143 | + " app_key = APP_KEY, \n", |
157 | 144 | " grant = rd.session.platform.GrantPassword(\n", |
158 | 145 | " username = RDP_LOGIN, \n", |
159 | 146 | " password = RDP_PASSWORD\n", |
|
173 | 160 | }, |
174 | 161 | { |
175 | 162 | "cell_type": "code", |
176 | | - "execution_count": null, |
| 163 | + "execution_count": 3, |
177 | 164 | "id": "5eb4432c", |
178 | 165 | "metadata": {}, |
179 | | - "outputs": [], |
| 166 | + "outputs": [ |
| 167 | + { |
| 168 | + "name": "stdout", |
| 169 | + "output_type": "stream", |
| 170 | + "text": [ |
| 171 | + "[2021-09-03 10:53:56,954] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
| 172 | + "Checking port 9000 response : 200 - {\"statusCode\":\"ST_PROXY_READY\",\"version\":\"2.9.0\"}\n", |
| 173 | + "[2021-09-03 10:53:56,957] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
| 174 | + "Port 9000 was retrieved from .portInUse file\n", |
| 175 | + "[2021-09-03 10:53:56,959] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
| 176 | + "Try to handshake on url http://localhost:9000/api/handshake...\n", |
| 177 | + "[2021-09-03 10:53:59,176] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
| 178 | + "Response : 200 - {\"access_token\":\"***REMOVED***.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjBmN2EyZDEzYmYyNzQ3ODk4N2QxYzc1ZjJjNWZkOGZjNDY5MGY3ZTEiLCJBcHBTY29wZSI6InRyYXBpIiwiTGlicmFyeU5hbWUiOiJSRFAgUHl0aG9uIExpYnJhcnkiLCJMaWJyYXJ5VmVyc2lvbiI6IjEuMC4wYTEuZGV2OSIsImlhdCI6MTYzMDY2MjgzOSwiZXhwIjoxNjMxODcyNDM5fQ.pHZg8YbWbKlK-zkgAG3CGMIbbT1AavmwWi5saL10zeI\",\"expires_in\":1209600,\"token_type\":\"bearer\"}\n", |
| 179 | + "[2021-09-03 10:53:59,177] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
| 180 | + "Application ID: 0f7a2d13bf27478987d1c75f2c5fd8fc4690f7e1\n" |
| 181 | + ] |
| 182 | + }, |
| 183 | + { |
| 184 | + "data": { |
| 185 | + "text/plain": [ |
| 186 | + "<SessionState.Open: 3>" |
| 187 | + ] |
| 188 | + }, |
| 189 | + "execution_count": 3, |
| 190 | + "metadata": {}, |
| 191 | + "output_type": "execute_result" |
| 192 | + } |
| 193 | + ], |
180 | 194 | "source": [ |
181 | 195 | "session.open()" |
182 | 196 | ] |
|
214 | 228 | }, |
215 | 229 | { |
216 | 230 | "cell_type": "code", |
217 | | - "execution_count": null, |
| 231 | + "execution_count": 4, |
218 | 232 | "id": "f628d577", |
219 | 233 | "metadata": {}, |
220 | | - "outputs": [], |
| 234 | + "outputs": [ |
| 235 | + { |
| 236 | + "data": { |
| 237 | + "text/plain": [ |
| 238 | + "<SessionState.Closed: 1>" |
| 239 | + ] |
| 240 | + }, |
| 241 | + "execution_count": 4, |
| 242 | + "metadata": {}, |
| 243 | + "output_type": "execute_result" |
| 244 | + } |
| 245 | + ], |
221 | 246 | "source": [ |
222 | 247 | "session.close()" |
223 | 248 | ] |
|
233 | 258 | }, |
234 | 259 | { |
235 | 260 | "cell_type": "code", |
236 | | - "execution_count": null, |
| 261 | + "execution_count": 5, |
237 | 262 | "id": "adb83bc9", |
238 | 263 | "metadata": {}, |
239 | | - "outputs": [], |
| 264 | + "outputs": [ |
| 265 | + { |
| 266 | + "name": "stdout", |
| 267 | + "output_type": "stream", |
| 268 | + "text": [ |
| 269 | + "Session State:EventCode.SessionAuthenticationSuccess | Successfully authorized to RDP authentication endpoint.\n", |
| 270 | + "Session State:SessionState.Open | Session is opened.\n" |
| 271 | + ] |
| 272 | + }, |
| 273 | + { |
| 274 | + "data": { |
| 275 | + "text/plain": [ |
| 276 | + "<SessionState.Open: 3>" |
| 277 | + ] |
| 278 | + }, |
| 279 | + "execution_count": 5, |
| 280 | + "metadata": {}, |
| 281 | + "output_type": "execute_result" |
| 282 | + } |
| 283 | + ], |
240 | 284 | "source": [ |
241 | 285 | "# Callback to handle session state changes\n", |
242 | 286 | "def on_state_cb(session, state_code, state_msg):\n", |
|
247 | 291 | "\n", |
248 | 292 | "# Using PlatformSession - can be applied to DesktopSession as well\n", |
249 | 293 | "session = rd.session.platform.Definition(\n", |
250 | | - " APP_KEY, \n", |
251 | | - " rd.session.platform.GrantPassword(\n", |
252 | | - " username = RDP_LOGIN, \n", |
| 294 | + " app_key=APP_KEY,\n", |
| 295 | + " grant=rd.session.platform.GrantPassword(\n", |
| 296 | + " username = RDP_LOGIN,\n", |
253 | 297 | " password = RDP_PASSWORD\n", |
254 | | - " ),\n", |
255 | | - " on_state=on_state_cb, on_event=on_event_cb\n", |
| 298 | + " )\n", |
256 | 299 | ").get_session()\n", |
257 | | - " \n", |
| 300 | + "\n", |
| 301 | + "# Set your callbacks for handing the session events\n", |
| 302 | + "session.on_event(on_event_cb)\n", |
| 303 | + "session.on_state(on_state_cb)\n", |
| 304 | + "\n", |
| 305 | + "# Open the Session\n", |
258 | 306 | "session.open()\n", |
259 | 307 | "\n", |
260 | 308 | "#\n", |
261 | 309 | "# Run your application code\n", |
262 | | - "#\n", |
263 | | - "\n", |
| 310 | + "#\n" |
| 311 | + ] |
| 312 | + }, |
| 313 | + { |
| 314 | + "cell_type": "code", |
| 315 | + "execution_count": 6, |
| 316 | + "id": "f2bfad89-53d1-4e22-9903-3eba81159252", |
| 317 | + "metadata": {}, |
| 318 | + "outputs": [], |
| 319 | + "source": [ |
264 | 320 | "# close the session when done\n", |
265 | 321 | "session.close()" |
266 | 322 | ] |
267 | 323 | }, |
268 | 324 | { |
269 | 325 | "cell_type": "code", |
270 | 326 | "execution_count": null, |
271 | | - "id": "52567fb6-86e6-4661-b09e-041fceef1cd2", |
| 327 | + "id": "8119442c-31d2-436c-a2ab-4200700fb248", |
272 | 328 | "metadata": {}, |
273 | 329 | "outputs": [], |
274 | 330 | "source": [] |
275 | 331 | } |
276 | 332 | ], |
277 | 333 | "metadata": { |
278 | 334 | "kernelspec": { |
279 | | - "display_name": "rddev6", |
| 335 | + "display_name": "RevData39", |
280 | 336 | "language": "python", |
281 | | - "name": "rddev6" |
| 337 | + "name": "rd39" |
282 | 338 | }, |
283 | 339 | "language_info": { |
284 | 340 | "codemirror_mode": { |
|
290 | 346 | "name": "python", |
291 | 347 | "nbconvert_exporter": "python", |
292 | 348 | "pygments_lexer": "ipython3", |
293 | | - "version": "3.8.10" |
| 349 | + "version": "3.9.4" |
294 | 350 | } |
295 | 351 | }, |
296 | 352 | "nbformat": 4, |
|
0 commit comments