Skip to content

Commit

Permalink
Fix Thycotic import
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-keeper committed Apr 11, 2024
1 parent c7e7970 commit 7083e3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion keepercommander/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# Contact: ops@keepersecurity.com
#

__version__ = '16.10.12'
__version__ = '16.10.13'
23 changes: 12 additions & 11 deletions keepercommander/importer/thycotic/thycotic.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,14 @@ def request_totp():
return input('Enter TOTP code: '.rjust(25))

def _send_keep_alive_if_needed(self, params): # type: (KeeperParams) -> None
now = int(datetime.datetime.utcnow().timestamp())
if (now - self._last_keep_alive) > self._keep_alive_period:
self._last_keep_alive = now
try:
api.send_keepalive(params)
except:
pass
if isinstance(params, KeeperParams):
now = int(datetime.datetime.utcnow().timestamp())
if (now - self._last_keep_alive) > self._keep_alive_period:
self._last_keep_alive = now
try:
api.send_keepalive(params)
except:
pass

def do_import(self, filename, **kwargs):
# type: (ThycoticImporter, str, ...) -> Iterable[Union[Record, SharedFolder]]
Expand Down Expand Up @@ -315,7 +316,7 @@ def do_import(self, filename, **kwargs):
pass
print(f'Loaded {len(totp_codes)} code(s)', flush=True)

self._send_keep_alive_if_needed()
self._send_keep_alive_if_needed(params)
folders = ThycoticImporter.get_folders(auth, skip_permissions=True)
filter_folder = kwargs.get('filter_folder')
if filter_folder:
Expand Down Expand Up @@ -346,7 +347,7 @@ def do_import(self, filename, **kwargs):
else:
secrets_ids = [x['id'] for x in auth.thycotic_search(f'/v1/secrets/lookup')]

self._send_keep_alive_if_needed()
self._send_keep_alive_if_needed(params)
print(f'Loading {len(secrets_ids)} Records ', flush=True, end='')
secrets = []
for secret_id in secrets_ids:
Expand All @@ -357,9 +358,9 @@ def do_import(self, filename, **kwargs):
if len(secrets) % 10 == 9:
print('.', flush=True, end='')
if len(secrets) % 100 == 99:
self._send_keep_alive_if_needed()
self._send_keep_alive_if_needed(params)

self._send_keep_alive_if_needed()
self._send_keep_alive_if_needed(params)
for secret in secrets:
record = Record()
record.title = secret.get('name', '')
Expand Down

0 comments on commit 7083e3c

Please sign in to comment.