Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keepercommander/commands/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ def execute(self, params, **kwargs):
params.environment_variables[LAST_FOLDER_UID] = folder_uid
if request['folder_type'] == 'shared_folder':
params.environment_variables[LAST_SHARED_FOLDER_UID] = folder_uid
parent_path = get_folder_path(params, base_folder.uid) if base_folder.uid else ''
path = f'{parent_path}{name}'
response_data = {'folder_uid': folder_uid, 'name': name, 'path': path}
logging.info(json.dumps(response_data))
return folder_uid


Expand Down
14 changes: 12 additions & 2 deletions keepercommander/commands/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ def execute(self, params, **kwargs):
admins = api.get_share_admins_for_shared_folder(params, uid)
sf = api.get_shared_folder(params, uid)
if fmt == 'json':
path = get_folder_path(params, sf.shared_folder_uid, delimiter=os.sep) if sf.shared_folder_uid else ''
sfo = {
"shared_folder_uid": sf.shared_folder_uid,
"name": sf.name,
"path": path,
"manage_users": sf.default_manage_users,
"manage_records": sf.default_manage_records,
"can_edit": sf.default_can_edit,
Expand All @@ -291,17 +293,25 @@ def execute(self, params, **kwargs):
'can_edit': r['can_edit'],
'can_share': r['can_share']
} for r in sf.records]
def _format_expiration(expiration_value):
if expiration_value is None or expiration_value <= 0:
return 'never'
return datetime.datetime.fromtimestamp(expiration_value // 1000).isoformat()
if sf.users:
sfo['users'] = [{
'username': u['username'],
'user_id': u.get('account_uid'),
'manage_records': u['manage_records'],
'manage_users': u['manage_users']
'manage_users': u['manage_users'],
'expiration': _format_expiration(u.get('expiration'))
} for u in sf.users]
if sf.teams:
sfo['teams'] = [{
'name': t['name'],
'team_uid': t.get('team_uid'),
'manage_records': t['manage_records'],
'manage_users': t['manage_users']
'manage_users': t['manage_users'],
'expiration': _format_expiration(t.get('expiration'))
} for t in sf.teams]

if admins:
Expand Down
30 changes: 22 additions & 8 deletions keepercommander/service/util/parse_keeper_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,27 +486,41 @@ def _parse_this_device_command(response: str) -> Dict[str, Any]:

@staticmethod
def _parse_mkdir_command(response: str) -> Dict[str, Any]:
"""Parse 'mkdir' command output to extract folder UID."""
"""Parse 'mkdir' command output to extract folder UID, path, and name."""
response_str = response.strip()

# Success case - try to extract UID
lines = [ln.strip() for ln in response_str.split('\n') if ln.strip()]

result = {
"status": "success",
"command": "mkdir",
"data": None
}

if re.match(r'^[a-zA-Z0-9_-]+$', response_str):

for line in lines:
try:
data = json.loads(line)
if isinstance(data, dict) and 'folder_uid' in data:
result["data"] = {
"folder_uid": data["folder_uid"],
"path": data.get("path"),
"name": data.get("name")
}
return result
except (json.JSONDecodeError, TypeError):
pass

last_line = lines[-1] if lines else response_str
if re.match(r'^[a-zA-Z0-9_-]+$', last_line):
result["data"] = {
"folder_uid": response_str
"folder_uid": last_line
}
else:
uid_match = re.search(r'folder_uid=([a-zA-Z0-9_-]+)', response_str)
uid_match = re.search(r'folder_uid=([a-zA-Z0-9_-]+)', last_line)
if uid_match:
result["data"] = {
"folder_uid": uid_match.group(1)
}

return result

@staticmethod
Expand Down
Loading