From daf8360e35fe54b11dadf53752acdcba9ebec2e0 Mon Sep 17 00:00:00 2001 From: Sinisa Veseli <sveseli@aps.anl.gov> Date: Fri, 14 Oct 2016 05:14:09 +0000 Subject: [PATCH] remove microsecond from timestamp; add cron job script --- sbin/dm_sync_aps_user_accounts.sh | 25 +++++++++++++++++++ setup.sh | 1 + src/python/dm/__init__.py | 2 +- .../cli/updateUsersFromApsDbCli.py | 4 +++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 sbin/dm_sync_aps_user_accounts.sh diff --git a/sbin/dm_sync_aps_user_accounts.sh b/sbin/dm_sync_aps_user_accounts.sh new file mode 100755 index 00000000..c438d1bc --- /dev/null +++ b/sbin/dm_sync_aps_user_accounts.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# +# Script used for syncing APS user accounts + +# Usage: +# +# $0 +# + +CURRENT_DIR=`pwd` +MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd` +cd $CURRENT_DIR +DM_ROOT_DIR=$MY_DIR/.. +DM_ENV_FILE=${DM_ROOT_DIR}/setup.sh +if [ ! -f ${DM_ENV_FILE} ]; then + echo "Environment file ${DM_ENV_FILE} does not exist." + exit 2 +fi +. ${DM_ENV_FILE} > /dev/null +DM_CONFIG_FILE=$DM_ROOT_DIR/../etc/dm.aps-user-update-utilities.conf + +# Simply run update command after sourcing setup file +dm-update-users-from-aps-db --config-file=$DM_CONFIG_FILE --quiet + diff --git a/setup.sh b/setup.sh index 5bf05917..ba2bb4f5 100644 --- a/setup.sh +++ b/setup.sh @@ -109,6 +109,7 @@ fi oracleDir=$DM_SUPPORT_DIR/opt/oracle-client/$DM_HOST_ARCH if [ -d $oracleDir ]; then LD_LIBRARY_PATH=$oracleDir:$LD_LIBRARY_PATH + PATH=$oracleDir:$PATH fi # Get back to where we were before invoking the setup script diff --git a/src/python/dm/__init__.py b/src/python/dm/__init__.py index f024d30e..7000cfa1 100644 --- a/src/python/dm/__init__.py +++ b/src/python/dm/__init__.py @@ -1 +1 @@ -__version__ = "0.13 (2016.05.27)" +__version__ = "0.14 (2016.10.13)" diff --git a/src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py b/src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py index b9870b3a..afc0e615 100755 --- a/src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py +++ b/src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py @@ -150,6 +150,10 @@ Description: # datetime cannot handle time zone at the moment timeZonePos = dmLastUpdate.rfind('-') dmLastUpdate = dmLastUpdate[0:timeZonePos] + # remove microseconds from the timestamp + secondPos = dmLastUpdate.rfind('.') + if secondPos > 0: + dmLastUpdate = dmLastUpdate[0:secondPos] dmLastUpdate = datetime.datetime.strptime(dmLastUpdate, '%Y-%m-%d %H:%M:%S') if not dmLastUpdate or dmLastUpdate < apsLastChangeDate: # User needs update -- GitLab