| 1854 | |
| 1855 | |
| 1856 | class CheckEnforcementsCommand(Command): |
| 1857 | def get_parser(self): |
| 1858 | return check_enforcements_parser |
| 1859 | |
| 1860 | def is_authorised(self): |
| 1861 | return False |
| 1862 | |
| 1863 | def execute(self, params, **kwargs): |
| 1864 | if params.enforcements: |
| 1865 | if 'enterprise_invited' in params.enforcements: |
| 1866 | logging.info('You\'ve been invited to join {0}.'.format(params.enforcements['enterprise_invited'])) |
| 1867 | action = user_choice('A(ccept)/D(ecline)/I(gnore)?: ', 'adi') |
| 1868 | action = action.lower() |
| 1869 | if action == 'a': |
| 1870 | action = 'accept' |
| 1871 | elif action == 'd': |
| 1872 | action = 'decline' |
| 1873 | if action in ['accept', 'decline']: |
| 1874 | e_rq = { |
| 1875 | 'command': '{0}_enterprise_invite'.format(action) |
| 1876 | } |
| 1877 | if action == 'accept': |
| 1878 | verification_code = input('Please enter the verification code sent via email: ') |
| 1879 | if verification_code: |
| 1880 | e_rq['verification_code'] = verification_code |
| 1881 | else: |
| 1882 | e_rq = None |
| 1883 | if e_rq: |
| 1884 | try: |
| 1885 | api.communicate(params, e_rq) |
| 1886 | logging.info('%s enterprise invite', 'Accepted' if action == 'accept' else 'Declined') |
| 1887 | #TODO reload enterprise settings |
| 1888 | except Exception as e: |
| 1889 | logging.error('Enterprise %s failure: %s', action, e) |
| 1890 | |
| 1891 | share_account_by = params.get_share_account_timestamp() |
| 1892 | if share_account_by is not None: |
| 1893 | account_transfer_command = AcceptTransferCommand() |
| 1894 | account_transfer_command.execute(params, **kwargs) |
| 1895 | |
| 1896 | |
| 1897 | class AcceptTransferCommand(Command): |