[ARVADOS] updated: 2.1.0-2154-gba245c7a7
Git user
git at public.arvados.org
Sat Mar 26 00:30:31 UTC 2022
Summary of changes:
tools/user-activity/arvados_user_activity/main.py | 52 ++++++++++++++++++++---
1 file changed, 46 insertions(+), 6 deletions(-)
via ba245c7a71e54de5b0a9ad0adb1f8ed0486e686e (commit)
via 5ca906cc875a1debfde1123e461b60411e152b33 (commit)
from d89f3c32c8c98d7f9a28e796358645683f0f66c9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit ba245c7a71e54de5b0a9ad0adb1f8ed0486e686e
Author: Ward Vandewege <ward at curii.com>
Date: Fri Mar 25 20:30:09 2022 -0400
18903: add a date range option to the user activity report.
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>
diff --git a/tools/user-activity/arvados_user_activity/main.py b/tools/user-activity/arvados_user_activity/main.py
index 3fcba5748..f078b8154 100755
--- a/tools/user-activity/arvados_user_activity/main.py
+++ b/tools/user-activity/arvados_user_activity/main.py
@@ -13,8 +13,26 @@ import ciso8601
def parse_arguments(arguments):
arg_parser = argparse.ArgumentParser()
- arg_parser.add_argument('--days', type=int, required=True)
+ arg_parser.add_argument('--start', help='Start date for the report in YYYY-MM-DD format')
+ arg_parser.add_argument('--end', help='End date for the report in YYYY-MM-DD format')
+ arg_parser.add_argument('--days', type=int, help='Number of days before now() to start the report')
args = arg_parser.parse_args(arguments)
+
+ if args.days and (args.start or args.end):
+ p.print_help()
+ print("Error: either specify --days or both --start and --end")
+ exit(1)
+
+ if not args.days and (not args.start or not args.end):
+ p.print_help()
+ print("Error: either specify --days or both --start and --end")
+ exit(1)
+
+ if (args.start and not args.end) or (args.end and not args.start):
+ p.print_help()
+ print("Error: no start or end date found, either specify --days or both --start and --end")
+ exit(1)
+
return args
def getowner(arv, uuid, owners):
@@ -65,13 +83,31 @@ def main(arguments=None):
arv = arvados.api()
- since = datetime.datetime.utcnow() - datetime.timedelta(days=args.days)
+ if args.days:
+ to = datetime.datetime.utcnow()
+ since = to - datetime.timedelta(days=args.days)
+
+ if args.start:
+ try:
+ since = datetime.datetime.strptime(args.start,"%Y-%m-%d")
+ except:
+ p.print_help()
+ print("Error: start date must be in YYYY-MM-DD format")
+ exit(1)
+
+ if args.end:
+ try:
+ to = datetime.datetime.strptime(args.end,"%Y-%m-%d")
+ except:
+ p.print_help()
+ print("Error: end date must be in YYYY-MM-DD format")
+ exit(1)
print("User activity on %s between %s and %s\n" % (arv.config()["ClusterID"],
- (datetime.datetime.now() - datetime.timedelta(days=args.days)).isoformat(sep=" ", timespec="minutes"),
- datetime.datetime.now().isoformat(sep=" ", timespec="minutes")))
+ since.isoformat(sep=" ", timespec="minutes"),
+ to.isoformat(sep=" ", timespec="minutes")))
- events = arvados.util.keyset_list_all(arv.logs().list, filters=[["created_at", ">=", since.isoformat()]])
+ events = arvados.util.keyset_list_all(arv.logs().list, filters=[["created_at", ">=", since.isoformat()],["created_at", "<", to.isoformat()]])
users = {}
owners = {}
commit 5ca906cc875a1debfde1123e461b60411e152b33
Author: Ward Vandewege <ward at curii.com>
Date: Fri Mar 25 17:33:43 2022 -0400
18903: handle deleted users properly.
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>
diff --git a/tools/user-activity/arvados_user_activity/main.py b/tools/user-activity/arvados_user_activity/main.py
index 2f38db3be..3fcba5748 100755
--- a/tools/user-activity/arvados_user_activity/main.py
+++ b/tools/user-activity/arvados_user_activity/main.py
@@ -33,7 +33,11 @@ def getowner(arv, uuid, owners):
return getowner(arv, owners[uuid], owners)
def getuserinfo(arv, uuid):
- u = arv.users().get(uuid=uuid).execute()
+ try:
+ u = arv.users().get(uuid=uuid).execute()
+ except:
+ return "deleted user (%susers/%s)" % (arv.config()["Services"]["Workbench1"]["ExternalURL"],
+ uuid)
prof = "\n".join(" %s: \"%s\"" % (k, v) for k, v in u["prefs"].get("profile", {}).items() if v)
if prof:
prof = "\n"+prof+"\n"
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list