unrealon 1.1.6__py3-none-any.whl → 2.0.5__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.
Files changed (144) hide show
  1. {unrealon-1.1.6.dist-info/licenses → unrealon-2.0.5.dist-info}/LICENSE +1 -1
  2. unrealon-2.0.5.dist-info/METADATA +491 -0
  3. unrealon-2.0.5.dist-info/RECORD +128 -0
  4. {unrealon-1.1.6.dist-info → unrealon-2.0.5.dist-info}/WHEEL +2 -1
  5. unrealon-2.0.5.dist-info/entry_points.txt +3 -0
  6. unrealon-2.0.5.dist-info/top_level.txt +3 -0
  7. unrealon_browser/__init__.py +5 -6
  8. unrealon_browser/cli/browser_cli.py +18 -9
  9. unrealon_browser/cli/interactive_mode.py +13 -4
  10. unrealon_browser/core/browser_manager.py +29 -16
  11. unrealon_browser/dto/__init__.py +21 -0
  12. unrealon_browser/dto/bot_detection.py +175 -0
  13. unrealon_browser/dto/models/config.py +9 -3
  14. unrealon_browser/managers/__init__.py +1 -1
  15. unrealon_browser/managers/logger_bridge.py +1 -4
  16. unrealon_browser/stealth/__init__.py +27 -0
  17. unrealon_browser/stealth/bypass_techniques.pyc +0 -0
  18. unrealon_browser/stealth/manager.pyc +0 -0
  19. unrealon_browser/stealth/nodriver_stealth.pyc +0 -0
  20. unrealon_browser/stealth/playwright_stealth.pyc +0 -0
  21. unrealon_browser/stealth/scanner_tester.pyc +0 -0
  22. unrealon_browser/stealth/undetected_chrome.pyc +0 -0
  23. unrealon_core/__init__.py +172 -0
  24. unrealon_core/config/__init__.py +16 -0
  25. unrealon_core/config/environment.py +151 -0
  26. unrealon_core/config/urls.py +94 -0
  27. unrealon_core/enums/__init__.py +24 -0
  28. unrealon_core/enums/status.py +216 -0
  29. unrealon_core/enums/types.py +240 -0
  30. unrealon_core/error_handling/__init__.py +45 -0
  31. unrealon_core/error_handling/circuit_breaker.py +292 -0
  32. unrealon_core/error_handling/error_context.py +324 -0
  33. unrealon_core/error_handling/recovery.py +371 -0
  34. unrealon_core/error_handling/retry.py +268 -0
  35. unrealon_core/exceptions/__init__.py +46 -0
  36. unrealon_core/exceptions/base.py +292 -0
  37. unrealon_core/exceptions/communication.py +22 -0
  38. unrealon_core/exceptions/driver.py +11 -0
  39. unrealon_core/exceptions/proxy.py +11 -0
  40. unrealon_core/exceptions/task.py +12 -0
  41. unrealon_core/exceptions/validation.py +17 -0
  42. unrealon_core/models/__init__.py +79 -0
  43. unrealon_core/models/arq_context.py +252 -0
  44. unrealon_core/models/arq_responses.py +125 -0
  45. unrealon_core/models/base.py +291 -0
  46. unrealon_core/models/bridge_stats.py +58 -0
  47. unrealon_core/models/communication.py +39 -0
  48. unrealon_core/models/connection_stats.py +47 -0
  49. unrealon_core/models/driver.py +30 -0
  50. unrealon_core/models/driver_details.py +98 -0
  51. unrealon_core/models/logging.py +28 -0
  52. unrealon_core/models/task.py +21 -0
  53. unrealon_core/models/typed_responses.py +210 -0
  54. unrealon_core/models/websocket/__init__.py +91 -0
  55. unrealon_core/models/websocket/base.py +49 -0
  56. unrealon_core/models/websocket/config.py +200 -0
  57. unrealon_core/models/websocket/driver.py +215 -0
  58. unrealon_core/models/websocket/errors.py +138 -0
  59. unrealon_core/models/websocket/heartbeat.py +100 -0
  60. unrealon_core/models/websocket/logging.py +261 -0
  61. unrealon_core/models/websocket/proxy.py +496 -0
  62. unrealon_core/models/websocket/tasks.py +275 -0
  63. unrealon_core/models/websocket/utils.py +153 -0
  64. unrealon_core/models/websocket_session.py +144 -0
  65. unrealon_core/monitoring/__init__.py +43 -0
  66. unrealon_core/monitoring/alerts.py +398 -0
  67. unrealon_core/monitoring/dashboard.py +307 -0
  68. unrealon_core/monitoring/health_check.py +354 -0
  69. unrealon_core/monitoring/metrics.py +352 -0
  70. unrealon_core/utils/__init__.py +11 -0
  71. unrealon_core/utils/time.py +61 -0
  72. unrealon_core/version.py +219 -0
  73. unrealon_driver/__init__.py +90 -51
  74. unrealon_driver/core_module/__init__.py +34 -0
  75. unrealon_driver/core_module/base.py +184 -0
  76. unrealon_driver/core_module/config.py +30 -0
  77. unrealon_driver/core_module/event_manager.py +127 -0
  78. unrealon_driver/core_module/protocols.py +98 -0
  79. unrealon_driver/core_module/registry.py +146 -0
  80. unrealon_driver/decorators/__init__.py +15 -0
  81. unrealon_driver/decorators/retry.py +117 -0
  82. unrealon_driver/decorators/schedule.py +137 -0
  83. unrealon_driver/decorators/task.py +61 -0
  84. unrealon_driver/decorators/timing.py +132 -0
  85. unrealon_driver/driver/__init__.py +20 -0
  86. unrealon_driver/driver/communication/__init__.py +10 -0
  87. unrealon_driver/driver/communication/session.py +203 -0
  88. unrealon_driver/driver/communication/websocket_client.py +205 -0
  89. unrealon_driver/driver/core/__init__.py +10 -0
  90. unrealon_driver/driver/core/config.py +175 -0
  91. unrealon_driver/driver/core/driver.py +221 -0
  92. unrealon_driver/driver/factory/__init__.py +9 -0
  93. unrealon_driver/driver/factory/manager_factory.py +130 -0
  94. unrealon_driver/driver/lifecycle/__init__.py +11 -0
  95. unrealon_driver/driver/lifecycle/daemon.py +76 -0
  96. unrealon_driver/driver/lifecycle/initialization.py +97 -0
  97. unrealon_driver/driver/lifecycle/shutdown.py +48 -0
  98. unrealon_driver/driver/monitoring/__init__.py +9 -0
  99. unrealon_driver/driver/monitoring/health.py +63 -0
  100. unrealon_driver/driver/utilities/__init__.py +10 -0
  101. unrealon_driver/driver/utilities/logging.py +51 -0
  102. unrealon_driver/driver/utilities/serialization.py +61 -0
  103. unrealon_driver/managers/__init__.py +32 -0
  104. unrealon_driver/managers/base.py +174 -0
  105. unrealon_driver/managers/browser.py +98 -0
  106. unrealon_driver/managers/cache.py +116 -0
  107. unrealon_driver/managers/http.py +107 -0
  108. unrealon_driver/managers/logger.py +286 -0
  109. unrealon_driver/managers/proxy.py +99 -0
  110. unrealon_driver/managers/registry.py +87 -0
  111. unrealon_driver/managers/threading.py +54 -0
  112. unrealon_driver/managers/update.py +107 -0
  113. unrealon_driver/utils/__init__.py +9 -0
  114. unrealon_driver/utils/time.py +10 -0
  115. unrealon-1.1.6.dist-info/METADATA +0 -625
  116. unrealon-1.1.6.dist-info/RECORD +0 -55
  117. unrealon-1.1.6.dist-info/entry_points.txt +0 -9
  118. unrealon_browser/managers/stealth.py +0 -388
  119. unrealon_driver/README.md +0 -0
  120. unrealon_driver/exceptions.py +0 -33
  121. unrealon_driver/html_analyzer/__init__.py +0 -32
  122. unrealon_driver/html_analyzer/cleaner.py +0 -657
  123. unrealon_driver/html_analyzer/config.py +0 -64
  124. unrealon_driver/html_analyzer/manager.py +0 -247
  125. unrealon_driver/html_analyzer/models.py +0 -115
  126. unrealon_driver/html_analyzer/websocket_analyzer.py +0 -157
  127. unrealon_driver/models/__init__.py +0 -31
  128. unrealon_driver/models/websocket.py +0 -98
  129. unrealon_driver/parser/__init__.py +0 -36
  130. unrealon_driver/parser/cli_manager.py +0 -142
  131. unrealon_driver/parser/daemon_manager.py +0 -403
  132. unrealon_driver/parser/managers/__init__.py +0 -25
  133. unrealon_driver/parser/managers/config.py +0 -293
  134. unrealon_driver/parser/managers/error.py +0 -412
  135. unrealon_driver/parser/managers/result.py +0 -321
  136. unrealon_driver/parser/parser_manager.py +0 -458
  137. unrealon_driver/smart_logging/__init__.py +0 -24
  138. unrealon_driver/smart_logging/models.py +0 -44
  139. unrealon_driver/smart_logging/smart_logger.py +0 -406
  140. unrealon_driver/smart_logging/unified_logger.py +0 -525
  141. unrealon_driver/websocket/__init__.py +0 -31
  142. unrealon_driver/websocket/client.py +0 -249
  143. unrealon_driver/websocket/config.py +0 -188
  144. unrealon_driver/websocket/manager.py +0 -90
@@ -1,321 +0,0 @@
1
- """
2
- Result Manager - Automatic result tracking and metrics with Pydantic v2
3
-
4
- Strict compliance with CRITICAL_REQUIREMENTS.md:
5
- - No Dict[str, Any] usage
6
- - Complete type annotations
7
- - Pydantic v2 models everywhere
8
- - Custom exception hierarchy
9
- """
10
-
11
- from typing import Optional, List, TypeVar, Generic
12
- from datetime import datetime
13
- from pydantic import BaseModel, Field, ConfigDict, field_validator
14
- from enum import Enum
15
-
16
-
17
- T = TypeVar('T', bound=BaseModel)
18
-
19
-
20
- class OperationStatus(str, Enum):
21
- """Operation status enumeration"""
22
- PENDING = "pending"
23
- RUNNING = "running"
24
- COMPLETED = "completed"
25
- FAILED = "failed"
26
- CANCELLED = "cancelled"
27
-
28
-
29
- class ParseMetrics(BaseModel):
30
- """Parse operation metrics with strict typing"""
31
- model_config = ConfigDict(
32
- validate_assignment=True,
33
- extra="forbid"
34
- )
35
-
36
- started_at: datetime = Field(
37
- default_factory=datetime.now,
38
- description="Operation start time"
39
- )
40
- completed_at: Optional[datetime] = Field(
41
- default=None,
42
- description="Operation completion time"
43
- )
44
- duration_seconds: Optional[float] = Field(
45
- default=None,
46
- ge=0.0,
47
- description="Operation duration in seconds"
48
- )
49
- pages_processed: int = Field(
50
- default=0,
51
- ge=0,
52
- description="Number of pages processed"
53
- )
54
- items_found: int = Field(
55
- default=0,
56
- ge=0,
57
- description="Number of items found"
58
- )
59
- errors_count: int = Field(
60
- default=0,
61
- ge=0,
62
- description="Number of errors encountered"
63
- )
64
- warnings_count: int = Field(
65
- default=0,
66
- ge=0,
67
- description="Number of warnings encountered"
68
- )
69
- status: OperationStatus = Field(
70
- default=OperationStatus.PENDING,
71
- description="Current operation status"
72
- )
73
-
74
- def complete(self, status: OperationStatus = OperationStatus.COMPLETED) -> None:
75
- """Mark operation as completed"""
76
- self.completed_at = datetime.now()
77
- if self.completed_at and self.started_at:
78
- self.duration_seconds = (self.completed_at - self.started_at).total_seconds()
79
- self.status = status
80
-
81
-
82
- class ParseResult(BaseModel, Generic[T]):
83
- """Generic parse result with metrics and strict typing"""
84
- model_config = ConfigDict(
85
- validate_assignment=True,
86
- extra="forbid"
87
- )
88
-
89
- data: List[T] = Field(
90
- default_factory=list,
91
- description="Parsed data items"
92
- )
93
- metrics: ParseMetrics = Field(
94
- default_factory=ParseMetrics,
95
- description="Operation metrics"
96
- )
97
- source_urls: List[str] = Field(
98
- default_factory=list,
99
- description="Source URLs processed"
100
- )
101
- parser_id: str = Field(
102
- ...,
103
- min_length=1,
104
- description="Parser identifier"
105
- )
106
- error_message: Optional[str] = Field(
107
- default=None,
108
- description="Error message if operation failed"
109
- )
110
- warnings: List[str] = Field(
111
- default_factory=list,
112
- description="Warning messages"
113
- )
114
-
115
- @field_validator('source_urls')
116
- @classmethod
117
- def validate_urls(cls, v: List[str]) -> List[str]:
118
- """Validate URL format"""
119
- for url in v:
120
- if not url.startswith(('http://', 'https://')):
121
- raise ValueError(f"Invalid URL format: {url}")
122
- return v
123
-
124
- def model_post_init(self, __context) -> None:
125
- """Update metrics after initialization"""
126
- self.metrics.items_found = len(self.data)
127
-
128
-
129
- class ResultManagerError(Exception):
130
- """Base exception for result manager errors"""
131
- def __init__(self, message: str, operation: str, details: Optional[dict[str, str]] = None):
132
- self.message = message
133
- self.operation = operation
134
- self.details = details or {}
135
- super().__init__(message)
136
-
137
-
138
- class OperationNotFoundError(ResultManagerError):
139
- """Raised when operation is not found"""
140
- pass
141
-
142
-
143
- class InvalidOperationStateError(ResultManagerError):
144
- """Raised when operation is in invalid state"""
145
- pass
146
-
147
-
148
- class ResultManager:
149
- """
150
- 🎯 Result Manager - Automatic result tracking and metrics
151
-
152
- Features:
153
- - Automatic timing and metrics
154
- - Result aggregation
155
- - Error tracking
156
- - Performance monitoring
157
- - Type-safe operations
158
- """
159
-
160
- def __init__(self, parser_id: str):
161
- if not parser_id.strip():
162
- raise ValueError("Parser ID cannot be empty")
163
-
164
- self.parser_id: str = parser_id
165
- self._current_metrics: Optional[ParseMetrics] = None
166
- self._results_history: List[ParseResult] = []
167
-
168
- def start_operation(self) -> ParseMetrics:
169
- """Start tracking a new parse operation"""
170
- if self._current_metrics and self._current_metrics.status == OperationStatus.RUNNING:
171
- raise InvalidOperationStateError(
172
- message="Cannot start new operation while another is running",
173
- operation="start_operation",
174
- details={"current_status": self._current_metrics.status.value}
175
- )
176
-
177
- self._current_metrics = ParseMetrics(status=OperationStatus.RUNNING)
178
- return self._current_metrics
179
-
180
- def track_page(self) -> None:
181
- """Track a processed page"""
182
- if not self._current_metrics:
183
- raise OperationNotFoundError(
184
- message="No operation in progress",
185
- operation="track_page"
186
- )
187
-
188
- self._current_metrics.pages_processed += 1
189
-
190
- def track_error(self) -> None:
191
- """Track an error"""
192
- if not self._current_metrics:
193
- raise OperationNotFoundError(
194
- message="No operation in progress",
195
- operation="track_error"
196
- )
197
-
198
- self._current_metrics.errors_count += 1
199
-
200
- def track_warning(self) -> None:
201
- """Track a warning"""
202
- if not self._current_metrics:
203
- raise OperationNotFoundError(
204
- message="No operation in progress",
205
- operation="track_warning"
206
- )
207
-
208
- self._current_metrics.warnings_count += 1
209
-
210
- def complete_operation(
211
- self,
212
- data: List[T],
213
- source_urls: List[str],
214
- success: bool = True,
215
- error_message: Optional[str] = None,
216
- warnings: Optional[List[str]] = None
217
- ) -> ParseResult[T]:
218
- """Complete the current operation and return result"""
219
- if not self._current_metrics:
220
- raise OperationNotFoundError(
221
- message="No operation in progress",
222
- operation="complete_operation"
223
- )
224
-
225
- status = OperationStatus.COMPLETED if success else OperationStatus.FAILED
226
- self._current_metrics.complete(status)
227
-
228
- result = ParseResult[T](
229
- data=data,
230
- metrics=self._current_metrics,
231
- source_urls=source_urls,
232
- parser_id=self.parser_id,
233
- error_message=error_message,
234
- warnings=warnings or []
235
- )
236
-
237
- self._results_history.append(result)
238
- self._current_metrics = None
239
-
240
- return result
241
-
242
- def cancel_operation(self, reason: str) -> None:
243
- """Cancel the current operation"""
244
- if not self._current_metrics:
245
- raise OperationNotFoundError(
246
- message="No operation in progress",
247
- operation="cancel_operation"
248
- )
249
-
250
- self._current_metrics.complete(OperationStatus.CANCELLED)
251
-
252
- # Create cancelled result
253
- result = ParseResult[BaseModel](
254
- data=[],
255
- metrics=self._current_metrics,
256
- source_urls=[],
257
- parser_id=self.parser_id,
258
- error_message=f"Operation cancelled: {reason}"
259
- )
260
-
261
- self._results_history.append(result)
262
- self._current_metrics = None
263
-
264
- def get_current_metrics(self) -> Optional[ParseMetrics]:
265
- """Get current operation metrics"""
266
- return self._current_metrics
267
-
268
- def get_history(self) -> List[ParseResult]:
269
- """Get results history"""
270
- return [
271
- ParseResult.model_validate(result.model_dump())
272
- for result in self._results_history
273
- ]
274
-
275
- def get_stats(self) -> dict[str, float]:
276
- """Get overall statistics"""
277
- if not self._results_history:
278
- return {
279
- "total_operations": 0.0,
280
- "success_rate": 0.0,
281
- "average_duration": 0.0,
282
- "total_items": 0.0,
283
- "total_pages": 0.0
284
- }
285
-
286
- successful = [
287
- r for r in self._results_history
288
- if r.metrics.status == OperationStatus.COMPLETED
289
- ]
290
-
291
- total_items = sum(r.metrics.items_found for r in self._results_history)
292
- total_pages = sum(r.metrics.pages_processed for r in self._results_history)
293
-
294
- durations = [
295
- r.metrics.duration_seconds
296
- for r in self._results_history
297
- if r.metrics.duration_seconds is not None
298
- ]
299
- avg_duration = sum(durations) / len(durations) if durations else 0.0
300
-
301
- return {
302
- "total_operations": float(len(self._results_history)),
303
- "successful_operations": float(len(successful)),
304
- "failed_operations": float(len(self._results_history) - len(successful)),
305
- "success_rate": len(successful) / len(self._results_history) * 100.0,
306
- "total_items_found": float(total_items),
307
- "total_pages_processed": float(total_pages),
308
- "average_duration_seconds": round(avg_duration, 2),
309
- "items_per_operation": total_items / len(self._results_history) if self._results_history else 0.0
310
- }
311
-
312
- def clear_history(self) -> None:
313
- """Clear results history"""
314
- self._results_history.clear()
315
-
316
- def get_recent_results(self, limit: int = 10) -> List[ParseResult]:
317
- """Get recent results with limit"""
318
- if limit <= 0:
319
- raise ValueError("Limit must be positive")
320
-
321
- return self._results_history[-limit:]