diff --git a/Dockerfile b/Dockerfile index c2c4cd5..587da65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ ENV VCS_CONFIG="/root/vacation_calendar_sync_config.yaml" #ENV VCS_COLLECTION_PATH="/root/vacation_calendar_sync/" #RUN mkdir /duo_auth/app -CMD ["bash"] +#CMD ["bash"] #CMD [ "python3 OutlookCalendar.py -s" ] diff --git a/IndividualCalendar.py b/IndividualCalendar.py index 0b63ec9..3bd51c3 100644 --- a/IndividualCalendar.py +++ b/IndividualCalendar.py @@ -52,7 +52,8 @@ def get_individual_calendars(start_date, end_date, group_members, access_token): if response.status_code != 200: message = 'Unable to retrieve individual calendar from the getSchedule endpoint' utils.send_email(message, access_token) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError(message) return response.json() diff --git a/OutlookCalendar.py b/OutlookCalendar.py index 96da19b..1dd933d 100644 --- a/OutlookCalendar.py +++ b/OutlookCalendar.py @@ -148,6 +148,6 @@ def main(configs): stream_handler.setFormatter(fmt=logging.Formatter('%(name)s:%(asctime)s:%(filename)s:%(levelname)s:%(message)s')) logger.addHandler(stream_handler) - main(configs) - #debug(configs) + #main(configs) + debug(configs) diff --git a/README.md b/README.md index e67e488..a9c3cd3 100644 --- a/README.md +++ b/README.md @@ -8,23 +8,22 @@ Microsoft Azure Project Config (`/root/vacation_calendar_sync_config.yaml`) Look at [sample_config.yaml](sample_config.yaml) -# Netrc setup (`/home/.ssh/netrc`) -``` -machine OUTLOOK_LOGIN -login ... -password ... +## Pull Image from DockerHub ``` - - # Build Container ``` docker run -it --name ncsa_vacation_calendar_sync --mount type=bind,source=$HOME,dst=/home ghcr.io/ncsa/vacation_calendar_sync ``` +Once the container is created, entrypoint will execute the entrypoint.sh file, which effectively runs the program with python3 OutlookCalendar -s mode. To override this default command run: + +``` +docker run -it --name ncsa_vacation_calendar_sync entrypoint python3 OutlookCalendar -m [year]-[month]-[day] [year]-[month]-[day] --mount type=bind,source=$HOME,dst=/home ghcr.io/ncsa/vacation_calendar_sync +``` + # Quick Start The commnad below will generate a report to console of events that occurs between the start and end date. @@ -47,11 +46,7 @@ Example: python3 OutlookCalendar.py -s `-h` : Display the help screen -# Notes -The `.netrc` file needs to have the correct permission (`-rw-------`). -If not, do: `chmod u+rw,u-x,go-rwx ~/.netrc` -To check: `ls -la ~/.netrc` diff --git a/SharedCalendar.py b/SharedCalendar.py index 409ade8..c995ac1 100644 --- a/SharedCalendar.py +++ b/SharedCalendar.py @@ -36,7 +36,8 @@ def get_shared_calendar_id(shared_calendar_name, access_token): if response.status_code != 200: message = f"Unable to connect to the {endpoint} endpoint to retrieve {shared_calendar_name}" utils.send_email(message, access_token) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError(message) # Loop through all the calendars available to the user, and find the one indicated in the yaml file and retrieve its calendar ID @@ -46,7 +47,8 @@ def get_shared_calendar_id(shared_calendar_name, access_token): message = f"{shared_calendar_name} was not found" utils.send_email(message, access_token) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise KeyError(message) def get_shared_calendar(shared_calendar_id, start_date, end_date, access_token): @@ -84,7 +86,8 @@ def get_shared_calendar(shared_calendar_id, start_date, end_date, access_token): if (response.status_code != 200): message = f'Unable to retrieve shared calendar from {endpoint} endpoint' utils.send_email(message) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError(message) return response.json() @@ -350,7 +353,8 @@ def post_batch(access_token, batches, info=None): message = "Unable to post batch \n" + str(response.json()["error"]) #utils.send_email(user_client, access_token, message) logger.warning(message) - logger.warning(response.json()) + logger.warning(f"response.text: {response.text}") + #logger.warning(response.json()) continue if info: @@ -381,7 +385,8 @@ def get_category(access_token, category_name, category_color): if (response.status_code != 200): message = f"Unable to connect to {endpoint} endpoint to retrieve the masterCategories" utils.send_email(message, access_token) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError(message) response = response.json()['value'] @@ -422,7 +427,8 @@ def create_category(access_token, category_name, category_color): if response.status_code != 201: message = f"Unable to create {category_name}" utils.send_email(message, access_token) - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError(message) #print("category created") return category_name diff --git a/utils.py b/utils.py index bff46ae..66a15da 100644 --- a/utils.py +++ b/utils.py @@ -124,7 +124,8 @@ def send_email(message, access_token): response = requests.post(endpoint, data=json.dumps(payload), headers=header) if (response.status_code != 202): - logger.error(response.json()) + #logger.error(response.json()) + logger.error(f"response.text: {response.text}") raise ConnectionError("Unable to send email") # TODO: consider a case if the status code isn't 202