|
14 | 14 | "outputs": [],
|
15 | 15 | "source": [
|
16 | 16 | "import dropboxdrivefs as dbx\n",
|
17 |
| - "import logging" |
| 17 | + "import logging\n", |
| 18 | + "\n", |
| 19 | + "logging.basicConfig(format=\"%(levelname)s:%(message)s\", level=logging.INFO)" |
18 | 20 | ]
|
19 | 21 | },
|
20 | 22 | {
|
21 | 23 | "cell_type": "code",
|
22 |
| - "execution_count": 14, |
| 24 | + "execution_count": 2, |
23 | 25 | "metadata": {},
|
24 | 26 | "outputs": [],
|
25 | 27 | "source": [
|
26 |
| - "fs = dbx.DropboxDriveFileSystem(token=\"****************\")" |
| 28 | + "fs = dbx.DropboxDriveFileSystem(token=\"*****************\")" |
27 | 29 | ]
|
28 | 30 | },
|
29 | 31 | {
|
|
35 | 37 | },
|
36 | 38 | {
|
37 | 39 | "cell_type": "code",
|
38 |
| - "execution_count": 15, |
| 40 | + "execution_count": 16, |
39 | 41 | "metadata": {},
|
40 | 42 | "outputs": [
|
41 | 43 | {
|
42 | 44 | "name": "stderr",
|
43 | 45 | "output_type": "stream",
|
44 | 46 | "text": [
|
45 | 47 | "INFO:Request to files/create_folder_v2\n",
|
46 |
| - "INFO:The directory/test_dropbox has been created.\n" |
| 48 | + "INFO:The directory/Data/test_dropbox has been created.\n" |
| 49 | + ] |
| 50 | + } |
| 51 | + ], |
| 52 | + "source": [ |
| 53 | + "fs.mkdir(\"/Data/test_dropbox\")" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "code", |
| 58 | + "execution_count": 17, |
| 59 | + "metadata": {}, |
| 60 | + "outputs": [ |
| 61 | + { |
| 62 | + "name": "stderr", |
| 63 | + "output_type": "stream", |
| 64 | + "text": [ |
| 65 | + "INFO:Request to files/list_folder\n" |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "data": { |
| 70 | + "text/plain": [ |
| 71 | + "[{'name': '/Data/test_dropbox', 'size': None, 'type': 'directory'}]" |
| 72 | + ] |
| 73 | + }, |
| 74 | + "execution_count": 17, |
| 75 | + "metadata": {}, |
| 76 | + "output_type": "execute_result" |
| 77 | + } |
| 78 | + ], |
| 79 | + "source": [ |
| 80 | + "fs.ls(\"/Data/test_dropbox\")" |
| 81 | + ] |
| 82 | + }, |
| 83 | + { |
| 84 | + "cell_type": "code", |
| 85 | + "execution_count": 18, |
| 86 | + "metadata": {}, |
| 87 | + "outputs": [ |
| 88 | + { |
| 89 | + "name": "stderr", |
| 90 | + "output_type": "stream", |
| 91 | + "text": [ |
| 92 | + "INFO:Request to files/get_metadata\n" |
47 | 93 | ]
|
| 94 | + }, |
| 95 | + { |
| 96 | + "data": { |
| 97 | + "text/plain": [ |
| 98 | + "{'name': '/Data/test_dropbox', 'size': None, 'type': 'directory'}" |
| 99 | + ] |
| 100 | + }, |
| 101 | + "execution_count": 18, |
| 102 | + "metadata": {}, |
| 103 | + "output_type": "execute_result" |
48 | 104 | }
|
49 | 105 | ],
|
50 | 106 | "source": [
|
51 |
| - "fs.mkdir(\"/test_dropbox\")" |
| 107 | + "fs.info(\"/Data/test_dropbox\")" |
52 | 108 | ]
|
53 | 109 | },
|
54 | 110 | {
|
55 | 111 | "cell_type": "markdown",
|
56 | 112 | "metadata": {},
|
57 | 113 | "source": [
|
58 |
| - "## Upload a file" |
| 114 | + "## Upload" |
59 | 115 | ]
|
60 | 116 | },
|
61 | 117 | {
|
62 | 118 | "cell_type": "code",
|
63 |
| - "execution_count": 16, |
| 119 | + "execution_count": 19, |
| 120 | + "metadata": {}, |
| 121 | + "outputs": [ |
| 122 | + { |
| 123 | + "name": "stderr", |
| 124 | + "output_type": "stream", |
| 125 | + "text": [ |
| 126 | + "INFO:Request to files/upload_session/start\n", |
| 127 | + "INFO:Request to files/upload_session/finish\n" |
| 128 | + ] |
| 129 | + } |
| 130 | + ], |
| 131 | + "source": [ |
| 132 | + "# Upload a file\n", |
| 133 | + "\n", |
| 134 | + "fs.put_file(\"example_file/test1.txt\", \"/Data/test_dropbox/text1.txt\")" |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "code", |
| 139 | + "execution_count": 23, |
64 | 140 | "metadata": {},
|
65 | 141 | "outputs": [
|
66 | 142 | {
|
67 | 143 | "name": "stderr",
|
68 | 144 | "output_type": "stream",
|
69 | 145 | "text": [
|
| 146 | + "INFO:Request to files/get_metadata\n", |
| 147 | + "INFO:Request to files/upload_session/start\n", |
| 148 | + "INFO:Request to files/upload_session/finish\n", |
70 | 149 | "INFO:Request to files/upload_session/start\n",
|
71 | 150 | "INFO:Request to files/upload_session/finish\n"
|
72 | 151 | ]
|
73 | 152 | }
|
74 | 153 | ],
|
75 | 154 | "source": [
|
76 |
| - "fs.upload(\"test1.txt\", \"/test_dropbox/test1.txt\")" |
| 155 | + "# Upload a folder with two files \n", |
| 156 | + "\n", |
| 157 | + "fs.upload(\"example_file/test_db\", \"/Data/test_dropbox/\", recursive=True)" |
77 | 158 | ]
|
78 | 159 | },
|
79 | 160 | {
|
|
85 | 166 | },
|
86 | 167 | {
|
87 | 168 | "cell_type": "code",
|
88 |
| - "execution_count": 18, |
| 169 | + "execution_count": 8, |
89 | 170 | "metadata": {},
|
90 | 171 | "outputs": [
|
91 | 172 | {
|
92 | 173 | "name": "stderr",
|
93 | 174 | "output_type": "stream",
|
94 | 175 | "text": [
|
| 176 | + "INFO:Request to files/get_metadata\n", |
95 | 177 | "INFO:Request to files/get_temporary_link\n",
|
96 | 178 | "INFO:Request to files/get_metadata\n"
|
97 | 179 | ]
|
98 | 180 | }
|
99 | 181 | ],
|
100 | 182 | "source": [
|
101 |
| - "fs.download(\"/test_dropbox/test1.txt\", \"test1.txt\")" |
| 183 | + "fs.download(\"/Data/test_dropbox/text1.txt\", \"example_file/test.txt\")" |
102 | 184 | ]
|
103 | 185 | },
|
104 | 186 | {
|
|
110 | 192 | },
|
111 | 193 | {
|
112 | 194 | "cell_type": "code",
|
113 |
| - "execution_count": 19, |
| 195 | + "execution_count": 9, |
114 | 196 | "metadata": {},
|
115 | 197 | "outputs": [
|
116 | 198 | {
|
|
123 | 205 | }
|
124 | 206 | ],
|
125 | 207 | "source": [
|
126 |
| - "with fs.open(\"/test_dropbox/test.txt\", mode='w') as f:\n", |
127 |
| - " f.write('hello')" |
| 208 | + "with fs.open(\"/Data/test_dropbox/test.txt\", mode='w') as f:\n", |
| 209 | + " f.write('Hello')" |
128 | 210 | ]
|
129 | 211 | },
|
130 | 212 | {
|
|
136 | 218 | },
|
137 | 219 | {
|
138 | 220 | "cell_type": "code",
|
139 |
| - "execution_count": null, |
| 221 | + "execution_count": 10, |
140 | 222 | "metadata": {},
|
141 |
| - "outputs": [], |
| 223 | + "outputs": [ |
| 224 | + { |
| 225 | + "name": "stderr", |
| 226 | + "output_type": "stream", |
| 227 | + "text": [ |
| 228 | + "INFO:Request to files/upload_session/start\n", |
| 229 | + "INFO:Request to files/upload_session/finish\n" |
| 230 | + ] |
| 231 | + } |
| 232 | + ], |
142 | 233 | "source": [
|
143 |
| - "with fs.open(\"/test_dropbox/test.txt\", mode='a') as f:\n", |
144 |
| - " f.write('hello')" |
| 234 | + "with fs.open(\"/Data/test_dropbox/test.txt\", mode='a') as f:\n", |
| 235 | + " f.write('world')" |
145 | 236 | ]
|
146 | 237 | },
|
147 | 238 | {
|
|
153 | 244 | },
|
154 | 245 | {
|
155 | 246 | "cell_type": "code",
|
156 |
| - "execution_count": 20, |
| 247 | + "execution_count": 11, |
157 | 248 | "metadata": {},
|
158 | 249 | "outputs": [
|
159 | 250 | {
|
|
163 | 254 | "INFO:Request to files/get_temporary_link\n",
|
164 | 255 | "INFO:Request to files/get_metadata\n"
|
165 | 256 | ]
|
166 |
| - } |
167 |
| - ], |
168 |
| - "source": [ |
169 |
| - "file = fs.open(\"/test_dropbox/test.txt\")" |
170 |
| - ] |
171 |
| - }, |
172 |
| - { |
173 |
| - "cell_type": "code", |
174 |
| - "execution_count": 21, |
175 |
| - "metadata": {}, |
176 |
| - "outputs": [ |
| 257 | + }, |
177 | 258 | {
|
178 |
| - "data": { |
179 |
| - "text/plain": [ |
180 |
| - "b'hellohello'" |
181 |
| - ] |
182 |
| - }, |
183 |
| - "execution_count": 21, |
184 |
| - "metadata": {}, |
185 |
| - "output_type": "execute_result" |
| 259 | + "name": "stdout", |
| 260 | + "output_type": "stream", |
| 261 | + "text": [ |
| 262 | + "b'Hello'\n" |
| 263 | + ] |
186 | 264 | }
|
187 | 265 | ],
|
188 | 266 | "source": [
|
189 |
| - "file.read()" |
| 267 | + "with fs.open(\"/Data/test_dropbox/test.txt\", mode=\"rb\") as f:\n", |
| 268 | + " print(f.read())" |
190 | 269 | ]
|
191 | 270 | },
|
192 | 271 | {
|
|
198 | 277 | },
|
199 | 278 | {
|
200 | 279 | "cell_type": "code",
|
201 |
| - "execution_count": 22, |
| 280 | + "execution_count": 12, |
202 | 281 | "metadata": {},
|
203 | 282 | "outputs": [],
|
204 | 283 | "source": [
|
|
207 | 286 | },
|
208 | 287 | {
|
209 | 288 | "cell_type": "code",
|
210 |
| - "execution_count": 23, |
| 289 | + "execution_count": 13, |
211 | 290 | "metadata": {},
|
212 | 291 | "outputs": [],
|
213 | 292 | "source": [
|
214 |
| - "file_intake = intake.open_textfiles(\"dropbox:///test_dropbox/test.txt\",storage_options={\"token\":db.load_token()})\n" |
| 293 | + "file_intake = intake.open_textfiles(\"dropbox:///Data/test_dropbox/test.txt\",storage_options={\"token\":\"**********\"})\n" |
215 | 294 | ]
|
216 | 295 | },
|
217 | 296 | {
|
218 | 297 | "cell_type": "code",
|
219 |
| - "execution_count": 24, |
| 298 | + "execution_count": 14, |
220 | 299 | "metadata": {},
|
221 | 300 | "outputs": [
|
222 |
| - { |
223 |
| - "name": "stderr", |
224 |
| - "output_type": "stream", |
225 |
| - "text": [ |
226 |
| - "INFO:Request to files/get_temporary_link\n", |
227 |
| - "INFO:Request to files/get_metadata\n" |
228 |
| - ] |
229 |
| - }, |
230 | 301 | {
|
231 | 302 | "data": {
|
232 | 303 | "text/plain": [
|
233 |
| - "['hellohello']" |
| 304 | + "['Hello']" |
234 | 305 | ]
|
235 | 306 | },
|
236 |
| - "execution_count": 24, |
| 307 | + "execution_count": 14, |
237 | 308 | "metadata": {},
|
238 | 309 | "output_type": "execute_result"
|
239 | 310 | }
|
|
251 | 322 | },
|
252 | 323 | {
|
253 | 324 | "cell_type": "code",
|
254 |
| - "execution_count": 26, |
| 325 | + "execution_count": 15, |
255 | 326 | "metadata": {},
|
256 | 327 | "outputs": [
|
257 | 328 | {
|
258 | 329 | "name": "stderr",
|
259 | 330 | "output_type": "stream",
|
260 | 331 | "text": [
|
261 | 332 | "INFO:Request to files/delete_v2\n",
|
262 |
| - "INFO:The directory/test_dropbox has been erased.\n" |
| 333 | + "INFO:The directory/Data/test_dropbox has been erased.\n" |
263 | 334 | ]
|
264 | 335 | }
|
265 | 336 | ],
|
266 | 337 | "source": [
|
267 |
| - "fs.rm(\"/test_dropbox\")" |
| 338 | + "fs.rm(\"/Data/test_dropbox\")" |
268 | 339 | ]
|
269 | 340 | }
|
270 | 341 | ],
|
271 | 342 | "metadata": {
|
272 | 343 | "kernelspec": {
|
273 |
| - "display_name": "Python 3", |
| 344 | + "display_name": "Python 3 (ipykernel)", |
274 | 345 | "language": "python",
|
275 | 346 | "name": "python3"
|
276 | 347 | },
|
|
284 | 355 | "name": "python",
|
285 | 356 | "nbconvert_exporter": "python",
|
286 | 357 | "pygments_lexer": "ipython3",
|
287 |
| - "version": "3.7.7" |
| 358 | + "version": "3.7.11" |
288 | 359 | }
|
289 | 360 | },
|
290 | 361 | "nbformat": 4,
|
|
0 commit comments