def _credentials(): try: updated_at = os.path.getmtime(settings.CREDENTIALS_FILE) updated_at = datetime.fromtimestamp(updated_at) updated_at = updated_at.strftime('%Y-%m-%d %H:%M') return '''Credentials (updated {updated_at}): User: {user} Token: {token}'''.format(updated_at=updated_at, user=auth.get_username(), token=auth.get_access_token()) except OSError: return 'No credentials'
def _pay_or_charge(args): access_token = auth.get_access_token() if not access_token: return params = { 'note': args.note, 'amount': args.amount, 'access_token': access_token, 'audience': 'private', } if args.user.startswith("@"): user_id = user.id_from_username(args.user[1:]) params['user_id'] = user_id else: params['phone'] = args.user response = session.post( _payments_url_with_params(params) ).json() _log_response(response)