channel-app 0.0.157a10__py3-none-any.whl → 0.0.157a11__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.
@@ -3,100 +3,154 @@ from typing import List
3
3
  from channel_app.core import settings
4
4
  from channel_app.core.data import CategoryTreeDto, ErrorReportDto, AttributeDto
5
5
  from channel_app.core.settings import OmnitronIntegration, ChannelIntegration
6
+ from channel_app.logs.services import LogService
6
7
  from channel_app.omnitron.constants import ContentType
7
8
 
8
9
 
9
10
  class SetupService(object):
10
11
  def create_or_update_category_tree_and_nodes(self, is_success_log=False):
11
- with OmnitronIntegration(
12
+ log_service = LogService()
13
+ log_service.create_flow(name="(Setup) Create or Update Category Tree and Nodes")
14
+
15
+ try:
16
+ with OmnitronIntegration(
12
17
  content_type=ContentType.category_tree.value) as omnitron_integration:
13
- channel_integration = ChannelIntegration()
14
- category_tree, report, _ = channel_integration.do_action(
15
- key='get_category_tree_and_nodes',
16
- batch_request=omnitron_integration.batch_request)
18
+ channel_integration = ChannelIntegration()
19
+ with log_service.step("get_category_tree_and_nodes"):
20
+ category_tree, report, _ = channel_integration.do_action(
21
+ key='get_category_tree_and_nodes',
22
+ batch_request=omnitron_integration.batch_request)
17
23
 
18
- category_tree: CategoryTreeDto
19
- report: ErrorReportDto
24
+ category_tree: CategoryTreeDto
25
+ report: ErrorReportDto
20
26
 
21
- if report and (is_success_log or not report.is_ok):
22
- omnitron_integration.do_action(
23
- key='create_error_report',
24
- objects=report)
27
+ if report and (is_success_log or not report.is_ok):
28
+ with log_service.step("create_error_report"):
29
+ omnitron_integration.do_action(
30
+ key='create_error_report',
31
+ objects=report)
25
32
 
26
- omnitron_integration.do_action(
27
- key='create_or_update_category_tree_and_nodes',
28
- objects=category_tree)
33
+ with log_service.step("create_or_update_category_tree_and_nodes"):
34
+ omnitron_integration.do_action(
35
+ key='create_or_update_category_tree_and_nodes',
36
+ objects=category_tree)
37
+ except Exception as fatal:
38
+ log_service.add_exception(fatal)
39
+ raise
40
+ finally:
41
+ log_service.save()
29
42
 
30
43
  def create_or_update_category_attributes(self, is_success_log=False):
31
- with OmnitronIntegration(
32
- content_type=ContentType.attribute.value) as omnitron_integration:
33
- channel_integration = ChannelIntegration()
34
- category_integration_actions = omnitron_integration.do_action(
35
- key='get_category_ids')
36
-
37
- for category_ia in category_integration_actions:
38
- if not category_ia.remote_id:
39
- continue
40
-
41
- category, report, data = channel_integration.do_action(
42
- key='get_category_attributes',
43
- objects=category_ia,
44
- batch_request=omnitron_integration.batch_request
45
- )
46
- if report and (is_success_log or not report.is_ok):
47
- omnitron_integration.do_action(
48
- key='create_error_report',
49
- objects=report)
44
+ log_service = LogService()
45
+ log_service.create_flow(name="Create or Update Category Attributes")
50
46
 
51
- category = category if category.attributes else None
52
- omnitron_integration.do_action(
53
- key='create_or_update_category_attributes',
54
- objects=(category_ia, category))
47
+ try:
48
+ with OmnitronIntegration(
49
+ content_type=ContentType.attribute.value) as omnitron_integration:
50
+ channel_integration = ChannelIntegration()
51
+ with log_service.step("get_category_ids"):
52
+ category_integration_actions = omnitron_integration.do_action(
53
+ key='get_category_ids')
54
+
55
+ for category_ia in category_integration_actions:
56
+ if not category_ia.remote_id:
57
+ continue
58
+
59
+ with log_service.step("get_category_attributes"):
60
+ category, report, data = channel_integration.do_action(
61
+ key='get_category_attributes',
62
+ objects=category_ia,
63
+ batch_request=omnitron_integration.batch_request
64
+ )
65
+ if report and (is_success_log or not report.is_ok):
66
+ with log_service.step("create_error_report"):
67
+ omnitron_integration.do_action(
68
+ key='create_error_report',
69
+ objects=report)
70
+
71
+ category = category if category.attributes else None
72
+ with log_service.step("create_or_update_category_attributes"):
73
+ omnitron_integration.do_action(
74
+ key='create_or_update_category_attributes',
75
+ objects=(category_ia, category))
76
+ except Exception as fatal:
77
+ log_service.add_exception(fatal)
78
+ raise
79
+ finally:
80
+ log_service.save()
55
81
 
56
82
  def create_or_update_attributes(self, is_success_log=False):
57
- with OmnitronIntegration(
83
+ log_service = LogService()
84
+ log_service.create_flow(name="Create or Update Attributes")
85
+
86
+ try:
87
+ with OmnitronIntegration(
58
88
  content_type=ContentType.attribute.value) as omnitron_integration:
59
- channel_integration = ChannelIntegration()
60
- attributes, report, data = channel_integration.do_action(
61
- key='get_attributes',
62
- batch_request=omnitron_integration.batch_request
63
- )
64
-
65
- attributes: List[AttributeDto]
66
- reports: ErrorReportDto
67
-
68
- if report and (is_success_log or not report.is_ok):
69
- omnitron_integration.do_action(
70
- key='create_error_report',
71
- objects=report)
72
-
73
- for attribute in attributes:
74
- attr = omnitron_integration.do_action(
75
- key="create_or_update_channel_attribute",
76
- objects={"name": attribute.name,
77
- "remote_id": attribute.remote_id},
78
- )[0]
79
-
80
- omnitron_integration.do_action(
81
- key="get_or_create_channel_attribute_schema",
82
- objects={"name": f"{settings.OMNITRON_CHANNEL_ID} {attribute.name} Schema"},
83
- )
84
- for attr_value in attribute.values:
85
- omnitron_integration.do_action(
86
- key="create_or_update_channel_attribute_value",
87
- objects={
88
- "attribute": attr.pk,
89
- "label": attr_value.name,
90
- "value": attr_value.remote_id,
91
- "remote_id": attr_value.remote_id})
89
+ channel_integration = ChannelIntegration()
90
+ with log_service.step("get_attributes"):
91
+ attributes, report, data = channel_integration.do_action(
92
+ key='get_attributes',
93
+ batch_request=omnitron_integration.batch_request
94
+ )
95
+
96
+ attributes: List[AttributeDto]
97
+ reports: ErrorReportDto
98
+
99
+ if report and (is_success_log or not report.is_ok):
100
+ with log_service.step("create_error_report"):
101
+ omnitron_integration.do_action(
102
+ key='create_error_report',
103
+ objects=report)
104
+
105
+ for attribute in attributes:
106
+ with log_service.step("create_or_update_channel_attribute"):
107
+ attr = omnitron_integration.do_action(
108
+ key="create_or_update_channel_attribute",
109
+ objects={"name": attribute.name,
110
+ "remote_id": attribute.remote_id},
111
+ )[0]
112
+
113
+ with log_service.step("get_or_create_channel_attribute_schema"):
114
+ omnitron_integration.do_action(
115
+ key="get_or_create_channel_attribute_schema",
116
+ objects={"name": f"{settings.OMNITRON_CHANNEL_ID} {attribute.name} Schema"},
117
+ )
118
+ for attr_value in attribute.values:
119
+ with log_service.step("create_or_update_channel_attribute_value", metadata={
120
+ "attribute_name": attr_value.name,
121
+ "remote_id": attr_value.remote_id
122
+ }):
123
+ omnitron_integration.do_action(
124
+ key="create_or_update_channel_attribute_value",
125
+ objects={
126
+ "attribute": attr.pk,
127
+ "label": attr_value.name,
128
+ "value": attr_value.remote_id,
129
+ "remote_id": attr_value.remote_id})
130
+ except Exception as fatal:
131
+ log_service.add_exception(fatal)
132
+ raise
133
+ finally:
134
+ log_service.save()
92
135
 
93
136
  def update_channel_conf_schema(self):
94
- with OmnitronIntegration(
95
- content_type=ContentType.channel.value) as omnitron_integration:
96
- channel_integration = ChannelIntegration()
97
- schema, _, _ = channel_integration.do_action(
98
- key='get_channel_conf_schema',
99
- batch_request=omnitron_integration.batch_request)
137
+ log_service = LogService()
138
+ log_service.create_flow(name="Update Channel Conf Schema")
100
139
 
101
- omnitron_integration.do_action(key="update_channel_conf_schema",
102
- objects=schema)
140
+ try:
141
+ with OmnitronIntegration(
142
+ content_type=ContentType.channel.value) as omnitron_integration:
143
+ channel_integration = ChannelIntegration()
144
+ with log_service.step("get_channel_conf_schema"):
145
+ schema, _, _ = channel_integration.do_action(
146
+ key='get_channel_conf_schema',
147
+ batch_request=omnitron_integration.batch_request)
148
+
149
+ with log_service.step("update_channel_conf_schema"):
150
+ omnitron_integration.do_action(key="update_channel_conf_schema",
151
+ objects=schema)
152
+ except Exception as fatal:
153
+ log_service.add_exception(fatal)
154
+ raise
155
+ finally:
156
+ log_service.save()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: channel-app
3
- Version: 0.0.157a10
3
+ Version: 0.0.157a11
4
4
  Summary: Channel app for Sales Channels
5
5
  Home-page: https://github.com/akinon/channel_app
6
6
  Author: akinonteam
@@ -3,17 +3,17 @@ channel_app/alembic.ini,sha256=wUP23krSqffP4Gmo-dXuoceqwi8f7RJaC--7cR-Sfsg,3751
3
3
  channel_app/migrate.py,sha256=jbeWNvgtSbGk9dKXTgM_rGr1NZf3trEfjJvKVhvNmHE,532
4
4
  channel_app/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  channel_app/app/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- channel_app/app/order/service.py,sha256=GZ8StGwvICtI0DWMtYFq1mB9GPdojNpjCh9oVrHlHJE,22366
6
+ channel_app/app/order/service.py,sha256=DZyBOkXSF6xTZzzSWFSrKuWK0eAqaMcYp4jbNG_5vWA,31952
7
7
  channel_app/app/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- channel_app/app/product/service.py,sha256=7DZF-Vtoaf5eKT1m_ccEOAqUxWSO7Csop4HEtJmcrvw,10646
8
+ channel_app/app/product/service.py,sha256=i_vw303fxX0zYtNssInct_BRFjpvHIn7YfRMgmh2K5w,18059
9
9
  channel_app/app/product_image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- channel_app/app/product_image/service.py,sha256=3snVh07Q7rDW63yl_KJ6COmndxRkXMfoCK2g7eYGtuM,6202
10
+ channel_app/app/product_image/service.py,sha256=RMc-avIcTT-MlWvtU6Np_Gcq5FDJ3m9hbCclQYEVsiQ,10372
11
11
  channel_app/app/product_price/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- channel_app/app/product_price/service.py,sha256=lbFnEhED40ImFAQ-7-UMGRjLJaTUKVndexcLlMQxknY,13836
12
+ channel_app/app/product_price/service.py,sha256=mF2HCj9vyuAcj524ZcUhLE08wU49-Nl_dWzY7g7sDKI,21300
13
13
  channel_app/app/product_stock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- channel_app/app/product_stock/service.py,sha256=6oS4tkWkkVAwEMFWqn0uc0zZgByoxP69-TfTnLMT954,13700
14
+ channel_app/app/product_stock/service.py,sha256=8wewnWmjNycUEVaPHLLzpX4q_x9uqf2P39JV1Ke-okw,18992
15
15
  channel_app/app/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- channel_app/app/setup/service.py,sha256=d53IKrQjahNZvxCaZAmXo2VUKBMM6-wm-P9I9tBTYOY,4553
16
+ channel_app/app/setup/service.py,sha256=Pymo7-m6ygcUdJKaDFUHYljTIXqZleeiZ-XAkOWuoxs,7386
17
17
  channel_app/channel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  channel_app/channel/integration.py,sha256=fDx5nxa6w-4gMucU7xo_OTOkqPHdBUHeDtuzeaDJlXE,3769
19
19
  channel_app/channel/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,7 +71,7 @@ channel_app/omnitron/commands/tests/test_product_images.py,sha256=y6tmiJ00kd2GTq
71
71
  channel_app/omnitron/commands/tests/test_product_prices.py,sha256=5HPX9PmjGw6gk3oNrwtWLqdrOkfeNx1mYP-pYwOesZU,3496
72
72
  channel_app/omnitron/commands/tests/test_product_stocks.py,sha256=q4RGlrCNUUJyN5CBL1fzrvdd4Q3xt816mbMRQT0XEd0,3496
73
73
  channel_app/omnitron/commands/tests/test_products.py,sha256=uj5KLaubY3XNu0hidOH-u-Djfboe81Hj7-lP--01Le0,103494
74
- channel_app-0.0.157a10.dist-info/METADATA,sha256=XAM_GiW9PN_9TvYw_QziOkJKPRKr5QGgb6L6RxFnK6g,442
75
- channel_app-0.0.157a10.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
76
- channel_app-0.0.157a10.dist-info/top_level.txt,sha256=JT-gM6L5Cwxr1xEoN7NHrREDs-d6iGFGfRnK-NrJ3tU,12
77
- channel_app-0.0.157a10.dist-info/RECORD,,
74
+ channel_app-0.0.157a11.dist-info/METADATA,sha256=-OeKhBxlGFeWqTLjnJIzCt1P1IgyK8WnTUvtLhICtec,442
75
+ channel_app-0.0.157a11.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
76
+ channel_app-0.0.157a11.dist-info/top_level.txt,sha256=JT-gM6L5Cwxr1xEoN7NHrREDs-d6iGFGfRnK-NrJ3tU,12
77
+ channel_app-0.0.157a11.dist-info/RECORD,,