Skip to content

Commit 43d8443

Browse files
authored
Merge pull request #12 from TheScriptGuy/11-timestamp-error-message-mongodb
Version 0.37. See CHANGELOG.md
2 parents d3964ad + 21b9668 commit 43d8443

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2023/04/15
2+
## Version 0.37
3+
### Feature additions
4+
* [Adding time to output when error occurs](https://github.com/TheScriptGuy/certificateChecker/issues/11)
5+
16
# 2023/03/25
27
## Version 0.36
38
### Feature additions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Certificate Checker
22

3-
Version: 0.36
3+
Version: 0.37
44

55
Author: TheScriptGuy
66

@@ -30,7 +30,7 @@ usage: certCheck.py [-h] [--hostname HOSTNAME] [--displayCertificate] [--display
3030
[--sendEmail] [--retryAmount RETRYAMOUNT] [--timeBetweenRetries TIMEBETWEENRETRIES] [--contextVariables] [--setTag SETTAG] [--delTag] [--getTag] [--renewDeviceId] [--getDeviceId] [--deleteDeviceId]
3131
[--setTenantId SETTENANTID] [--getTenantId] [--delTenantId] [--createBlankConfiguration]
3232

33-
Certificate Checker v0.35
33+
Certificate Checker v0.37
3434

3535
optional arguments:
3636
-h, --help show this help message and exit

certCheck.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Program: Certificate Checker
22
# Author: Nolan Rumble
3-
# Date: 2023/03/25
4-
# Version: 0.36
3+
# Date: 2023/04/15
4+
# Version: 0.37
55

66
import argparse
77
import datetime
@@ -17,7 +17,7 @@
1717
from data import emailTemplateBuilder
1818
from data import sendDataEmail
1919

20-
scriptVersion = "0.36"
20+
scriptVersion = "0.37"
2121

2222
# Global Variables
2323
args = None

data/sendDataMongoDB.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Class: sendDataMongoDB
2-
# Last updated: 2023/03/25
3-
# Author: TheScriptGuy (https://github.com/TheScriptGuy
4-
# Version: 0.09
2+
# Last updated: 2023/04/15
3+
# Author: TheScriptGuy (https://github.com/TheScriptGuy)
4+
# Version: 0.10
55
# Description: Send json list to mongoDB based on configuration in mongo.cfg
66

77
import pymongo
@@ -107,13 +107,20 @@ def sendResults(self, __results, __destCollection):
107107
__mongoResult = __destCollection.insert_one(__results)
108108
__uploadResult.append(__mongoResult)
109109
except pymongo.errors.ServerSelectionTimeoutError:
110-
print("Server connection timeout error when uploading data.")
111-
print("Saving to certificateData.json")
110+
# Get time of error
111+
errTime = str(datetime.datetime.utcnow())
112+
print(f"{errTime} - Server connection timeout error when uploading data. Saving to certificateData.json")
113+
114+
# Save test data to file.
112115
self.sendJsonScriptDataToFile("certificateData.json", [__results])
113116
sys.exit(1)
117+
114118
except pymongo.errors.OperationFailure as e:
115-
print(f"Mongo operation error - {e}")
116-
print("Saving to certificateData.json")
119+
# Get time of error
120+
errTime = str(datetime.datetime.utcnow())
121+
print(f"{errTime} - Mongo operation error - {e}. Saving to certificateData.json")
122+
123+
# Save test data to file.
117124
self.sendJsonScriptDataToFile("certificateData.json", [__results])
118125
sys.exit(1)
119126

@@ -233,4 +240,4 @@ def uploadDataToMongoDB(self, __jsonScriptData):
233240
def __init__(self):
234241
"""Initialize the sendDataMongoDB class."""
235242
self.initialized = True
236-
self.version = "0.09"
243+
self.version = "0.10"

0 commit comments

Comments
 (0)