edx-enterprise-data 10.7.6__py3-none-any.whl → 10.7.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {edx_enterprise_data-10.7.6.dist-info → edx_enterprise_data-10.7.8.dist-info}/METADATA +1 -1
- {edx_enterprise_data-10.7.6.dist-info → edx_enterprise_data-10.7.8.dist-info}/RECORD +10 -10
- enterprise_data/__init__.py +1 -1
- enterprise_reporting/send_enterprise_reports.py +13 -3
- enterprise_reporting/tests/test_send_enterprise_reports.py +1 -1
- enterprise_reporting/tests/test_utils.py +1 -0
- enterprise_reporting/utils.py +2 -5
- {edx_enterprise_data-10.7.6.dist-info → edx_enterprise_data-10.7.8.dist-info}/LICENSE +0 -0
- {edx_enterprise_data-10.7.6.dist-info → edx_enterprise_data-10.7.8.dist-info}/WHEEL +0 -0
- {edx_enterprise_data-10.7.6.dist-info → edx_enterprise_data-10.7.8.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
enterprise_data/__init__.py,sha256=
|
1
|
+
enterprise_data/__init__.py,sha256=ORyaAJ_q0FsUuk6G-Jpj2Dn-dzIgmLg2r_3zzLJ40Is,124
|
2
2
|
enterprise_data/apps.py,sha256=aF6hZwDfI2oWj95tUTm_2ikHueQj-jLj-u0GrgzpsQI,414
|
3
3
|
enterprise_data/clients.py,sha256=GvQupy5TVYfO_IKC3yzXSAgNP54r-PtIjidM5ws9Iks,3947
|
4
4
|
enterprise_data/constants.py,sha256=uCKjfpdlMYFZJsAj3n9RMw4Cmg5_6s3NuwocO-fch3s,238
|
@@ -154,8 +154,8 @@ enterprise_reporting/__init__.py,sha256=yQO9ureIxFnl-1a_34H53elDwuAzXrSmhLlzqqD2
|
|
154
154
|
enterprise_reporting/delivery_method.py,sha256=bG-JCGhrK3nuC3P6D88zBRSwDJCbaDxN35nNlXzvoRM,4813
|
155
155
|
enterprise_reporting/external_resource_link_report.py,sha256=jQ6RS0yec0IhAz4wErQ3q8Yn206R7aQbgcR2c803BLA,8066
|
156
156
|
enterprise_reporting/reporter.py,sha256=3wI46qH-CNCUC5r9-Eme1mQdMjwEsFk9myRb-ajzJkM,13807
|
157
|
-
enterprise_reporting/send_enterprise_reports.py,sha256=
|
158
|
-
enterprise_reporting/utils.py,sha256=
|
157
|
+
enterprise_reporting/send_enterprise_reports.py,sha256=W9xc7hu3ZP4zmoIndITc3hdXDbd4A3QEWQN0_ZO1E1A,5270
|
158
|
+
enterprise_reporting/utils.py,sha256=L_ENZYE-UgTy3sHRJSXjN-Hb3qkT-VLAIIqzIu9fpDQ,13745
|
159
159
|
enterprise_reporting/clients/__init__.py,sha256=9xW-Nj1A3JWb9rOWVFdFaDzcyremAS-whVB8DRW_wCY,5121
|
160
160
|
enterprise_reporting/clients/enterprise.py,sha256=-ZKoQTyDLYPLDfC7hWKhJZxVOorWt0kYmFAiOUJkyNM,9853
|
161
161
|
enterprise_reporting/clients/s3.py,sha256=CZ9FgwOGKo-lQmZ4cw8oIqoVmhEtwBb6jfhFqoNHgh4,559
|
@@ -169,12 +169,12 @@ enterprise_reporting/tests/test_delivery_method.py,sha256=Zy169SrKz5zWjysI_RhGuj
|
|
169
169
|
enterprise_reporting/tests/test_enterprise_client.py,sha256=lpWm0muvA3alRjmlRAezE5901C9DU3WiySH4D5-U3qE,1058
|
170
170
|
enterprise_reporting/tests/test_external_link_report.py,sha256=zdnVOD1qtAp9c5EbIPnD9jcoLtW4iKs7gSVklgBK328,7029
|
171
171
|
enterprise_reporting/tests/test_reporter.py,sha256=PTmkGvPjGEjxiyizL88LAKnaWdvZDgOBjL4QStfOdyw,4057
|
172
|
-
enterprise_reporting/tests/test_send_enterprise_reports.py,sha256=
|
173
|
-
enterprise_reporting/tests/test_utils.py,sha256=
|
172
|
+
enterprise_reporting/tests/test_send_enterprise_reports.py,sha256=zBj7sDvRLJQbRsOHwYeOzTGrKx7t7JUq5dLNGASiq7o,1052
|
173
|
+
enterprise_reporting/tests/test_utils.py,sha256=y4t6w9aKra-ftqtUeHvPwOhje-1npz7auV5o74ya8fE,9523
|
174
174
|
enterprise_reporting/tests/test_vertica_client.py,sha256=-R2yNCGUjRtoXwLMBloVFQkFYrJoo613VCr61gwI3kQ,140
|
175
175
|
enterprise_reporting/tests/utils.py,sha256=xms2LM7DV3wczXEfctOK1ddel1EE0J_YSr17UzbCDy4,1401
|
176
|
-
edx_enterprise_data-10.7.
|
177
|
-
edx_enterprise_data-10.7.
|
178
|
-
edx_enterprise_data-10.7.
|
179
|
-
edx_enterprise_data-10.7.
|
180
|
-
edx_enterprise_data-10.7.
|
176
|
+
edx_enterprise_data-10.7.8.dist-info/LICENSE,sha256=dql8h4yceoMhuzlcK0TT_i-NgTFNIZsgE47Q4t3dUYI,34520
|
177
|
+
edx_enterprise_data-10.7.8.dist-info/METADATA,sha256=qqw6Wijtwxo0PbLwnV-E-ELIIsSJgbdFs_9i6ZVrl0M,1684
|
178
|
+
edx_enterprise_data-10.7.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
179
|
+
edx_enterprise_data-10.7.8.dist-info/top_level.txt,sha256=f5F2kU-dob6MqiHJpgZkFzoCD5VMhsdpkTV5n9Tvq3I,59
|
180
|
+
edx_enterprise_data-10.7.8.dist-info/RECORD,,
|
enterprise_data/__init__.py
CHANGED
@@ -4,13 +4,15 @@ Sends an Enterprise Customer's data file to a configured destination.
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
|
7
|
-
|
8
7
|
import argparse
|
8
|
+
import datetime
|
9
9
|
import logging
|
10
10
|
import os
|
11
11
|
import re
|
12
12
|
import sys
|
13
13
|
|
14
|
+
import pytz
|
15
|
+
|
14
16
|
from enterprise_reporting.clients.enterprise import EnterpriseAPIClient
|
15
17
|
from enterprise_reporting.reporter import EnterpriseReportSender
|
16
18
|
from enterprise_reporting.utils import is_current_time_in_schedule
|
@@ -55,11 +57,13 @@ def cleanup_files(enterprise_id):
|
|
55
57
|
os.remove(os.path.join(directory, f))
|
56
58
|
|
57
59
|
|
58
|
-
def should_deliver_report(args, reporting_config):
|
60
|
+
def should_deliver_report(args, reporting_config, current_est_time):
|
59
61
|
"""Given CLI arguments and the reporting configuration, determine if delivery should happen."""
|
60
62
|
valid_data_type = reporting_config['data_type'] in (args.data_type or DATA_TYPES)
|
61
63
|
enterprise_customer_specified = bool(args.enterprise_customer)
|
64
|
+
|
62
65
|
meets_schedule_requirement = is_current_time_in_schedule(
|
66
|
+
current_est_time,
|
63
67
|
reporting_config['frequency'],
|
64
68
|
reporting_config['hour_of_day'],
|
65
69
|
reporting_config['day_of_month'],
|
@@ -101,6 +105,12 @@ def process_reports():
|
|
101
105
|
LOGGER.error(f'The enterprise {args.enterprise_customer} does not have a reporting configuration.')
|
102
106
|
sys.exit(1)
|
103
107
|
|
108
|
+
# We are defining the current est time globally because we want the current time for a job
|
109
|
+
# to remain same thoughout the job. This ensures that a single report is not processed multiple times.
|
110
|
+
# See this comment for more details: https://2u-internal.atlassian.net/browse/ENT-9954?focusedCommentId=5356815
|
111
|
+
est_timezone = pytz.timezone('US/Eastern')
|
112
|
+
current_est_time = datetime.datetime.now(est_timezone)
|
113
|
+
|
104
114
|
error_raised = False
|
105
115
|
for reporting_config in reporting_configs['results']:
|
106
116
|
LOGGER.info('Checking if {}\'s reporting config for {} data in {} format is ready for processing'.format(
|
@@ -109,7 +119,7 @@ def process_reports():
|
|
109
119
|
reporting_config['report_type'],
|
110
120
|
))
|
111
121
|
|
112
|
-
if should_deliver_report(args, reporting_config):
|
122
|
+
if should_deliver_report(args, reporting_config, current_est_time):
|
113
123
|
if send_data(reporting_config):
|
114
124
|
error_raised = True
|
115
125
|
else:
|
@@ -33,4 +33,4 @@ class TestSendEnterpriseReports(unittest.TestCase):
|
|
33
33
|
Command = namedtuple("Command", "data_type enterprise_customer")
|
34
34
|
args = Command('', '')
|
35
35
|
|
36
|
-
assert should_deliver_report(args, reporting_config)
|
36
|
+
assert should_deliver_report(args, reporting_config, current_est_time)
|
@@ -165,6 +165,7 @@ class TestUtilities(unittest.TestCase):
|
|
165
165
|
est_timezone = pytz.timezone('US/Eastern')
|
166
166
|
current_est_time = datetime.datetime.now(est_timezone)
|
167
167
|
assert utils.is_current_time_in_schedule(
|
168
|
+
current_est_time,
|
168
169
|
utils.FREQUENCY_TYPE_DAILY,
|
169
170
|
current_est_time.hour,
|
170
171
|
current_est_time.day,
|
enterprise_reporting/utils.py
CHANGED
@@ -3,7 +3,6 @@ Utility functions for Enterprise Reporting.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
|
6
|
-
import datetime
|
7
6
|
import logging
|
8
7
|
import os
|
9
8
|
import re
|
@@ -16,7 +15,6 @@ from urllib.parse import parse_qs, urlparse
|
|
16
15
|
import boto3
|
17
16
|
import pgpy
|
18
17
|
import pyminizip
|
19
|
-
import pytz
|
20
18
|
from cryptography.fernet import Fernet
|
21
19
|
from fernet_fields.hkdf import derive_fernet_key
|
22
20
|
|
@@ -149,12 +147,11 @@ def send_email_with_attachment(subject, body, from_email, to_email, attachment_d
|
|
149
147
|
LOGGER.debug(result)
|
150
148
|
|
151
149
|
|
152
|
-
def is_current_time_in_schedule(frequency, hour_of_day, day_of_month=None, day_of_week=None):
|
150
|
+
def is_current_time_in_schedule(current_est_time, frequency, hour_of_day, day_of_month=None, day_of_week=None):
|
153
151
|
"""
|
154
152
|
Determine if the current time is in the range specified by this configuration's schedule.
|
155
153
|
"""
|
156
|
-
|
157
|
-
current_est_time = datetime.datetime.now(est_timezone)
|
154
|
+
|
158
155
|
current_hour_of_day = current_est_time.hour
|
159
156
|
current_day_of_week = current_est_time.weekday()
|
160
157
|
current_day_of_month = current_est_time.day
|
File without changes
|
File without changes
|
File without changes
|