(id, cmd, args)
| 458 | |
| 459 | |
| 460 | def fileDownload(id, cmd, args): |
| 461 | req = pb.FileDownReq(id=str(id), auth=pb.Auth(scheme='token', secret=tn_globals.AuthToken), |
| 462 | uri=cmd.filename, if_modified="") |
| 463 | |
| 464 | # Call the server |
| 465 | stream = pbx.NodeStub(tn_globals.Connection).LargeFileServe(req) |
| 466 | # Read file chunks |
| 467 | fd = None |
| 468 | for chunk in stream: |
| 469 | if chunk: |
| 470 | if chunk.code >= 400: |
| 471 | stdoutln("Failed to download '{0}': {1} {2}".format(cmd.filename, chunk.code, chunk.text)) |
| 472 | break |
| 473 | if chunk.code >= 300: |
| 474 | stdoutln("Use HTTP {0} to download from {1}".format(chunk.code, chunk.redir_url)) |
| 475 | break |
| 476 | if not fd: |
| 477 | fd = open(chunk.meta.name, mode='wb') |
| 478 | fd.write(chunk.content) |
| 479 | continue |
| 480 | if fd: |
| 481 | fd.close() |
| 482 | |
| 483 | |
| 484 | # Given an array of parts, parse commands and arguments |
nothing calls this directly
no test coverage detected
searching dependent graphs…