|
5 | 5 | you may not use this file except in compliance with the License. |
6 | 6 | You may obtain a copy of the License at |
7 | 7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | | - |
| 8 | +
|
9 | 9 | Unless required by applicable law or agreed to in writing, software |
10 | 10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 | 18 | import time |
19 | 19 |
|
20 | 20 | """ |
21 | | -This script demonstrates how to retrieve the AppSession object produced |
| 21 | +This script demonstrates how to retrieve the AppSession object produced |
22 | 22 | when a user initiates an app. Further it's demonstrated how to automatically |
23 | 23 | generate the scope strings to request access to the data object (a project or a sample) |
24 | 24 | that the app was triggered to analyze. |
|
51 | 51 |
|
52 | 52 | # Using the basespaceApi we can request the appSession object corresponding to the AppSession id supplied |
53 | 53 | myAppSession = myAPI.getAppSession() |
54 | | -print myAppSession |
| 54 | +print(myAppSession) |
55 | 55 |
|
56 | 56 | # An app session contains a referal to one or more appLaunchObjects which reference the data module |
57 | | -# the user launched the app on. This can be a list of projects, samples, or a mixture of objects |
58 | | -print "\nType of data the app was triggered on can be seen in 'references'" |
59 | | -print myAppSession.References |
| 57 | +# the user launched the app on. This can be a list of projects, samples, or a mixture of objects |
| 58 | +print("\nType of data the app was triggered on can be seen in 'references'") |
| 59 | +print(myAppSession.References) |
60 | 60 |
|
61 | 61 | # We can also get a handle to the user who started the AppSession |
62 | | -print "\nWe can get a handle for the user who triggered the app\n" + str(myAppSession.UserCreatedBy) |
| 62 | +print("\nWe can get a handle for the user who triggered the app\n" + str(myAppSession.UserCreatedBy)) |
63 | 63 |
|
64 | 64 | # Let's have a closer look at the appSessionLaunchObject |
65 | 65 | myReference = myAppSession.References[0] |
66 | | -print "\nWe can get out information such as the href to the launch object:" |
67 | | -print myReference.HrefContent |
68 | | -print "\nand the specific type of that object:" |
69 | | -print myReference.Type |
| 66 | +print("\nWe can get out information such as the href to the launch object:") |
| 67 | +print(myReference.HrefContent) |
| 68 | +print("\nand the specific type of that object:") |
| 69 | +print(myReference.Type) |
70 | 70 |
|
71 | 71 |
|
72 | 72 | # Now we will want to ask for more permission for the specific reference object |
73 | | -print "\nWe can get out the specific project objects by using 'content':" |
| 73 | +print("\nWe can get out the specific project objects by using 'content':") |
74 | 74 | myReference = myReference.Content |
75 | | -print myReference |
76 | | -print "\nThe scope string for requesting read access to the reference object is:" |
77 | | -print myReference.getAccessStr(scope='write') |
| 75 | +print(myReference) |
| 76 | +print("\nThe scope string for requesting read access to the reference object is:") |
| 77 | +print(myReference.getAccessStr(scope='write')) |
78 | 78 |
|
79 | 79 | # We can easily request write access to the reference object so our App can start contributing analysis |
80 | 80 | # by default we ask for write permission and authentication for a device |
81 | 81 | #accessMap = myAPI.getAccess(myReference,accessType='write') |
82 | 82 | # We may limit our request to read access only if that's all that is needed |
83 | 83 | #readAccessMaps = myAPI.getAccess(myReference,accessType='read') |
84 | 84 |
|
85 | | -#print "\nWe get the following access map for the write request" |
86 | | -#print accessMap |
| 85 | +#print("\nWe get the following access map for the write request") |
| 86 | +#print(accessMap) |
87 | 87 |
|
88 | 88 | ## PAUSE HERE |
89 | 89 | # Have the user visit the verification uri to grant us access |
90 | | -#print "\nPlease visit the uri within 15 seconds and grant access" |
91 | | -#print accessMap['verification_with_code_uri'] |
| 90 | +#print("\nPlease visit the uri within 15 seconds and grant access") |
| 91 | +#print(accessMap['verification_with_code_uri']) |
92 | 92 | #webbrowser.open_new(accessMap['verification_with_code_uri']) |
93 | 93 | #time.sleep(15) |
94 | 94 | ## PAUSE HERE |
95 | 95 |
|
96 | 96 | # Once the user has granted us the access to the object we requested we can |
97 | 97 | # get the basespace access token and start browsing simply by calling updatePriviliges |
98 | | -# on the baseSpaceApi instance |
| 98 | +# on the baseSpaceApi instance |
99 | 99 | #code = accessMap['device_code'] |
100 | 100 | #myAPI.updatePrivileges(code) |
101 | | -#print "\nThe BaseSpaceAPI instance was update with write privileges" |
102 | | -#print myAPI |
| 101 | +#print("\nThe BaseSpaceAPI instance was update with write privileges") |
| 102 | +#print(myAPI) |
0 commit comments