| 479 | |
| 480 | |
| 481 | class SyncDownCommand(Command): |
| 482 | def get_parser(self): |
| 483 | return sync_down_parser |
| 484 | |
| 485 | def execute(self, params, **kwargs): |
| 486 | force = kwargs.get('force') is True |
| 487 | if force: |
| 488 | params.revision = 0 |
| 489 | params.sync_down_token = b'' |
| 490 | if params.config: |
| 491 | if 'skip_records' in params.config: |
| 492 | del params.config['skip_records'] |
| 493 | |
| 494 | api.sync_down(params, record_types=force) |
| 495 | if force: |
| 496 | from ..loginv3 import LoginV3Flow |
| 497 | LoginV3Flow.populateAccountSummary(params) |
| 498 | |
| 499 | accepted = False |
| 500 | if len(params.pending_share_requests) > 0: |
| 501 | for user in params.pending_share_requests: |
| 502 | accepted = False |
| 503 | logging.info('Note: You have pending share request from ' + user) |
| 504 | answer = user_choice('Do you want to accept these request?', 'yn', 'n') |
| 505 | rq = { |
| 506 | 'command': 'accept_share' if answer == 'y' else 'cancel_share', |
| 507 | 'from_email': user |
| 508 | } |
| 509 | try: |
| 510 | rs = api.communicate(params, rq) |
| 511 | if rs['result'] == 'success': |
| 512 | accepted = accepted or answer == 'y' |
| 513 | except Exception as e: |
| 514 | logging.debug('Accept share exception: %s', e) |
| 515 | |
| 516 | params.pending_share_requests.clear() |
| 517 | |
| 518 | if accepted: |
| 519 | params.sync_data = True |
| 520 | |
| 521 | |
| 522 | class ThisDeviceCommand(Command): |
no outgoing calls
no test coverage detected