Referencia de la API
⚠️ Nota / Note:
Esta página está disponible solo en Inglés temporalmente. This page is currently available in English only.Proyecto compatible con Eventlet y GEvent.
business_logic
program_manager
AttendancesManager
Bases: AttendancesManagerBase
Source code in src\business_logic\program_manager.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
__init__()
Initializes the ProgramManager instance.
This constructor sets up the initial state of the ProgramManager by creating a new instance of SharedState and passing it to the parent class initializer.
Attributes:
Name | Type | Description |
---|---|---|
state |
SharedState
|
The shared state object used to manage |
Source code in src\business_logic\program_manager.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
manage_attendances_of_one_device(device)
Manages the attendance data for a single device. This method handles the connection to a device, retrieves attendance data, processes it, and updates the device's state and attendance records. It also manages error handling and ensures proper cleanup of resources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
Device
|
The device object representing the attendance device to be managed. |
required |
Workflow
- Establishes a connection to the device using
ConnectionManager
. - Retrieves attendance data from the device.
- Formats the attendance data and handles any errors during formatting.
- Clears attendance data on the device based on the
clear_attendance
flag. - Updates the device's model name if possible.
- Processes individual and global attendance records.
- Synchronizes the device's time and handles time-related errors.
- Updates the attendance count for the device in a shared dictionary.
- Ensures proper disconnection from the device and updates progress tracking.
Logging
- Logs debug information for connection initiation, attendance processing, and cleanup.
- Logs errors and warnings for failed connections and other issues.
Returns:
Type | Description |
---|---|
None |
Source code in src\business_logic\program_manager.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
manage_devices_attendances(selected_ips, emit_progress=None)
Manages the attendance records for the specified devices. This method processes attendance data for the devices with the given IPs. It also handles configuration settings related to clearing attendance data and updates the configuration file if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_ips
|
list[str]
|
A list of IP addresses of the devices to manage. |
required |
emit_progress
|
Callable
|
A callable function to emit progress updates. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
int
|
The count of attendances processed. |
Side Effects
- Reads configuration settings from 'config.ini'.
- Resets the internal state before processing.
- Updates the 'force_clear_attendance' setting in 'config.ini' if it was set to True.
Source code in src\business_logic\program_manager.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
ConnectionsInfo
Bases: OperationManager
Source code in src\business_logic\program_manager.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
__init__()
Initializes the ProgramManager instance.
This constructor sets up the shared state and initializes a dictionary to store connection information. It also calls the superclass initializer with the shared state.
Attributes:
Name | Type | Description |
---|---|---|
state |
SharedState
|
An instance of SharedState to manage shared resources. |
connections_info |
dict[str, ConnectionInfo]
|
A dictionary mapping connection identifiers to their respective ConnectionInfo objects. |
Source code in src\business_logic\program_manager.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
obtain_connection_info(device)
Establishes a connection to a device, retrieves its connection information, and updates the connection status.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
Device
|
The device object containing information such as IP, communication type, and model name. |
required |
Raises:
Type | Description |
---|---|
ConnectionFailedError
|
If the connection to the device fails due to a network error. |
BaseError
|
If any other unexpected exception occurs during the process. |
Workflow
- Initializes a connection manager for the device using its IP and communication type.
- Attempts to connect to the device with retries.
- Pings the device to verify connectivity.
- If the ping is successful, retrieves device information and updates the connection info.
- If the ping fails or a network error occurs, marks the connection as failed and raises a ConnectionFailedError.
- Updates the shared connection information dictionary with the device's connection status.
- Ensures the connection is properly disconnected in the
finally
block. - Updates the progress tracker and logs the completion of the process.
Note
This method uses a lock to ensure thread-safe updates to the shared
connections_info
dictionary.
Source code in src\business_logic\program_manager.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
obtain_connections_info(selected_ips, emit_progress=None)
Obtains connection information for a list of selected IPs and manages the threading process to retrieve this information from devices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_ips
|
list[str]
|
A list of IP addresses to connect to and retrieve information from. |
required |
emit_progress
|
Callable
|
A callable function to emit progress updates during the operation. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary containing connection information for the devices if any connections were successfully established. Returns an empty dictionary if no connections were made. |
Source code in src\business_logic\program_manager.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
HourManager
Bases: HourManagerBase
Source code in src\business_logic\program_manager.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
__init__()
Initializes the ProgramManager instance.
This constructor sets up the initial state of the ProgramManager by creating a new instance of SharedState and passing it to the parent class initializer.
Attributes:
Name | Type | Description |
---|---|---|
state |
SharedState
|
The shared state object used to manage |
Source code in src\business_logic\program_manager.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
manage_hour_devices(selected_ips, emit_progress=None)
Synchronizes the time on a list of devices identified by their IP addresses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_ips
|
list[str]
|
A list of IP addresses of the devices to update. |
required |
emit_progress
|
Callable
|
A callback function to emit progress updates. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Any
|
The result of the |
Source code in src\business_logic\program_manager.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
update_device_time_of_one_device(device)
Updates the device time for a single device.
This method attempts to connect to the specified device, update its time, and handle any errors that may occur during the process. It also updates the device's error status and progress tracking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
Device
|
The device object containing information such as IP address, communication type, model name, and point. |
required |
Raises:
Type | Description |
---|---|
ConnectionFailedError
|
If the connection to the device fails. |
BatteryFailingError
|
If the device's battery is failing and its time cannot be updated. |
BaseError
|
For any other unexpected errors, with error code 3000. |
Notes
- Uses a lock to ensure thread-safe updates to the
devices_errors
dictionary. - Updates the battery status if an outdated time error occurs.
- Ensures the connection is properly closed in the
finally
block. - Tracks progress using the
ProgressTracker
class.
Source code in src\business_logic\program_manager.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
ProgressTracker
Source code in src\business_logic\program_manager.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
__init__(state, emit_progress)
Initializes the ProgramManager instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
SharedState
|
The shared state object used to manage and share data across components. |
required |
emit_progress
|
Callable
|
A callable function used to emit progress updates. |
required |
Source code in src\business_logic\program_manager.py
37 38 39 40 41 42 43 44 45 46 |
|
update(device)
Updates the progress of processing a device and emits progress information if applicable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
Device
|
The device object being processed. |
required |
Behavior
- Increments the count of processed devices in the current state.
- Calculates the progress percentage based on the total devices.
- Emits progress information including:
- Percent progress.
- IP address of the device being processed.
- Number of processed devices.
- Total number of devices.
- Logs the progress details for debugging purposes.
Source code in src\business_logic\program_manager.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
RestartManager
Bases: OperationManager
Source code in src\business_logic\program_manager.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
__init__()
Initializes the ProgramManager instance.
This constructor sets up the shared state and initializes a dictionary to track device errors. It also calls the superclass initializer with the shared state.
Attributes:
Name | Type | Description |
---|---|---|
state |
SharedState
|
An instance of SharedState to manage shared data. |
devices_errors |
dict[str, dict[str, bool]]
|
A dictionary to store error states for devices, where the keys are device identifiers and the values are dictionaries mapping error types to their boolean statuses. |
Source code in src\business_logic\program_manager.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
restart_device(device)
Restart the specified device by establishing a connection, sending a restart command, and handling any potential errors during the process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
Device
|
The device object containing details such as IP address, communication type, and model information. |
required |
Raises:
Type | Description |
---|---|
ConnectionFailedError
|
If the connection to the device fails. |
BaseError
|
For any other unexpected errors during the restart process. |
Notes
- Uses a connection manager to handle the device connection and restart operation.
- Updates the device error state in a thread-safe manner using a lock.
- Ensures the connection is properly closed in the
finally
block. - Tracks progress using the
ProgressTracker
class.
Source code in src\business_logic\program_manager.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
restart_devices(selected_ips, emit_progress=None)
Restarts the devices specified by their IP addresses. This method clears any existing device errors, resets the state, and manages threads to restart the specified devices. If any errors occur during the restart process, they are collected and returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_ips
|
list[str]
|
A list of IP addresses of the devices to restart. |
required |
emit_progress
|
Callable
|
A callable function to emit progress updates. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary containing errors encountered during the restart process, if any. If no errors occur, an empty dictionary is returned. |
Source code in src\business_logic\program_manager.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
ui
base_dialog
BaseDialog
Bases: QDialog
Source code in src\ui\base_dialog.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
__init__(parent=None, window_title='')
Initializes the base dialog window with the specified parent and window title.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for the dialog. Defaults to None. |
None
|
window_title
|
str
|
The title of the dialog window. Defaults to an empty string. |
''
|
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the exception message. |
Source code in src\ui\base_dialog.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
adjust_size_to_table()
Adjusts the size of the dialog window to fit the content of the table widget. This method resizes the columns of the table widget to fit their contents and calculates the required width and height of the table based on its content. It ensures that the dialog window does not exceed the available screen height, applying a margin if necessary. Finally, it resizes the dialog window to accommodate the adjusted table dimensions.
Notes
- An extra width adjustment is added to account for margins and the button bar.
- The height is capped to fit within the available screen height minus a margin.
Source code in src\ui\base_dialog.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
center_window()
Centers the window on the current screen.
This method calculates the available geometry of the current screen and moves the window to the center of the screen.
Returns:
Type | Description |
---|---|
None |
Source code in src\ui\base_dialog.py
85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
base_select_devices_dialog
SelectDevicesDialog
Bases: BaseDialog
Source code in src\ui\base_select_devices_dialog.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
__init__(parent=None, op_function=None, window_title='')
Initializes the BaseSelectDevicesDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for this dialog. Defaults to None. |
None
|
op_function
|
callable
|
A callable operation function to be executed. Defaults to None. |
None
|
window_title
|
str
|
The title of the dialog window. Defaults to an empty string. |
''
|
Attributes:
Name | Type | Description |
---|---|---|
op_function |
callable
|
Stores the operation function passed as an argument. |
file_path |
str
|
The file path to the "info_devices.txt" file, located in the current working directory. |
data |
list
|
A list to store device-related data. |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the error message. |
Source code in src\ui\base_select_devices_dialog.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
cleanup_thread()
Cleans up the operation thread by scheduling its deletion.
This method ensures that the op_thread
object is properly deleted
using the deleteLater()
method, which schedules the object for
deletion once it is safe to do so, typically after all pending events
have been processed.
Source code in src\ui\base_select_devices_dialog.py
289 290 291 292 293 294 295 296 297 298 |
|
column_exists(column_name)
Checks if a column with the specified name exists in the table widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_name
|
str
|
The name of the column to check for existence. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the column exists, False otherwise. |
Source code in src\ui\base_select_devices_dialog.py
315 316 317 318 319 320 321 322 323 324 325 326 |
|
deselect_all_rows()
Deselects all rows in the table widget.
This method clears the current selection in the table widget, ensuring that no rows remain selected.
Source code in src\ui\base_select_devices_dialog.py
379 380 381 382 383 384 385 386 |
|
ensure_column_exists(column_name)
Ensures that a column with the specified name exists in the table widget. If the column does not exist, it creates a new column with the given name. If the column already exists, it retrieves its index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_name
|
str
|
The name of the column to ensure exists. |
required |
Returns:
Type | Description |
---|---|
int
|
The index of the column in the table widget. |
Source code in src\ui\base_select_devices_dialog.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
get_column_number(column_name)
Retrieves the index of a column in the table widget based on the column's name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_name
|
str
|
The name of the column to search for. |
required |
Returns:
Type | Description |
---|---|
int
|
The index of the column if found, otherwise -1. |
Source code in src\ui\base_select_devices_dialog.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
init_ui(header_labels)
Initializes the user interface for the device selection dialog.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
header_labels
|
list
|
A list of strings representing the column headers for the table. |
required |
UI Components
- QVBoxLayout: Main layout for the dialog.
- QTableWidget: Table widget to display devices with configurable columns and sorting enabled.
- QPushButton: Buttons for updating data, selecting all rows, and deselecting all rows.
- QLabel: Label to display a message when data is being updated.
- QProgressBar: Progress bar to indicate the progress of data updates.
- ComboBoxDelegate: Delegate for the communication column to provide a combo box UI.
Features
- Multi-selection enabled for the table with full row selection.
- Buttons to select all rows, deselect all rows, and perform operations on selected devices.
- Progress bar and label for visual feedback during data updates.
- Automatic loading of initial device data into the table.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the initialization process, it raises a BaseError with code 3501. |
Source code in src\ui\base_select_devices_dialog.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
load_data()
Loads data from a file specified by self.file_path
and filters it based on
specific criteria. The method reads each line of the file, splits it into
parts, and checks if the last part (active status) indicates a truthy value
(e.g., 'true', '1', 'yes', 'verdadero', 'si'). If the criteria are met,
selected fields are extracted and appended to self.data
.
After processing the file, the data is loaded into a table using
self.load_data_into_table()
.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during file reading or processing,
it raises a |
Source code in src\ui\base_select_devices_dialog.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
load_data_into_table()
Populates the table widget with data from the self.data
attribute.
This method clears any existing rows in the table widget and inserts new rows
based on the records in self.data
. Each cell is populated with non-editable
items, and the background color of the cells is set to light gray. After
populating the table, the method adjusts the table's size to fit its content.
Steps:
- Clears all rows in the table widget.
- Iterates through the records in
self.data
and inserts rows into the table. - Creates non-editable table items for each cell and sets their background color.
- Adjusts the table size to fit the content.
Note
- The
self.data
attribute is expected to be an iterable of records, where each record is an iterable of values corresponding to table columns. - The table widget is assumed to be an instance of QTableWidget.
Source code in src\ui\base_select_devices_dialog.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
op_terminate(devices=None)
Resets the UI components to their default visible states after an operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices
|
optional
|
A parameter for devices, currently unused in the method. |
None
|
Source code in src\ui\base_select_devices_dialog.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
operation_with_selected_ips()
Handles operations with the selected IP addresses from the table widget. This method retrieves the selected rows from the table widget, extracts the IP addresses from a specific column, and performs an operation on the selected IPs using a separate thread. It also updates the UI to reflect the ongoing operation and handles progress updates.
Raises:
Type | Description |
---|---|
Exception
|
If no devices are selected, a message box is displayed, and an exception is raised. |
BaseError
|
If any other exception occurs during the execution of the method. |
Attributes:
Name | Type | Description |
---|---|---|
selected_ips |
list[str]
|
A list to store the IP addresses of the selected devices. |
UI Updates
- Hides the table widget.
- Sorts the table widget by the IP column in descending order.
- Updates labels and buttons to indicate the operation is in progress.
- Displays a progress bar to show the operation's progress.
Threads
- Creates and starts an
OperationThread
to perform the operation on the selected IPs. - Connects thread signals to appropriate methods for progress updates, termination, and cleanup.
Source code in src\ui\base_select_devices_dialog.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
|
select_all_rows()
Selects all rows in the table widget that are not already selected. This method retrieves the list of currently selected rows in the table widget and iterates through all rows in the table. If a row is not already selected, it selects the row.
Note
- The method assumes that
self.table_widget
is a valid QTableWidget or similar widget withselectionModel
,selectedRows
,rowCount
, andselectRow
methods.
Source code in src\ui\base_select_devices_dialog.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
update_progress(percent_progress, device_progress, processed_devices, total_devices)
Updates the progress bar and status label with the current progress of device processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
percent_progress
|
int
|
The overall progress percentage to be displayed on the progress bar. |
required |
device_progress
|
str
|
A message indicating the status of the last connection attempt. |
required |
processed_devices
|
int
|
The number of devices that have been processed so far. |
required |
total_devices
|
int
|
The total number of devices to be processed. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in src\ui\base_select_devices_dialog.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
icon_manager
MainWindow
Bases: QMainWindow
Source code in src\ui\icon_manager.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
__create_action(text, function)
Creates a QAction with the specified text and associates it with a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The display text for the action. |
required |
function
|
callable
|
The function to be executed when the action is triggered. |
required |
Returns:
Type | Description |
---|---|
QAction
|
The created action with the specified text and connected function. |
Source code in src\ui\icon_manager.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
__create_tray_icon()
Creates and configures the system tray icon for the application. This method initializes a QSystemTrayIcon with a tooltip and a custom context menu containing various actions for interacting with the application. The context menu includes options for modifying devices, restarting devices, testing connections, updating device time, fetching attendances, and toggling specific settings. It also provides options to view logs and exit the application. The tray icon displays a notification message upon initialization and is shown in the system tray.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the creation or configuration of the system tray icon, it raises a BaseError with an error code and message. |
Source code in src\ui\icon_manager.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
__init__()
Initializes the IconManager class. This constructor sets up the initial state of the application, including the system tray icon, configuration settings, and application startup behavior. It also handles potential duplicate instances of the application.
Attributes:
Name | Type | Description |
---|---|---|
is_running |
bool
|
Indicates if the application is currently running. |
checked_clear_attendance |
bool
|
State of the "clear attendance" checkbox, retrieved from the configuration file. |
checked_automatic_init |
bool
|
Indicates if the application is set to start automatically on system startup. |
tray_icon |
QSystemTrayIcon
|
The system tray icon for the application. |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with an error code, message, and severity level. |
Source code in src\ui\icon_manager.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
__init_ui()
Initializes the user interface components for the application.
This method is responsible for setting up and configuring the system tray icon by invoking the necessary helper methods. It ensures that the system tray icon is properly created and ready for use.
Source code in src\ui\icon_manager.py
88 89 90 91 92 93 94 95 96 97 |
|
__opt_exit_icon()
Handles the exit operation for the application.
This method hides the system tray icon, if it exists, and then quits the application.
Returns:
Type | Description |
---|---|
None |
Source code in src\ui\icon_manager.py
417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
__opt_fetch_devices_attendances()
Handles the process of fetching attendance data from devices.
This method creates and displays a dialog for obtaining attendance data from devices. Once the dialog is closed, it ensures that the tray icon's context menu is made visible again. Any exceptions encountered during the process are captured and logged using the BaseError class.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the execution of the method. |
Source code in src\ui\icon_manager.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
__opt_modify_devices()
Handles the modification of devices through a dialog interface.
This method creates and displays a ModifyDevicesDialog
for modifying device settings.
Once the dialog is closed, it ensures that the tray icon's context menu is visible again.
Any exceptions encountered during the process are logged using the BaseError
class.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the execution of the method, it is wrapped and logged with an error code of 3500. |
Source code in src\ui\icon_manager.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
__opt_restart_devices()
Handles the restart devices operation by displaying a dialog to the user.
This method creates and executes a RestartDevicesDialog
to allow the user
to restart devices. Once the dialog is closed, it ensures that the tray icon's
context menu is made visible again. If an exception occurs during the process,
it logs the error using the BaseError
class.
Raises:
Type | Description |
---|---|
Exception
|
If an error occurs during the execution of the dialog or while handling the tray icon's context menu. |
Source code in src\ui\icon_manager.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
__opt_show_logs()
Displays the logs dialog and ensures the system tray context menu is visible after the dialog is closed.
This method attempts to create and display a LogsDialog
instance. Once the dialog is closed,
it ensures that the system tray icon's context menu is made visible again. If an exception occurs
during this process, it is handled by logging the error using the BaseError
class.
Raises:
Type | Description |
---|---|
Exception
|
If an error occurs while creating or displaying the |
Source code in src\ui\icon_manager.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
__opt_test_connections()
Handles the testing of device connections by opening a dialog to ping devices.
This method creates and displays a PingDevicesDialog
to check the status of devices.
Once the dialog is closed, it ensures that the tray icon's context menu is visible again.
If an exception occurs during the process, it logs the error using the BaseError
class.
Raises:
Type | Description |
---|---|
Exception
|
If an error occurs during the execution of the method. |
Source code in src\ui\icon_manager.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
__opt_toggle_checkbox_automatic_init()
Toggles the state of the "automatic initialization" checkbox and updates the system's startup configuration accordingly. This method is intended to be used in a frozen Python application (e.g., packaged with PyInstaller). When the checkbox is toggled:
- If enabled, the application is added to the system's startup programs.
- If disabled, the application is removed from the system's startup programs.
Exceptions are caught and logged using the BaseError
class.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the process, it is wrapped and raised with an error code (3000). |
Notes
- The
add_to_startup
andremove_from_startup
functions are assumed to handle the actual system-level operations for managing startup programs. - This method only functions correctly in a frozen Python environment (e.g., when
sys.frozen
is True).
Source code in src\ui\icon_manager.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
__opt_toggle_checkbox_clear_attendance()
Toggles the state of the 'clear attendance' checkbox and updates the configuration file accordingly.
This method inverts the current state of the checked_clear_attendance
attribute, updates the
corresponding value in the configuration file under the 'Device_config' section, and writes the
changes back to the file. If an error occurs during the file write operation, it raises a
BaseError
with an appropriate error code and message.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs while writing to the configuration file. |
Source code in src\ui\icon_manager.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
__opt_update_devices_time()
Handles the process of updating the time on devices.
This method creates and displays a dialog for updating the time on devices. Once the dialog is closed, it ensures that the context menu of the tray icon is made visible again if it exists. Any exceptions raised during the process are caught and logged using the BaseError class.
Raises:
Type | Description |
---|---|
Exception
|
Catches any exception that occurs during the execution and logs it with an error code and message. |
Source code in src\ui\icon_manager.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
__show_message_information(title, text)
Displays an informational message dialog with a specified title and text.
This method creates a QMessageBox instance to show an informational message
to the user. It sets the title, text, and icon of the dialog box. Additionally,
it customizes the window icon using a specified .ico
file. After the dialog
box is closed, it ensures that the tray icon's context menu is made visible again.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
The title of the message dialog box. |
required |
text
|
str
|
The informational text to display in the dialog box. |
required |
Side Effects
- Displays a QMessageBox with the specified title and text.
- Sets the window icon of the QMessageBox using a custom
.ico
file. - Ensures the tray icon's context menu is visible after the dialog box is closed.
Source code in src\ui\icon_manager.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
start_timer()
Starts a timer by returning the current time in seconds.
Returns:
Type | Description |
---|---|
float
|
The current time in seconds since the epoch. |
Source code in src\ui\icon_manager.py
166 167 168 169 170 171 172 173 |
|
stop_timer(start_time)
Stops the timer and calculates the elapsed time since the provided start time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time
|
float
|
The starting time in seconds since the epoch. |
required |
Returns:
Type | Description |
---|---|
None |
Logs
Logs the elapsed time in seconds to the application log.
Side Effects
Displays a system tray notification with the elapsed time.
Source code in src\ui\icon_manager.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
logs_dialog
LogsDialog
Bases: BaseDialog
Source code in src\ui\logs_dialog.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
__init__()
Initializes the LogsDialog class.
This constructor sets up the LogsDialog instance by calling the parent class initializer with a specific window title, initializing the user interface, and handling any exceptions that may occur during the process.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it is wrapped in a BaseError with code 3501 and the exception message. |
Source code in src\ui\logs_dialog.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
get_error_logs(start_date, end_date, selected_errors, selected_sources, search_text)
Retrieves error log entries from log files within a specified date range, filtered by error codes, sources, and optional search text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date
|
str
|
The start date in the format 'YYYY-MM-DD' to filter log entries. |
required |
end_date
|
str
|
The end date in the format 'YYYY-MM-DD' to filter log entries. |
required |
selected_errors
|
list
|
A list of error codes to filter log entries. If empty, all error codes are included. |
required |
selected_sources
|
list
|
A list of sources to filter log entries. If empty, all sources are included. |
required |
search_text
|
str
|
Optional text to search within log entries. If empty, no search filtering is applied. |
required |
Returns:
Type | Description |
---|---|
list
|
A list of formatted error log entries that match the specified filters, sorted by date and time. |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during log processing, it raises a BaseError with code 3500 and the error message. |
Source code in src\ui\logs_dialog.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
init_ui()
Initializes the user interface for the logs dialog. This method sets up the UI components, including date selection widgets, text search filter, error and source selection lists, and a text display area for logs. It also configures the layout and connects signals to dynamically filter logs based on user input.
UI Components
- Date Selection Widgets:
start_date_edit
: QDateEdit for selecting the start date.end_date_edit
: QDateEdit for selecting the end date.
- Text Search Filter:
text_search_edit
: QLineEdit for searching text in logs.
- Error Selection List:
error_list
: QListWidget for selecting error codes to filter logs.
- Source Selection List:
source_list
: QListWidget for selecting log sources to filter logs.
- Toggle Filter Button:
toggle_filter_button
: QPushButton to toggle the visibility of error and source filter lists.
- Labels:
select_errors_label
: QLabel for error filter instructions.select_sources_label
: QLabel for source filter instructions.
- Logs Display:
text_edit
: QTextEdit for displaying filtered logs.
Layout
filter_layout
: Horizontal layout for date selection, text search, and toggle filter button.error_list_layout
: Vertical layout for error filter label and list.source_list_layout
: Vertical layout for source filter label and list.filter_lists_layout
: Horizontal layout combining error and source filter layouts.layout
: Main vertical layout combining all components.
Behavior
- Connects signals to dynamically filter logs when:
- Dates are changed.
- Text is entered in the search field.
- Error or source selections are modified.
- Loads logs at startup.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during UI initialization. |
Source code in src\ui\logs_dialog.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
load_logs()
Loads and displays error logs based on the specified filters.
This method retrieves error logs within a specified date range, filtered by selected error types, sources, and a search text.
The logs are then displayed in a text editor.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the log retrieval process. |
Filters
- Date range: Defined by
start_date_edit
andend_date_edit
. - Error types: Selected items in
error_list
. - Sources: Selected items in
source_list
. - Search text: Text entered in
text_search_edit
.
Steps
- Retrieve the start and end dates from the date edit widgets.
- Get the search text and convert it to lowercase.
- Collect selected error types and sources from their respective lists.
- Fetch the filtered error logs using
get_error_logs
. - Display the logs in the
text_edit
widget.
Note
Ensure that the get_error_logs
method is implemented to handle
the filtering logic and return the appropriate logs.
Source code in src\ui\logs_dialog.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
toggle_filter_visibility()
Toggles the visibility of filter-related UI elements in the logs dialog.
This method switches the visibility state of the following elements
select_errors_label
error_list
select_sources_label
source_list
If an exception occurs during the process, it raises a BaseError
with
an error code of 3500 and the exception message.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs while toggling visibility. |
Source code in src\ui\logs_dialog.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
message_box
MessageBox
Bases: QMessageBox
Source code in src\ui\message_box.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
__init__(icon, text, parent=None)
Initializes the custom message box with the specified icon, text, and optional parent widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon
|
Icon
|
The icon to display in the message box. |
required |
text
|
str
|
The text message to display in the message box. |
required |
parent
|
QWidget
|
The parent widget of the message box. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
BaseError
|
If an error occurs during initialization, a BaseError with code 3501 is raised. |
Source code in src\ui\message_box.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
modify_device_dialog
AddDevicesDialog
Bases: QDialog
Source code in src\ui\modify_device_dialog.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
__init__(parent=None, id=0)
Initializes the ModifyDeviceDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for this dialog. Defaults to None. |
None
|
id
|
int
|
The identifier for the device. Defaults to 0. |
0
|
Raises:
Type | Description |
---|---|
BaseError
|
Custom error raised with code 3501 if an exception occurs during initialization. |
Source code in src\ui\modify_device_dialog.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
get_data()
Retrieves and returns the data from the dialog fields.
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing the following elements:
|
Source code in src\ui\modify_device_dialog.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
init_ui()
Initializes the user interface for the Modify Device Dialog. This method sets up the layout and widgets for the dialog, including input fields for district, model, point of marking, IP address, and communication type. It also includes a button to confirm the action.
Layout
- Uses QVBoxLayout as the main layout.
- Uses QFormLayout for organizing input fields and labels.
Signals
- Connects the QComboBox
currentIndexChanged
signal to theon_combobox_changed
slot.
Attributes:
Name | Type | Description |
---|---|---|
self.district_edit |
QLineEdit
|
Input field for the district. |
self.model_edit |
QLineEdit
|
Input field for the model. |
self.point_edit |
QLineEdit
|
Input field for the point of marking. |
self.ip_edit |
QLineEdit
|
Input field for the IP address. |
self.combo_box |
QComboBox
|
Dropdown for selecting the communication type. |
self.communication |
str
|
Stores the current communication type selected in the combo box. |
self.active |
bool
|
Indicates if the device is active (default is True). |
self.battery |
bool
|
Indicates if the device has a battery (default is True). |
self.btn_add |
QPushButton
|
Button to confirm and accept the dialog. |
Source code in src\ui\modify_device_dialog.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
on_combobox_changed(index)
Handles the event triggered when the selected index of the combo box changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int
|
The index of the newly selected item in the combo box. |
required |
Side Effects
Updates the self.communication
attribute with the text of the currently selected option
in the combo box.
Source code in src\ui\modify_device_dialog.py
430 431 432 433 434 435 436 437 438 439 440 441 442 |
|
ModifyDevicesDialog
Bases: BaseDialog
Source code in src\ui\modify_device_dialog.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
__init__(parent=None)
Initializes the ModifyDeviceDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for this dialog. Defaults to None. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
file_path |
str
|
The path to the "info_devices.txt" file, determined dynamically. |
data |
list
|
A list to store device data. |
max_id |
int
|
The maximum ID value among the devices. |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501. |
Source code in src\ui\modify_device_dialog.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
activate_all()
Activates all checkboxes in the specified column of the table widget.
This method iterates through all rows of the table widget and sets the checkbox in the 7th column (index 7) to a checked state.
Note
- Assumes that the 7th column of the table widget contains checkboxes as cell widgets.
- The table widget must be properly initialized and populated before calling this method.
Source code in src\ui\modify_device_dialog.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
add_device()
Adds a new device to the list of devices.
This method calculates a new unique ID for the device, opens a dialog to collect the device's details, and appends the new device data to the internal data list if the dialog is accepted. It also updates the maximum ID and refreshes the data displayed in the table.
Steps:
- Calculate a new unique ID for the device.
- Open the AddDevicesDialog to collect device details.
- If the dialog is accepted:
- Retrieve the new device data from the dialog.
- Append the new device data to the internal list.
- Update the maximum ID.
- Reload the data into the table.
Note: - The dialog must return QDialog.Accepted for the new device data to be added.
Source code in src\ui\modify_device_dialog.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
deactivate_all()
Deactivates all checkboxes in the specified column of the table widget.
This method iterates through all rows of the table widget and sets the checkbox in the specified column (column index 7) to an unchecked state.
Returns:
Type | Description |
---|---|
None |
Source code in src\ui\modify_device_dialog.py
152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
init_ui()
Initializes the user interface for the Modify Device Dialog. This method sets up the layout and widgets for the dialog, including a table for displaying device information and buttons for performing various actions such as loading, modifying, adding, activating, and deactivating devices.
Layout
- QVBoxLayout: Main layout containing the table widget and button layout.
- QHBoxLayout: Layout for arranging the action buttons horizontally.
Notes
- Buttons are configured to not retain focus after being clicked.
- The
load_data_and_show
method is called at the end to populate the table with initial data.
Source code in src\ui\modify_device_dialog.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
load_data()
Loads data from a file specified by self.file_path
.
The method reads each line of the file, splits it into parts, and processes the data if it matches the expected format. Each line is expected to have 8 components separated by ' - '. The components are: district, model, point, ip, id, communication, battery, and active.
The method updates self.max_id
with the maximum value of the id
field
encountered in the file. The battery
and active
fields are evaluated
as Python literals using literal_eval
.
Returns:
Type | Description |
---|---|
list
|
A list of tuples containing the processed data. Each tuple has the following structure: (district, model, point, ip, id, communication, battery, active) |
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an exception occurs during file reading or processing, it raises this custom error with an error code (3001) and the exception message. |
Source code in src\ui\modify_device_dialog.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
load_data_and_show()
Loads data, processes it, and displays it in the UI.
This method performs the following steps:
1. Loads data by calling the load_data
method.
2. Populates the UI table with the loaded data by calling the load_data_into_table
method.
Ensure that the load_data
and load_data_into_table
methods are properly implemented
for this method to function as expected.
Source code in src\ui\modify_device_dialog.py
198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
load_data_into_table()
Populates the table widget with data from the self.data
attribute.
This method iterates over the rows of data and populates each row in the table widget.
It sets up the following columns:
- Column 0: District (string)
- Column 1: Model (string)
- Column 2: Point (string)
- Column 3: IP Address (string)
- Column 4: ID (integer, converted to string)
- Column 5: Communication (string, with a ComboBoxDelegate)
- Column 6: Battery (boolean, with a CheckBoxDelegate)
- Column 7: Active (boolean, with a CheckBoxDelegate)
Delegates are used for specific columns:
- A ComboBoxDelegate is set for column 5 to allow selection of communication options.
- CheckBoxDelegates are used for columns 6 and 7 to represent boolean values.
After populating the table, the method adjusts the table size to fit the content.
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an exception occurs during the execution, it raises |
Source code in src\ui\modify_device_dialog.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
save_data()
Saves the data from the table widget to a file.
This method iterates through all rows of the table widget, retrieves the data
from each cell, and writes it to a file specified by self.file_path
. The data
is saved in a formatted string with each row's values separated by " - ".
Boolean values from checkboxes in the table are also included.
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an exception occurs during the file writing process, |
Side Effects
- Writes data to the file specified by
self.file_path
. - Displays a success message box upon successful save.
- Displays an error message box if an exception occurs.
Notes
- The
district
andpoint
values are converted to uppercase before saving. - The
battery
andactive
values are retrieved from checkbox widgets in the table.
Source code in src\ui\modify_device_dialog.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
obtain_attendances_devices_dialog
ObtainAttendancesDevicesDialog
Bases: SelectDevicesDialog
Source code in src\ui\obtain_attendances_devices_dialog.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
__init__(parent=None)
Initializes the ObtainAttendancesDevicesDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
Optional[QWidget]
|
The parent widget for this dialog. Defaults to None. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
failed_devices |
list[str]
|
A list to store devices that failed during the operation. |
attendances_manager |
AttendancesManager
|
An instance of AttendancesManager to handle attendance management. |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the exception message. |
Source code in src\ui\obtain_attendances_devices_dialog.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
check_attendance_files()
Checks attendance files in the "devices" directory for errors. A daily record (in a temporary file) is kept of each already reported incorrect check‑in, so that new ones are only reported once. For reporting, information is grouped by file, displaying each error only once (by file_path) as in the original version.
Raises:
Type | Description |
---|---|
BaseError
|
if the 'devices' folder is not found or if attendance errors are detected. |
Source code in src\ui\obtain_attendances_devices_dialog.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
extract_date(filename)
Extracts a date string from a given filename if it matches a specific pattern.
The method uses a regular expression to identify filenames that follow the
pattern: <IP_ADDRESS>_<YYYY-MM-DD>_file.cro
, where:
<IP_ADDRESS>
is a sequence of four groups of digits separated by dots.<YYYY-MM-DD>
is a date in the format year-month-day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The filename to extract the date from. |
required |
Returns:
Type | Description |
---|---|
str or None
|
The extracted date string in the format 'YYYY-MM-DD' if the filename matches the pattern; otherwise, None. |
Source code in src\ui\obtain_attendances_devices_dialog.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
extract_ip(filename)
Extracts an IP address from a given filename.
The method uses a regular expression to match filenames that follow the
pattern: <IP_ADDRESS>_<DATE>_file.cro
, where:
<IP_ADDRESS>
is a valid IPv4 address (e.g., 192.168.1.1).<DATE>
is in the format YYYY-MM-DD.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The filename to extract the IP address from. |
required |
Returns:
Type | Description |
---|---|
str
|
The extracted IP address if the filename matches the pattern, otherwise None. |
Source code in src\ui\obtain_attendances_devices_dialog.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
format_file_uri(file_path)
Converts a local file path to a file URI.
This method takes a file path as input, replaces backslashes with forward slashes (to ensure compatibility across different operating systems), and encodes special characters to make the path safe for use in a URI. It then constructs a file URI by prefixing the encoded path with 'file:'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The local file path to be converted into a file URI. |
required |
Returns:
Type | Description |
---|---|
str
|
The formatted file URI. |
Source code in src\ui\obtain_attendances_devices_dialog.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
init_ui()
Initializes the user interface for the attendance devices dialog.
This method sets up the UI components, including labels, buttons, and layouts, to display and manage attendance device information. It also configures event handlers for user interactions.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the initialization process, it raises a BaseError with code 3501 and the exception message. |
UI Components
- Header Labels: ["Distrito", "Modelo", "Punto de Marcación", "IP", "ID", "Comunicación"]
- QPushButton: A button to retry failed connections, initially hidden.
- QPushButton: A button to update and obtain attendance records, with updated text.
- QLabel: A label to display the total number of attendances, initially hidden.
Source code in src\ui\obtain_attendances_devices_dialog.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
on_retry_failed_connection_clicked()
Handles the retry action for failed device connections.
This method is triggered when the "Retry Failed Connection" button is clicked. It attempts to reconnect to the devices that previously failed to connect and updates the UI to reflect the retry process. A separate thread is used to manage the reconnection attempts and progress updates.
Steps performed:
- Hides certain UI elements (e.g., table widget, buttons) and updates labels.
- Initializes and starts an
OperationThread
to handle the reconnection logic. - Connects thread signals to appropriate methods for progress updates and cleanup.
- Hides the retry button after it is clicked.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the execution of the method. |
Attributes:
Name | Type | Description |
---|---|---|
self.failed_devices |
list
|
List of devices that failed to connect. |
self.attendances_manager |
object
|
Manager responsible for handling device attendances. |
Source code in src\ui\obtain_attendances_devices_dialog.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
op_terminate(devices=None)
Finalizes the operation of obtaining attendance data from devices and updates the UI accordingly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices
|
dict[str, dict[str, str]]
|
A dictionary where the keys are device IPs and the values are dictionaries containing device-specific information, such as "connection failed" status and "attendance count". |
None
|
Functionality
- Iterates through the rows of the table widget to update attendance data for each device.
- Checks if the device IP is in the list of selected IPs and updates the corresponding table cell:
- Marks devices with failed connections in red and adds them to the failed devices list.
- Updates the attendance count for devices with successful connections and marks them in green.
- Ensures the "Cant. de Marcaciones" column exists in the table and updates it with attendance data.
- Calculates the total number of attendances across all devices.
- Adjusts the table size, enables sorting, and sorts the table by a specific column in descending order.
- Deselects all rows in the table and centers the window.
- Attempts to check attendance files and handles any exceptions with a warning-level error.
- Displays a retry button for failed connections and updates the total attendance label.
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an unexpected exception occurs during the operation, it is raised with an error message box. |
Source code in src\ui\obtain_attendances_devices_dialog.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
operation_with_selected_ips()
Executes an operation with the selected IP addresses.
This method hides the retry button and the total attendances label before
attempting to perform the operation. It calls the parent class's
operation_with_selected_ips
method to execute the operation. If an
exception occurs during the execution, it displays the retry button
for failed connections.
Raises:
Type | Description |
---|---|
Exception
|
Catches any exception that occurs during the operation |
Source code in src\ui\obtain_attendances_devices_dialog.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
parse_attendance(line)
Parses a line of attendance data and extracts the timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line
|
str
|
A string containing attendance data, expected to have at least three parts separated by spaces, where the second and third parts represent the date and time respectively. |
required |
Returns:
Type | Description |
---|---|
datetime or None
|
A datetime object representing the parsed timestamp if the line is well-formed and the date and time are valid. Returns None if the line is malformed or the date/time cannot be parsed. |
Source code in src\ui\obtain_attendances_devices_dialog.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
show_btn_retry_failed_connection()
Displays the "Retry Failed Connection" button if there are failed devices.
This method checks if the failed_devices
attribute exists and contains
one or more entries. If so, it makes the btn_retry_failed_connection
button visible. If an exception occurs during execution, it raises a
BaseError
with an appropriate error code and message.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs, it is wrapped in a |
Source code in src\ui\obtain_attendances_devices_dialog.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
operation_thread
OperationThread
Bases: QThread
Source code in src\ui\operation_thread.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
__init__(op_func, selected_ips=None, parent=None)
Initializes the OperationThread instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
op_func
|
Callable
|
The operation function to be executed in the thread. |
required |
selected_ips
|
list[str]
|
A list of selected IP addresses. Defaults to None. |
None
|
parent
|
QObject
|
The parent object for the thread. Defaults to None. |
None
|
Source code in src\ui\operation_thread.py
27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
emit_progress(percent_progress=None, device_progress=None, processed_devices=None, total_devices=None)
Emits a progress update signal with the provided progress details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
percent_progress
|
int
|
The overall percentage of progress completed. Defaults to None. |
None
|
device_progress
|
str
|
A string describing the progress of the current device. Defaults to None. |
None
|
processed_devices
|
int
|
The number of devices that have been processed so far. Defaults to None. |
None
|
total_devices
|
int
|
The total number of devices to be processed. Defaults to None. |
None
|
Source code in src\ui\operation_thread.py
79 80 81 82 83 84 85 86 87 88 89 |
|
run()
Executes the operation function (op_func
) with the selected IPs or without them,
handles the result, and emits appropriate signals.
This method is designed to run in a separate thread to perform operations
asynchronously. It captures any exceptions raised during execution and
raises a BaseError
with a specific error code and message.
Attributes:
Name | Type | Description |
---|---|---|
selected_ips |
list
|
A list of selected IP addresses to pass to the operation function. If not provided, the operation function is called without IPs. |
result |
dict
|
The result of the operation function execution. |
Emits
op_terminate (dict): Signal emitted with the result of the operation function
or an empty dictionary if the result is None
.
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during the execution of the operation
function, a |
Source code in src\ui\operation_thread.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
ping_devices_dialog
PingDevicesDialog
Bases: SelectDevicesDialog
Source code in src\ui\ping_devices_dialog.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__init__(parent=None)
Initializes the PingDevicesDialog class.
This constructor sets up the dialog window for testing device connections. It initializes the user interface and sets the operation function to obtain connection information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for this dialog. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the exception message. |
Source code in src\ui\ping_devices_dialog.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
init_ui()
Initializes the user interface for the ping devices dialog.
This method sets up the table headers and updates the text of the update button to "Probar conexiones" (Test connections).
Header Labels
- Distrito: Represents the district or region.
- Modelo: Represents the device model.
- Punto de Marcación: Represents the marking point.
- IP: Represents the IP address of the device.
- ID: Represents the device identifier.
- Comunicación: Represents the communication status.
Overrides
This method overrides the init_ui
method from the parent class
and passes the custom header labels to it.
Source code in src\ui\ping_devices_dialog.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
op_terminate(devices=None)
Updates the table widget with the connection status and device information for a list of devices.
This method iterates through the rows of the table widget and updates the columns with information
such as connection status, attendance count, serial number, platform, and firmware version for each device.
The information is retrieved from the devices
dictionary, which maps IP addresses to device data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices
|
dict
|
A dictionary where keys are IP addresses (str) and values are dictionaries containing device information. Each device dictionary may include:
|
None
|
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an exception occurs during the operation, it raises a custom error with a message box displaying the error details. |
Notes
- The method ensures that specific columns ("Estado de Conexión", "Cant. de Marcaciones", "Número de Serie", "Plataforma", "Firmware") exist in the table widget before updating.
- The background color of each cell is updated based on the device's connection status and availability of information.
- The table widget is resized and sorted by the 6th column in descending order after updates.
- All rows are deselected at the end of the operation.
Source code in src\ui\ping_devices_dialog.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
restart_devices_dialog
RestartDevicesDialog
Bases: SelectDevicesDialog
Source code in src\ui\restart_devices_dialog.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
__init__(parent=None)
Initializes the RestartDevicesDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
QWidget
|
The parent widget for this dialog. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the exception message. |
Source code in src\ui\restart_devices_dialog.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
init_ui()
Initializes the user interface for the restart devices dialog.
This method sets up the table headers with predefined labels and updates the text of the update button to indicate its purpose as restarting devices.
Header Labels
- "Distrito": Represents the district information.
- "Modelo": Represents the device model.
- "Punto de Marcación": Represents the marking point.
- "IP": Represents the IP address of the device.
- "ID": Represents the device ID.
- "Comunicación": Represents the communication status of the device.
Source code in src\ui\restart_devices_dialog.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
op_terminate(devices_errors=None)
Handles the termination operation for devices, displaying appropriate messages based on the presence of errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices_errors
|
dict[str, dict[str, bool]]
|
A dictionary containing device error information. The keys are device identifiers, and the values are dictionaries with error details. Defaults to None. |
None
|
Behavior
- If
devices_errors
contains entries, an error message box is displayed with the list of problematic devices. - If
devices_errors
is empty or None, an information message box is displayed indicating successful device restarts. - Logs the
devices_errors
dictionary for debugging purposes. - Calls the parent class's
op_terminate
method after handling the operation.
Source code in src\ui\restart_devices_dialog.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
update_time_device_dialog
UpdateTimeDeviceDialog
Bases: SelectDevicesDialog
Source code in src\ui\update_time_device_dialog.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
__init__(parent=None)
Initializes the UpdateTimeDeviceDialog class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
Optional[QWidget]
|
The parent widget for this dialog. Defaults to None. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
device_info |
dict[str, bool]
|
A dictionary containing device information loaded from |
Raises:
Type | Description |
---|---|
BaseError
|
If an exception occurs during initialization, it raises a BaseError with code 3501 and the exception message. |
Source code in src\ui\update_time_device_dialog.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
init_ui()
Initializes the user interface for the update time device dialog.
This method sets up the table headers with predefined labels and updates the text of the update button to "Actualizar hora".
Header Labels
- Distrito
- Modelo
- Punto de Marcación
- IP
- ID
- Comunicación
Source code in src\ui\update_time_device_dialog.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
load_device_info()
Loads device information from a file and returns it as a dictionary.
The method reads the file "info_devices.txt" line by line, extracts the IP address and battery status from each line, and stores them in a dictionary. The IP address is used as the key, and the battery status (a boolean) is used as the value.
Returns:
Type | Description |
---|---|
dict[str, bool]
|
A dictionary where the keys are IP addresses (str) and the values are battery statuses (bool). |
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an error occurs while reading the file, an exception |
Source code in src\ui\update_time_device_dialog.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
op_terminate(devices_errors=None)
Updates the table widget with the connection and battery status of devices.
This method processes the devices_errors
dictionary to update the table widget
with the connection and battery status for each device. It ensures that the required
columns exist in the table, updates the rows with the appropriate status and colors,
and adjusts the table's size and sorting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices_errors
|
dict[str, dict[str, bool]]
|
A dictionary where the keys are device IP addresses, and the values are dictionaries containing error statuses for the device. The inner dictionary can have the following keys:
Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
BaseErrorWithMessageBox
|
If an exception occurs during the operation, it raises a custom error with a message box displaying the error details. |
Source code in src\ui\update_time_device_dialog.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|