API Documentation
This API is still in development and may change without notice.
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
CuemsDBMedia
Bases: StringSanitizer
Media file CRUD, thumbnail / waveform generation, and video pre-indexing.
On upload (via :meth:new) the following sidecar files are created:
- Movie — JPEG thumbnail (ffmpeg) +
.idxvideo index (cuems-videoindexer). - Audio — PNG waveform image (audiowaveform) + JSON waveform data.
- Image — JPEG thumbnail (ffmpeg).
All mutating operations are wrapped in Peewee atomic transactions with rollback; filesystem changes are reversed on failure where possible.
User-supplied name strings are sanitised via the inherited
StringSanitizer methods.
Example
db_media = CuemsDBMedia(settings_dict, database) dest_name = db_media.new("/tmp/cuems/upload.tmp123456", "my-audio.wav") media_list = db_media.list() meta = db_media.load_meta(uuid_str) db_media.delete(uuid_str) # soft-delete → trash db_media.restore(uuid_str) # restore from trash db_media.delete_from_trash(uuid_str) # permanent delete
Source code in src/cuemseditor/CuemsDBMedia.py
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 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 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | |
__init__(settings_dict, db_connection)
Initialise paths from settings_dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_dict
|
Mapping consumed from |
required | |
db_connection
|
The shared Peewee |
required |
Source code in src/cuemseditor/CuemsDBMedia.py
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 | |
add_binary_header(binary_data, uuid_string, type_number)
Prepend a 36-byte UUID header to binary_data.
The frontend identifies the media item from this header when it receives the binary WebSocket frame without an out-of-band correlation identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_data
|
Raw bytes of the thumbnail or waveform file. |
required | |
uuid_string
|
36-character UUID string to embed. |
required | |
type_number
|
Integer payload type tag (1 = thumbnail, 2 = waveform). |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | |
check_if_media_existed_in_projects(filename)
Query ProjectMedia rows referencing filename regardless of media FK.
Used by CuemsUpload after a successful upload to detect re-uploads
of files that projects already reference by filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
|
required |
Returns:
| Type | Description |
|---|---|
|
Peewee |
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | |
create_audio_thubnail(filename, duration)
Generate a waveform overview image for an audio file using audiowaveform.
Produces a PNG-format thumbnail at thumbnail_size pixels using
8-bit sample data. The -e (end time) argument is
duration.milliseconds_rounded / 1000 seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename of the source audio file inside |
required | |
duration
|
|
required |
Returns:
| Type | Description |
|---|---|
|
Absolute path to the created thumbnail file, or |
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | |
create_audio_waveform(filename)
Generate an 8-bit audiowaveform JSON data file for an audio file.
Writes to <waveform_path>/<stem>_<ext>.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename of the source audio file inside |
required |
Returns:
| Type | Description |
|---|---|
|
Absolute path to the created waveform file, or |
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | |
create_video_index(filename)
Run cuems-videoindexer to pre-build the frame index sidecar (.idx) for a video file.
The .idx file is created in <media_path>/indexes/ so that
videocomposer can call loadCachedIndex on first arm instead of
building the index at playback time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename of the video file inside |
required |
Source code in src/cuemseditor/CuemsDBMedia.py
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 | |
create_video_thumbnail(filename, duration)
Generate a JPEG thumbnail for a video or image file using ffmpeg.
Seeks to 200 ms when duration is provided to avoid all-black frames
at the start of some video files. Writes to
<thumbnail_path>/<stem>_<ext>.jpg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename of the source file inside |
required | |
duration
|
|
required |
Returns:
| Type | Description |
|---|---|
|
Absolute path to the created thumbnail file, or |
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
delete(uuid)
Soft-delete a media file by moving it and its sidecars to the trash.
Moves the media file, thumbnail, and (for audio) waveform to the
corresponding trash sub-directories via _move_keeping_name, so
unix_name stays valid. Sets Media.in_trash = True
atomically. Reverses filesystem moves on transaction rollback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of the live media file to trash. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no live media file with uuid exists. |
Source code in src/cuemseditor/CuemsDBMedia.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
delete_from_trash(uuid)
Permanently delete a trashed media file and its sidecars.
Removes the Media DB row (and its ProjectMedia join rows via
cascade) and deletes the media file, thumbnail, and waveform from the
trash directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of a trashed media file. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no trashed media file with uuid exists. |
Source code in src/cuemseditor/CuemsDBMedia.py
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
get_duration(filename)
Extract a media file's duration and return a CTimecode.
Thin wrapper around the module-level :func:probe_duration, resolving
filename against media_path. Kept as a method so callers with a
CuemsDBMedia instance need not know the media directory layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename of the media file inside |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NotTimeCodeError
|
If the duration cannot be probed (see
:func: |
Source code in src/cuemseditor/CuemsDBMedia.py
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | |
get_file_path(filename, trash_state=False)
Return the absolute path for a media file in the live or trash directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Media |
required | |
trash_state
|
|
False
|
Returns:
| Type | Description |
|---|---|
|
Absolute path string. |
Source code in src/cuemseditor/CuemsDBMedia.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | |
get_thumbnail_filename(filename)
Derive the thumbnail filename for filename.
Convention: <stem>_<ext_without_dot><thumbnail_extension>
e.g. concert.mp4 → concert_mp4.jpg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Source media filename. |
required |
Returns:
| Type | Description |
|---|---|
|
Thumbnail filename string (no directory component). |
Source code in src/cuemseditor/CuemsDBMedia.py
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | |
get_thumbnail_path(filename, trash_state=False)
Return the absolute path for a thumbnail file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Source media |
required | |
trash_state
|
|
False
|
Returns:
| Type | Description |
|---|---|
|
Absolute path string. |
Source code in src/cuemseditor/CuemsDBMedia.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | |
get_type(filename)
Detect the MediaType of filename from its extension.
Extension matching is case-insensitive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Filename string (no directory component needed). |
required |
Returns:
| Type | Description |
|---|---|
|
|
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
get_waveform_filename(filename)
Derive the waveform filename for filename.
Convention: <stem>_<ext_without_dot><waveform_extension>
e.g. concert.wav → concert_wav.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Source media filename. |
required |
Returns:
| Type | Description |
|---|---|
|
Waveform filename string (no directory component). |
Source code in src/cuemseditor/CuemsDBMedia.py
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 | |
get_waveform_path(filename, trash_state=False)
Return the absolute path for a waveform file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Source media |
required | |
trash_state
|
|
False
|
Returns:
| Type | Description |
|---|---|
|
Absolute path string. |
Source code in src/cuemseditor/CuemsDBMedia.py
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | |
is_audio(db_record)
Return True if db_record has media_type == 'AUDIO'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_record
|
A |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
846 847 848 849 850 851 852 853 854 855 856 857 858 | |
list()
Return all live (non-trashed) media files with project usage counts.
Returns:
| Type | Description |
|---|---|
|
List of single-key dicts ``{uuid_str: {name, unix_name, created, |
|
|
modified, duration, type, in_projects, in_projects_list, |
|
|
in_trash_projects}} |
|
|
|
|
|
copies it into cue |
|
|
is a list of |
|
|
project. |
Source code in src/cuemseditor/CuemsDBMedia.py
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 506 | |
list_trash()
Return all trashed media files with project usage counts.
Returns:
| Type | Description |
|---|---|
|
Same shape as :meth: |
|
|
|
Source code in src/cuemseditor/CuemsDBMedia.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
load_meta(uuid)
Return full metadata for a media file, including project usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Media UUID string (live or trashed). |
required |
Returns:
| Type | Description |
|---|---|
|
Single-key dict ``{uuid: {name, unix_name, description, created, |
|
|
modified, duration, type, in_trash, in_projects, in_trash_projects}}``. |
|
|
|
|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no media record with uuid exists. |
Source code in src/cuemseditor/CuemsDBMedia.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
load_thumbnail(uuid)
Read and return the thumbnail file as a length-prefixed binary blob.
The returned bytes start with a 36-byte UUID header (see
:meth:add_binary_header) so the frontend can correlate the binary
WebSocket frame to the originating request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Media UUID string. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If the media record or its thumbnail file cannot be found. |
Source code in src/cuemseditor/CuemsDBMedia.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
load_waveform(uuid)
Read and return the waveform data file as a length-prefixed binary blob.
The returned bytes start with a 36-byte UUID header (see
:meth:add_binary_header) so the frontend can correlate the binary
WebSocket frame to the originating request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Media UUID string. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If the media record or its waveform file cannot be found. |
Source code in src/cuemseditor/CuemsDBMedia.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
new(tmp_file_path, filename, md5=None)
Intake a newly uploaded file: move it into the media library and create sidecars.
Steps performed atomically:
CopyMoveVersioned.movefromtmp_file_pathto<media_path>/<filename>(versioned if filename exists).- Detect
MediaTypefrom the file extension. - Extract duration via
ffprobe(audio/video). - Generate thumbnail (ffmpeg), waveform (audiowaveform for audio), and video index (cuems-videoindexer for movies).
- Insert the
MediaDB row.
On any failure the transaction is rolled back and any partially created sidecar files are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tmp_file_path
|
Absolute path to the file in the tmp upload directory. |
required | |
filename
|
Sanitised target filename (no directory component). |
required | |
md5
|
the file's MD5 as the upload verified it ( |
None
|
Returns:
| Type | Description |
|---|---|
|
The actual destination filename (may differ from filename if |
|
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises after rollback and cleanup on any failure. |
Source code in src/cuemseditor/CuemsDBMedia.py
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 | |
restore(uuid)
Restore a trashed media file and its sidecars back to the media library.
Moves files from the trash sub-directories back to the live media
directories via _move_keeping_name, so unix_name stays valid.
Sets Media.in_trash = False atomically. Reverses filesystem
moves on transaction rollback.
A live file already at <media_path>/<unix_name> is not tracked by
the library, but cues may play it by name, so the restore is refused
rather than moving it aside.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of a trashed media file to restore. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no trashed media file with uuid exists. |
FileExistsError
|
If an untracked file already holds the name in the media directory. |
Source code in src/cuemseditor/CuemsDBMedia.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | |
save(uuid, data)
Update the name and description fields of a live media record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Media UUID string. |
required | |
data
|
Dict with structure |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If the media record does not exist or is in the trash. |
Source code in src/cuemseditor/CuemsDBMedia.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
MediaProbe
What one ffprobe call says about a file: its duration and the pixel size of its first video stream, each with a state, so "this file has no picture" is never mistaken for "the probe failed".
Source code in src/cuemseditor/CuemsDBMedia.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
MediaType
Bases: Enum
Media file category.
Used as the media_type column value in the Media ORM model (stored
as MOVIE, AUDIO, or IMAGE string).
Source code in src/cuemseditor/CuemsDBMedia.py
275 276 277 278 279 280 281 282 283 284 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
media_file_size(file_path)
Size in bytes, or None when unreadable or empty.
Source code in src/cuemseditor/CuemsDBMedia.py
58 59 60 61 62 63 64 | |
probe_dimensions(file_path)
Return (width, height) px of a file's first video stream, or
(None, None).
The same ffprobe query the engine ran when it armed a video cue, so the
stored values are the values the engine used to measure (869fat84r).
Never raises: a failure logs a WARNING and returns (None, None).
Source code in src/cuemseditor/CuemsDBMedia.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
probe_duration(file_path)
Probe a media file's duration with ffprobe and return a CTimecode.
Runs ffprobe -show_entries format=duration (plain float seconds, NOT
-sexagesimal) and constructs CTimecode(start_seconds=...) which
canonicalises correctly at every framerate including the whole-second carry
boundary. This replaces the previous sexagesimal-string reformatting hack,
which silently corrupted any duration whose millisecond fraction ended in a
zero (stored short by up to ~0.9 s) and mangled the carry case into a
minutes-long overshoot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Absolute path to the media file. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NotTimeCodeError
|
on any failure — ffprobe timeout, non-zero exit,
empty / |
Source code in src/cuemseditor/CuemsDBMedia.py
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 | |
probe_media(file_path, timeout=DIMENSIONS_PROBE_TIMEOUT)
Read a file's duration and pixel size with ONE ffprobe call.
The duration is the same format=duration field :func:probe_duration
reads, made into the same CTimecode, so an unchanged file gives the
same stored string. Never raises.
Source code in src/cuemseditor/CuemsDBMedia.py
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 | |
run_video_indexer(file_path, timeout=VIDEO_INDEXER_TIMEOUT)
async
Run cuems-videoindexer on file_path as an asyncio subprocess (no
executor thread is held while it works).
Success is the exit code AND an index the videocomposer will accept, not "an .idx file exists": a stale one exists too. Never raises.
Source code in src/cuemseditor/CuemsDBMedia.py
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 | |
video_index_path(file_path)
/lib/media/a.mp4 -> /lib/media/indexes/a.mp4.idx (the
videocomposer's getIndexPath).
Source code in src/cuemseditor/CuemsDBMedia.py
214 215 216 217 218 | |
video_index_state(file_path)
Is the video's .idx the one the videocomposer would accept?
It compares what the videocomposer compares: magic, version, the video's size and mtime (whole seconds), and a positive frame count. Fails closed: anything it cannot read counts as missing.
Source code in src/cuemseditor/CuemsDBMedia.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
CuemsBaseModel
Bases: Model
Peewee base model that binds all CueMS ORM classes to the shared database.
All concrete models inherit from this class so they all operate on the
same SqliteDatabase instance that CuemsDBManager initialises at
startup via database.init(path).
Source code in src/cuemseditor/CuemsDBModel.py
23 24 25 26 27 28 29 30 31 32 | |
Media
Bases: CuemsBaseModel
ORM model for a media file record.
Each row represents one file in library_path/media/. The
in_trash flag soft-deletes the file to library_path/trash/media/,
preserving unique-name constraints on name and unix_name.
Attributes:
| Name | Type | Description |
|---|---|---|
uuid |
Primary key; used as the media identifier in cue XML. |
|
name |
Human-readable filename (unique, sanitized). |
|
unix_name |
Filesystem filename (unique, sanitized). |
|
description |
Optional free-text description. |
|
created |
Upload timestamp. |
|
modified |
Last metadata-update timestamp. |
|
duration |
|
|
media_type |
|
|
in_trash |
|
|
pixel_width |
/ pixel_height
|
original size in pixels of a movie's
first video stream, measured at upload like the duration, so the
engine does not probe the file when it arms a cue (869fat84r);
|
file_size |
the file's size in bytes; the engine compares it with its own copy to notice a replaced file. Every media type. |
|
file_md5 |
the file's MD5 (lowercase hex), from the upload, which already carries it; identifies the file for integrity checks. Every media type (D18). |
Source code in src/cuemseditor/CuemsDBModel.py
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 | |
all_fields()
staticmethod
Return the full column list for use in explicit SELECT clauses.
Returns:
| Type | Description |
|---|---|
|
List of Peewee field descriptors covering every column on |
|
|
|
Source code in src/cuemseditor/CuemsDBModel.py
134 135 136 137 138 139 140 141 142 | |
orphan()
Query Media records that are not referenced by any project.
Returns:
| Type | Description |
|---|---|
|
Peewee |
|
|
|
Source code in src/cuemseditor/CuemsDBModel.py
158 159 160 161 162 163 164 165 166 167 168 169 | |
projects()
Query all Project records that reference this media file.
Returns:
| Type | Description |
|---|---|
|
Peewee |
|
|
|
Source code in src/cuemseditor/CuemsDBModel.py
144 145 146 147 148 149 150 151 152 153 154 155 156 | |
Project
Bases: CuemsBaseModel
ORM model for a CueMS project record.
Each row corresponds to one project directory under
library_path/projects/<unix_name>/. The in_trash flag moves the
project to the trash rather than hard-deleting it, preserving the DB
record and unique-name constraints.
Attributes:
| Name | Type | Description |
|---|---|---|
uuid |
Primary key; also the |
|
name |
Human-readable display name (unique, sanitized). |
|
unix_name |
Filesystem-safe directory name (unique, sanitized). |
|
description |
Free-text description; may be |
|
created |
Creation timestamp. |
|
modified |
Last-save timestamp. |
|
in_trash |
|
Source code in src/cuemseditor/CuemsDBModel.py
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 | |
all_fields()
staticmethod
Return the full column list for use in explicit SELECT clauses.
Returns:
| Type | Description |
|---|---|
|
List of Peewee field descriptors covering every column on |
|
|
|
Source code in src/cuemseditor/CuemsDBModel.py
61 62 63 64 65 66 67 68 69 | |
medias()
Query all Media records linked to this project.
Joins through ProjectMedia and returns each media file with a
count alias (number of ProjectMedia rows for the pair).
Returns:
| Type | Description |
|---|---|
|
Peewee |
Source code in src/cuemseditor/CuemsDBModel.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
ProjectMedia
Bases: CuemsBaseModel
Many-to-many join table linking projects to their media files.
media_filename is a denormalized copy of Media.unix_name kept
alongside the foreign key so that queries can match on filename without
an extra join to Media.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Auto-increment surrogate primary key. |
|
project |
FK to |
|
media |
FK to |
|
media_filename |
Denormalized |
Source code in src/cuemseditor/CuemsDBModel.py
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 | |
missing_refs()
Query ProjectMedia rows whose Media or Project FK is dangling.
Returns:
| Type | Description |
|---|---|
|
Peewee |
|
|
|
Source code in src/cuemseditor/CuemsDBModel.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
ensure_media_columns(db)
Add the missing media columns to an existing database.
create_tables(safe=True) creates missing tables but never adds a
column to an existing one, and the editor has no migration framework, so
this runs at every start (CuemsDBManager) and in the repair tool,
which opens the database itself. Additive and idempotent: an older
editor still reads the migrated database (peewee selects named columns).
Returns:
| Type | Description |
|---|---|
|
The names of the columns added (empty when nothing was missing). |
Raises:
| Type | Description |
|---|---|
Any database error
|
the caller must not carry on with a model the |
Source code in src/cuemseditor/CuemsDBModel.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
missing_media_columns(db)
Added media columns that this database does not have yet.
Source code in src/cuemseditor/CuemsDBModel.py
217 218 219 220 | |
CuemsDBProject
Bases: StringSanitizer
Project CRUD, XML script I/O, and filesystem directory management.
Each CueMS project lives at
<projects_path>/<unix_name>/cue_script.xml. All mutating operations
are wrapped in Peewee atomic transactions with rollback; filesystem
changes are reversed on failure where possible.
User-supplied name strings are sanitised via the inherited
StringSanitizer methods before being used as directory names or
stored in the database.
Example
db_project = CuemsDBProject(settings_dict, database) uuid = db_project.new({"CuemsScript": {"name": "My Show", ...}}, "my-show") project_data = db_project.load(uuid) db_project.update(uuid, project_data) db_project.delete(uuid) # soft-delete → trash db_project.restore(uuid) # restore from trash db_project.delete_from_trash(uuid) # permanent delete
Source code in src/cuemseditor/CuemsDBProject.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 | |
__init__(settings_dict, db_connection)
Initialise paths from settings_dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_dict
|
Mapping consumed from |
required | |
db_connection
|
The shared Peewee |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any required key is missing from settings_dict. |
Source code in src/cuemseditor/CuemsDBProject.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
add_media_relations(project, project_object)
Create ProjectMedia join rows for all media referenced by project_object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
|
required | |
project_object
|
|
required |
Source code in src/cuemseditor/CuemsDBProject.py
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 | |
delete(uuid)
Soft-delete a project by moving it to the trash directory.
The project directory is moved via CopyMoveVersioned.move to
<trash_path>/. The DB row's in_trash flag is set to True
atomically. On any failure the directory is moved back and the
transaction is rolled back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of the live project to trash. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no live project with uuid exists. |
Exception
|
Re-raises after rollback and filesystem cleanup. |
Source code in src/cuemseditor/CuemsDBProject.py
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | |
delete_from_trash(uuid)
Permanently delete a trashed project: remove the DB record and directory.
Calls project.delete_instance(recursive=True) to cascade-delete
ProjectMedia join rows, then removes the project directory tree
with shutil.rmtree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of a project that is currently in the trash. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no trashed project with uuid exists. |
Exception
|
Re-raises after rolling back the transaction (directory may already be gone at that point). |
Source code in src/cuemseditor/CuemsDBProject.py
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 | |
deletele_mising_media_references(media_filename)
Delete ProjectMedia rows whose media_id FK is NULL for media_filename.
Cleans up dangling join rows left when a Media record was replaced
by a re-upload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
media_filename
|
|
required |
Source code in src/cuemseditor/CuemsDBProject.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 | |
duplicate(uuid)
Duplicate a project: copy the directory and create a new DB record.
The copy is named <original_name> - Copy; a numeric suffix
(N) is appended if the name is taken by another live or trashed
record. The duplicated cue_script.xml has its CuemsScript.id
and name updated to match the new DB record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of the project to duplicate; must be a live project. |
required |
Returns:
| Type | Description |
|---|---|
|
New project UUID string. |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If the source project does not exist. |
Exception
|
Re-raises after rollback and copy cleanup. |
Source code in src/cuemseditor/CuemsDBProject.py
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
get_project_unix_name(uuid)
Return the filesystem directory name for a live (non-trashed) project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Project UUID string. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no live project with uuid exists. |
Source code in src/cuemseditor/CuemsDBProject.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
list()
Return a list of all live (non-trashed) projects, newest first.
Returns:
| Type | Description |
|---|---|
|
List of single-key dicts ``{uuid_str: {name, unix_name, |
|
|
description, created, modified}} |
|
|
descending. |
Example
projects = db_project.list() for entry in projects: ... uuid, meta = next(iter(entry.items())) ... print(uuid, meta['name'])
Source code in src/cuemseditor/CuemsDBProject.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
list_trash()
Return a list of all trashed projects, newest first.
Returns:
| Type | Description |
|---|---|
|
Same shape as :meth: |
|
|
|
Source code in src/cuemseditor/CuemsDBProject.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 | |
load(uuid, include_trash=False)
Load a project's CuemsScript dict from its XML file on disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Project UUID string. |
required | |
include_trash
|
When |
False
|
Returns:
| Type | Description |
|---|---|
|
|
|
|
|
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no project with uuid exists (or the
project is in the trash and include_trash is |
Source code in src/cuemseditor/CuemsDBProject.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
load_xml(unix_name)
Read and parse <projects_path>/<unix_name>/cue_script.xml.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unix_name
|
Project directory name. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsDBProject.py
1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 | |
media_report(project_uuid, context, reason=None)
The value of a media_check_report frame (plan §8.3), read-only.
files: the stale values the project holds, by file, capped at
:data:REPORT_FILES_MAX (total_files counts them all).
unverified: files whose size or index no longer matches their row
and that have not been measured yet. complete is false when part
of the check did not run (reason, or a file whose probe failed
before): the UI must not take that report as an all-clear.
Source code in src/cuemseditor/CuemsDBProject.py
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 | |
new(data, unix_name)
Create a new project: allocate a UUID, write the XML, insert the DB row.
The project directory <projects_path>/<unix_name>/ and its
cue_script.xml are created inside an atomic transaction. The
directory is removed on rollback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
|
required | |
unix_name
|
Raw directory name candidate supplied by the frontend;
sanitised via |
required |
Returns:
| Type | Description |
|---|---|
|
New project UUID string. |
Raises:
| Type | Description |
|---|---|
IntegrityError
|
If |
KeyError
|
If |
Exception
|
Re-raises after rollback and directory cleanup. |
Source code in src/cuemseditor/CuemsDBProject.py
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | |
plan_media_refresh(project_uuid)
Step 1 of the load-time check: read and compare, write nothing.
Reads the project file without the schema, finds each file it uses,
compares the file with its row (size; and the .idx header of a
video the sync carries), and lists the values present in the project
that no longer match their rows (:func:stale_by_file).
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
no live project with project_uuid. |
Source code in src/cuemseditor/CuemsDBProject.py
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | |
restore(uuid)
Restore a trashed project back to the active projects directory.
Moves the directory from <trash_path>/ to <projects_path>/
via CopyMoveVersioned.move, which handles name collisions by
appending a numeric suffix. The DB record's unix_name is updated
to the actual destination name and in_trash is set to False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
UUID of the trashed project to restore. |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no trashed project with uuid exists. |
Exception
|
Re-raises after rollback and filesystem cleanup. |
Source code in src/cuemseditor/CuemsDBProject.py
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 | |
save_xml(unix_name, project_object)
Write project_object to <projects_path>/<unix_name>/cue_script.xml.
Validates against script.xsd before writing; raises if the
CuemsScript object fails schema validation.
The file is replaced atomically (869fat84r D20): written to a
temporary file in the same directory, given the old file's mode (the
nodes' rsync reads it as nobody), then renamed over it, so a power
cut never leaves a truncated project. A directory the editor cannot
create files in falls back to writing in place, as before.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unix_name
|
Project directory name. |
required | |
project_object
|
|
required |
Source code in src/cuemseditor/CuemsDBProject.py
1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 | |
update(uuid, data)
Save an edited project: update DB metadata and rewrite the XML file.
Runs inside a Peewee atomic transaction. The XML is validated
against script.xsd by XmlReaderWriter.write_from_object —
an invalid cue tree raises before any persistent change is made.
A pre-save pass via :meth:_fix_media_durations corrects zero
durations sent by the frontend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
Project UUID string; must match |
required | |
data
|
|
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If the project does not exist or is in the trash. |
Exception
|
Re-raises any error after rolling back the transaction. |
Source code in src/cuemseditor/CuemsDBProject.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | |
update_existed_media_uuid(media_filename, old_media_uuid)
Overwrite the UUID of a Media row to match the value recorded in project XML.
Used when a re-uploaded file produces a new UUID in the DB that differs from the UUID stored inside existing project XML files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
media_filename
|
|
required | |
old_media_uuid
|
The UUID string to assign (taken from the XML). |
required |
Raises:
| Type | Description |
|---|---|
NonExistentItemError
|
If no |
Source code in src/cuemseditor/CuemsDBProject.py
1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 | |
update_media_relations(project, project_object)
Diff and sync ProjectMedia join rows after a project save.
Computes the symmetric difference between the old and new media sets,
then removes stale ProjectMedia rows and creates new ones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
|
required | |
project_object
|
|
required |
Source code in src/cuemseditor/CuemsDBProject.py
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 | |
update_projects_existed_media(project_uuid, media_filename)
Re-link a re-uploaded media file to the projects that referenced it by filename.
Called after CuemsUpload detects that media_filename was already
referenced by one or more projects. Reads the XML, finds matching
cues, and reconciles the stored media UUID with what is now in the DB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID of the project to update. |
required | |
media_filename
|
|
required |
Source code in src/cuemseditor/CuemsDBProject.py
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | |
verify_media_files(plan, deadline, clock=time.monotonic)
Step 2: re-probe each changed or legacy file and correct its row.
Stops at deadline (a clock value); the files not reached go first at the next load. One file that fails is logged and skipped.
Returns:
| Type | Description |
|---|---|
|
|
|
|
|
Source code in src/cuemseditor/CuemsDBProject.py
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 | |
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
DurationFixStats
Result of a :func:fix_media_durations_in_contents walk.
Attributes:
| Name | Type | Description |
|---|---|---|
media_refs |
Number of cue |
|
replacements |
Number of |
|
dimension_changes |
Number of |
|
orphans |
List of |
|
errors |
|
Source code in src/cuemseditor/CuemsDBProject.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
MediaFileCheck
Step 1's verdict on one file a project uses.
state: unchanged, changed (its size differs from the row, or
its video index was made for another file), legacy (the row has no
stored size yet), or skipped (its duration could not be read before
and the file has not changed since).
Source code in src/cuemseditor/CuemsDBProject.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
RefreshPlan
What a load must do before the engine is asked, and what the project holds that is stale (step 1, read-only).
Source code in src/cuemseditor/CuemsDBProject.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
has_work
property
Files to measure or to index. Stale values alone are reported, not work: they cost no engine query and no probe.
cap_report_files(entries, cap=None)
At most cap (:data:REPORT_FILES_MAX) entries, and their full count.
Source code in src/cuemseditor/CuemsDBProject.py
513 514 515 516 | |
db_dimensions_resolver(file_name)
Resolve a media unix_name to its stored size (see
:func:dimensions_of_row), or None when unknown. Read-only: no probe.
Raises KeyError when no Media row exists for file_name.
Source code in src/cuemseditor/CuemsDBProject.py
114 115 116 117 118 119 120 121 122 123 124 | |
db_duration_resolver(file_name)
Resolve a media unix_name to its stored duration string (or None).
Raises KeyError when no Media row exists for file_name, so the
walk can distinguish an orphaned reference from a present-but-NULL duration.
Source code in src/cuemseditor/CuemsDBProject.py
101 102 103 104 105 106 107 108 109 110 111 | |
dimensions_of_row(media)
What a Media row knows about its file: pixel_width and
pixel_height (both or neither), file_size, file_md5; only the
valid ones. None when it knows nothing.
Source code in src/cuemseditor/CuemsDBProject.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
fix_media_durations_in_contents(contents, resolver, dimensions_resolver=None)
Overwrite each cue Media's duration, and VideoCues' stored size,
from the resolvers, in place.
Shared by the WebSocket save path (:meth:CuemsDBProject._fix_media_durations)
and the standalone repair script, so both trust the same DB source of
truth and walk cue trees identically. Each caller passes its own
resolvers: only the save path's may probe and write the DB.
For every Media block, in this order:
- a
pixel_width/pixel_height/file_sizethat is not a positive integer, or afile_md5that is not 32 hex digits, is removed, whatever the cue: the parser assigns these keys raw, and the schema would reject the whole save; an AudioCue loses the pixel size (it belongs to VideoCues); - the duration, from resolver (an orphan stops here, untouched);
- the stored values, from dimensions_resolver when given: the pixel
size, size and MD5 on a VideoCue, size and MD5 on an AudioCue (D18).
They replace the client's;
None(unknown) removes them.
One block that fails is logged and skipped; the walk goes on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contents
|
|
required | |
resolver
|
callable |
required | |
dimensions_resolver
|
optional callable |
None
|
Returns:
| Type | Description |
|---|---|
|
class: |
Source code in src/cuemseditor/CuemsDBProject.py
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 | |
mark_index_failed(path)
Do not try to rebuild path's index again until the file changes.
Source code in src/cuemseditor/CuemsDBProject.py
428 429 430 431 432 | |
reset_refresh_marks()
Forget every in-memory mark (tests).
Source code in src/cuemseditor/CuemsDBProject.py
414 415 416 417 | |
stale_by_file(blocks, rows)
The stale values of a project, one entry per file:
[{file_name, cues, changes}], cues counting the cues whose block
holds stale values for that file.
Source code in src/cuemseditor/CuemsDBProject.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
stale_changes(cue_type, values, row)
The values PRESENT in this Media block that the fill would change.
The same decisions as :func:_fix_one_media, on normalised values, so a
value read as a string from the file is compared as the int the fill
writes. A value that is only missing (a project written before rc15) is
not stale: the next save adds it. Returns [{field, stored, current}],
field one of duration, pixel_size ("WxH"), file_size,
file_md5; current is None when the fill would remove it.
Source code in src/cuemseditor/CuemsDBProject.py
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 | |
validate_fade_durations_in_contents(contents)
Reject any FadeCue whose duration is missing, unparseable, or <= 0.
Save-time gate: CuemsParser/GenericParser assigns via
dict.__setitem__, bypassing FadeCue.set_duration's own
positive-and-non-zero rule, so a zero coming from a client would reach
the XML and later become a silent no-op at reveal (gradient-motiond
drops dur <= 0 over fire-and-forget UDP). Collects ALL offenders and
raises a single ValueError; the WS layer forwards the text to the
client.
Source code in src/cuemseditor/CuemsDBProject.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
validate_media_cues_in_contents(contents, media_exists=None)
Reject any AudioCue/VideoCue without a usable media block.
Save-time gate, run BEFORE anything is written. A client that cannot
resolve a cue's file drops the whole Media block (the frontend did
so for files in the media trash); the shapes that then arrive are: no
Media key, None, {}, or a block with an empty file_name
or no id. Without this gate such a save died inside the atomic
block with a bare KeyError 'file_name' from CueList.get_media
(cuems-utils < rc16) — and, had it not died, would have written an
empty <Media/> and lost the cue's media for good.
media_exists(file_name) -> bool lets the DB check that the file is
known (trashed is fine: it can be restored; deleted cannot). Collects
ALL offenders and raises a single ValueError whose text names them;
the WS layer forwards it to the client as is.
Source code in src/cuemseditor/CuemsDBProject.py
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 | |
CuemsLibraryMaintenance
Ensures the library directory tree exists before any DB or file operation.
Creates the following structure under library_path on first run::
<library_path>/
├── media/
│ ├── thumbnails/
│ └── waveforms/
├── projects/
└── trash/
├── media/
│ ├── thumbnails/
│ └── waveforms/
└── projects/
Call once at service startup, before CuemsDBManager is constructed.
Example
CuemsLibraryMaintenance("/var/lib/cuems/library")
Source code in src/cuemseditor/CuemsLibraryMaintenance.py
5 6 7 8 9 10 11 12 13 14 15 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 | |
__init__(library_path)
Bootstrap the library directory tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
library_path
|
Absolute path to the root library directory. Created if it does not exist. |
required |
Source code in src/cuemseditor/CuemsLibraryMaintenance.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
create_directory(directory_path)
Create directory_path and all intermediate parents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory_path
|
Absolute path to create. |
required |
Source code in src/cuemseditor/CuemsLibraryMaintenance.py
52 53 54 55 56 57 58 59 | |
ensure_directories(directories)
Create any missing directories from directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
Iterable of absolute directory paths to verify/create. |
required |
Source code in src/cuemseditor/CuemsLibraryMaintenance.py
42 43 44 45 46 47 48 49 50 | |
CuemsDBManager
Database facade that owns the SQLite connection, schema creation, and
the project / media sub-managers.
Initialise exactly once per process after CuemsLibraryMaintenance
has created the library directory tree. The shared database
singleton is initialised and connected here; CuemsDBProject and
CuemsDBMedia receive the same connection object.
Attributes:
| Name | Type | Description |
|---|---|---|
project |
|
|
media |
|
Example
settings = { ... "database_name": "cuems.db", ... "library_path": "/var/lib/cuems/library", ... "project_folder_name": "projects", ... "media_folder_name": "media", ... "trash_folder_name": "trash", ... "tmp_path": "/tmp/cuems", ... "script_file_name": "cue_script.xml", ... "script_schema_name": "script.xsd", ... "thumbnail_folder_name": "thumbnails", ... "waveform_folder_name": "waveforms", ... "thumbnail_extension": ".jpg", ... "waveform_extension": ".json", ... "thumbnail_size": [240, 120], ... } db = CuemsDBManager(settings) projects = db.project.list() media_files = db.media.list()
Source code in src/cuemseditor/CuemsProjectManager.py
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 | |
__init__(settings_dict)
Initialise the database connection and create missing tables.
Calls database.init(path) to bind the shared Peewee
SqliteDatabase to the file at
settings_dict['library_path'] / settings_dict['database_name'],
then calls database.create_tables(..., safe=True) so first-run
tables are created without dropping existing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_dict
|
Mapping consumed from |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in src/cuemseditor/CuemsProjectManager.py
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 | |
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
CuemsUpload
Bases: StringSanitizer
Async binary upload handler for the /upload WebSocket endpoint.
Implements a two-phase upload protocol over a dedicated WebSocket connection (separate from the main project-manager connection):
-
Init phase — client sends a JSON frame:
{"action": "upload", "value": {"name": "...", "size": <bytes>}}. Server responds{"ready": true}and transitions to the data phase. -
Data phase — client sends raw binary frames; server acknowledges each with
{"ready": true}. When all bytes are received the client sends{"action": "finished", "value": "<md5-hex>"}; the server verifies integrity, moves the file into the media library viaCuemsDBMedia.new, and sends{"close": true}.
The tmp file is automatically deleted if the upload fails or the object is garbage-collected.
Example
Inside CuemsWsServer.upload_session:
upload = CuemsUpload(server, websocket) await upload.message_handler()
Source code in src/cuemseditor/CuemsUpload.py
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 | |
__del__()
Clean up the tmp file if the upload session is destroyed mid-transfer.
Source code in src/cuemseditor/CuemsUpload.py
278 279 280 281 282 283 284 285 | |
__init__(server, websocket)
Bind the upload session to server and websocket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
The |
required | |
websocket
|
The WebSocket connection for the |
required |
Source code in src/cuemseditor/CuemsUpload.py
50 51 52 53 54 55 56 57 58 59 60 61 | |
check_file_integrity(path, original_md5)
Verify the MD5 digest of path against original_md5.
Reads the file in 64 KiB chunks to avoid loading large uploads into memory all at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Absolute path to the tmp file. |
required | |
original_md5
|
Hex MD5 string provided by the client. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
FileIntegrityError
|
If the computed digest differs from original_md5. |
Example
upload.check_file_integrity("/tmp/cuems/video.tmp123456", "d41d8cd98f00b204e9800998ecf8427e") True
Source code in src/cuemseditor/CuemsUpload.py
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 | |
check_if_media_existed(filename)
Re-link projects that already referenced filename before this upload.
Queries ProjectMedia for rows whose media_filename matches
filename, then calls
CuemsDBProject.update_projects_existed_media for each referencing
project so their XML UUIDs stay consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Destination filename returned by |
required |
Source code in src/cuemseditor/CuemsUpload.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 | |
message_handler()
async
Main receive loop for the upload WebSocket connection.
Dispatches string frames to :meth:process_upload_message and binary
frames to :meth:process_upload_packet. Exits cleanly when the
WebSocket is closed.
Source code in src/cuemseditor/CuemsUpload.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
message_sender(message)
async
Send a JSON string frame to the client, ignoring closed-connection errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
JSON-serialised string to send. |
required |
Source code in src/cuemseditor/CuemsUpload.py
81 82 83 84 85 86 87 88 89 90 | |
process_upload_message(message)
async
Dispatch a JSON control frame from the client.
Handles the "upload" action by delegating to :meth:set_upload.
Unknown actions are silently ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
Raw JSON string received from the WebSocket. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsUpload.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
process_upload_packet(bin_data)
async
Receive and assemble binary data frames into the tmp file.
Opens the tmp file in write-binary mode and loops, writing each
incoming binary frame and ACKing it with {"ready": true}.
When the client sends the "finished" JSON control frame the loop
exits and :meth:upload_done is called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bin_data
|
First binary frame received (written before the loop). |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsUpload.py
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 | |
set_upload(file_info)
async
Initialise upload state and signal readiness to the client.
Sanitises the filename, creates a unique tmp filename
<name>.tmp<random>, verifies the tmp path is accessible, and
sends {"ready": true} to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_info
|
Dict from the client init frame with at minimum
|
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in src/cuemseditor/CuemsUpload.py
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 | |
tmp_file_path()
Return the absolute path to the current tmp upload file.
Returns:
| Type | Description |
|---|---|
|
Absolute path string, or |
Source code in src/cuemseditor/CuemsUpload.py
269 270 271 272 273 274 275 276 | |
upload_done(received_md5)
async
Verify upload integrity and move the file into the media library.
Steps:
- :meth:
check_file_integrity— verifies the MD5 digest of the tmp file against received_md5. CuemsDBMedia.new— moves the tmp file to the media library and creates the DB record and sidecars.- :meth:
check_if_media_existed— re-links projects that already referenced the uploaded filename. - Sends
{"close": true}to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
received_md5
|
Hex MD5 digest string sent by the client. |
required |
Source code in src/cuemseditor/CuemsUpload.py
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 | |
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
CuemsWsServer
Top-level asyncio WebSocket server for the CueMS editor backend.
Accepts connections on two paths:
/or/?session=<uuid>— main project-manager session handled by :class:CuemsWsUser./upload— binary file upload session handled by :class:CuemsUpload.
Owns the NNG Communicator (engine IPC), the CuemsDBManager, the
active users dict, the sessions state, and a thread-pool
executor for blocking DB and filesystem operations.
Example
server = CuemsWsServer(settings_dict, mappings_dict) server.start(port=9092)
The settings_dict must contain at minimum:
.. code-block:: python
{
"editor_ipc": "ipc:///tmp/cuems-editor.sock",
"tmp_path": "/tmp/cuems",
"session_uuid": "<uuid>",
"library_path": "/var/lib/cuems/library",
# ... plus all keys required by CuemsDBManager
}
Source code in src/cuemseditor/CuemsWsServer.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 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 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 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
__init__(settings_dict, mappings_dict)
Initialise the server: bind the NNG communicator and validate the tmp path.
Does not start listening; call :meth:start to enter the event
loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_dict
|
Settings dict from |
required | |
mappings_dict
|
Output mapping dict from |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required key is absent from settings_dict. |
FileNotFoundError
|
If |
Source code in src/cuemseditor/CuemsWsServer.py
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 | |
check_session(user_session, path)
async
Parse or generate a session UUID from the request path.
If the path carries a ?session=<uuid> parameter and the UUID is
already in self.sessions, it is reused. Otherwise a new UUID is
generated. The session entry is updated with the current WebSocket id
and the UUID is sent to the client via :meth:notify_session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_session
|
The :class: |
required | |
path
|
Request path string. |
required |
Returns:
| Type | Description |
|---|---|
|
Session UUID string. |
Source code in src/cuemseditor/CuemsWsServer.py
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 | |
connection_handler(websocket)
async
Route an incoming WebSocket connection to the correct session type.
/ and /?session=<uuid> go to :meth:project_manager_session;
/upload goes to :meth:upload_session; other paths are logged and
dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
websocket
|
Incoming |
required |
Source code in src/cuemseditor/CuemsWsServer.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
exception_handler(loop, context)
Log uncaught asyncio exceptions at DEBUG level.
Registered as the event loop's exception handler in production mode (currently commented out to keep stack traces visible during development).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loop
|
The asyncio event loop. |
required | |
context
|
Exception context dict provided by asyncio. |
required |
Source code in src/cuemseditor/CuemsWsServer.py
652 653 654 655 656 657 658 659 660 661 662 663 664 | |
initial_json_template()
Build the initial CuemsScript template message sent to new clients.
Returns:
| Type | Description |
|---|---|
|
JSON string |
Source code in src/cuemseditor/CuemsWsServer.py
519 520 521 522 523 524 525 | |
initial_setting_message()
Build the initial mappings message sent to new clients.
Returns:
| Type | Description |
|---|---|
|
JSON string |
Source code in src/cuemseditor/CuemsWsServer.py
544 545 546 547 548 549 550 551 | |
load_session(user_session)
async
Restore session state for a reconnecting user.
Currently a no-op; the commented-out body would re-send the previously loaded project. Reserved for future reconnection support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_session
|
The :class: |
required |
Source code in src/cuemseditor/CuemsWsServer.py
290 291 292 293 294 295 296 297 298 299 300 | |
merge_node_data(existing_nodes, new_nodes)
Merge existing node data (with outputs) with new node data (with updated status).
Matches nodes by UUID and preserves outputs configuration while updating
basic fields (online, adopted, ip, name, node_type,
mac).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
existing_nodes
|
List of existing node dicts with outputs configuration. |
required | |
new_nodes
|
List of new node dicts from |
required |
Returns:
| Type | Description |
|---|---|
|
List of merged node dicts; nodes absent from existing_nodes are |
|
|
included as-is from new_nodes. |
Source code in src/cuemseditor/CuemsWsServer.py
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 | |
nodeconf_available()
Is cuems-nodeconf reachable right now?
Adoption goes engine -> /tmp/nodeconf.ipc, and nodeconf ships disabled on most of the fleet; there every adopt/un-adopt click can only end in an error, so the UI wants to grey the controls instead.
Deliberately sampled per message rather than cached at map-reload time:
nodeconf skips the write when the map's content has not changed, and it
writes nothing at all once it is stopped — so a flag refreshed only on
map changes would happily report true for as long as the operator
left the panel open after systemctl stop cuems-nodeconf.
Source code in src/cuemseditor/CuemsWsServer.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
notify_all_node_list_update()
async
Reload the network map and broadcast the updated node list to all clients.
Runs :meth:reload_network_map_nodes in the thread-pool executor to
avoid blocking the event loop during file I/O. Broadcasts
:meth:initial_setting_message to every connected user on success.
Source code in src/cuemseditor/CuemsWsServer.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
notify_others_list_changes(calling_user, list_type)
async
Notify all other connected users that a list has changed.
Used after project/media create, delete, or restore operations so all open browser tabs refresh their lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calling_user
|
The user who triggered the change; excluded from the notification. |
required | |
list_type
|
String list name to include in the message value (e.g.
|
required |
Source code in src/cuemseditor/CuemsWsServer.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
notify_others_same_project(calling_user, msg_type, project_uuid=None)
async
Notify users who have the same project loaded that it was modified.
If project_uuid is provided, only users with that exact project
loaded are notified. If None, uses the calling user's loaded
project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calling_user
|
The user who triggered the change; excluded from the notification. |
required | |
msg_type
|
Message type string (not currently used in the payload). |
required | |
project_uuid
|
UUID string of the modified project, or |
None
|
Source code in src/cuemseditor/CuemsWsServer.py
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 | |
notify_session(user_session, uuid)
async
Send the assigned session UUID to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_session
|
The :class: |
required | |
uuid
|
Session UUID string to send. |
required |
Source code in src/cuemseditor/CuemsWsServer.py
306 307 308 309 310 311 312 313 314 | |
notify_users(type)
async
Broadcast a message to all connected users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Message type string; only |
required |
Source code in src/cuemseditor/CuemsWsServer.py
387 388 389 390 391 392 393 394 395 396 397 | |
project_manager_session(websocket, path)
async
Manage the full lifecycle of a project-manager WebSocket session.
Creates a :class:CuemsWsUser, registers it, sends the initial
template and mappings messages, then runs the consumer/producer/
processor task set. Cleans up via :meth:unregister on exit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
websocket
|
The accepted WebSocket connection. |
required | |
path
|
The request path (used to extract an optional session UUID). |
required |
Source code in src/cuemseditor/CuemsWsServer.py
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 | |
register(user_session, path)
async
Register a new user session and restore any prior session state.
Adds user_session to self.users, broadcasts the updated user
count, assigns a session_id via :meth:check_session, and calls
:meth:load_session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_session
|
The :class: |
required | |
path
|
Request path string (may carry a |
required |
Source code in src/cuemseditor/CuemsWsServer.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
reload_network_map_nodes()
Reload network_map.xml and update mappings_dict with current node status.
Retries up to 3 times with exponential back-off in case the file is
being written concurrently. Merges the reloaded node data with the
existing mappings_dict via :meth:merge_node_data to preserve
output configurations while refreshing online/adopted status.
Returns:
| Type | Description |
|---|---|
|
|
|
|
retries fail. |
Source code in src/cuemseditor/CuemsWsServer.py
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 506 507 508 509 510 511 512 513 514 515 516 517 | |
run_async_server()
async
Initialise the DB, executor, and WebSocket server, then serve forever.
Called by :meth:start. Sets up:
self.db—CuemsDBManagerinstance.self.executor—ThreadPoolExecutorfor blocking work.self.project_server— thewebsocketsserver object.- SIGINT / SIGTERM handlers that call :meth:
stop.
Source code in src/cuemseditor/CuemsWsServer.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
send_to_project_sessions(project_uuid, message, skip=None)
async
Send message (an encoded frame), as given, to every session whose
last loaded, saved or created project is project_uuid, except
skip (869fat84r D20: media_check_report).
users holds the last project a session touched, not strictly the
one open now: a session that moved on may receive a report for its
previous project, which the UI keys by project.
Source code in src/cuemseditor/CuemsWsServer.py
345 346 347 348 349 350 351 352 353 354 355 356 | |
start(port=None)
Enter the asyncio event loop and start listening for connections.
Blocks until :meth:stop is called (via SIGINT or SIGTERM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
TCP port to listen on. May also be pre-set via
|
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If port is |
Source code in src/cuemseditor/CuemsWsServer.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
stop()
Initiate a graceful shutdown from a signal handler.
Schedules project_server.close() and :meth:stop_async on the
event loop from any thread context.
Source code in src/cuemseditor/CuemsWsServer.py
148 149 150 151 152 153 154 155 156 157 | |
stop_async()
async
Wait for the WebSocket server to finish closing, then stop the event loop.
Source code in src/cuemseditor/CuemsWsServer.py
159 160 161 162 163 164 165 166 167 | |
unregister(user_task)
async
Remove a user session and broadcast the updated user count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_task
|
The :class: |
required |
Source code in src/cuemseditor/CuemsWsServer.py
316 317 318 319 320 321 322 323 324 | |
upload_session(websocket)
async
Handle a binary file upload over the /upload WebSocket path.
Creates a :class:CuemsUpload and runs its :meth:~CuemsUpload.message_handler
until the connection closes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
websocket
|
The accepted WebSocket connection on the |
required |
Source code in src/cuemseditor/CuemsWsServer.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
users_event(type, uuid=None)
Build a users-count or item-modified event message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
|
required | |
uuid
|
Item UUID for non- |
None
|
Returns:
| Type | Description |
|---|---|
|
JSON string. |
Source code in src/cuemseditor/CuemsWsServer.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
watch_network_map()
async
Broadcast the node list whenever cuems-nodeconf rewrites the map.
cuems-nodeconf is resident: it re-merges avahi discovery and rewrites
network_map.xml on every (debounced) avahi event or every 30 s. We used
to read that file only on connect and right after our own successful
nodelist_modify, so a node powered on AFTER the operator opened the
settings panel never appeared in new_nodes — the adoption feature
looked broken exactly when it was needed.
One mtime poll per host (not per client) at NETWORK_MAP_POLL_S; on a change every connected UI gets the refreshed list.
Source code in src/cuemseditor/CuemsWsServer.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
CuemsWsServerError
Bases: Exception
Base exception for all cuems-editor errors.
All other editor exceptions inherit from this class, so callers can
catch CuemsWsServerError to handle any editor-originated failure.
Source code in src/cuemseditor/CuemsErrors.py
1 2 3 4 5 6 | |
EngineError
Bases: CuemsWsServerError
Raised when cuems-engine returns a non-OK NNG IPC response.
Also raised on timeout or connection failure. The str() of the
exception carries the engine's error value or the transport diagnostic.
Example
raise EngineError("Timeout: engine did not respond in 25s for project_load")
Source code in src/cuemseditor/CuemsErrors.py
33 34 35 36 37 38 39 40 41 | |
FileIntegrityError
Bases: CuemsWsServerError
Raised when an uploaded file's MD5 digest does not match the declared value.
Example
raise FileIntegrityError("MD5 mismatch: expected abc123, got def456")
Source code in src/cuemseditor/CuemsErrors.py
9 10 11 12 13 14 | |
NonExistentItemError
Bases: CuemsWsServerError
Raised when a database lookup by UUID or unix_name returns no result.
Example
raise NonExistentItemError("item with uuid: 1234-... does not exist")
Source code in src/cuemseditor/CuemsErrors.py
17 18 19 20 21 22 | |
NotTimeCodeError
Bases: CuemsWsServerError
Raised when a string cannot be parsed as a valid CueMS timecode.
Thrown by CuemsDBMedia.get_duration when ffprobe output does not
match the HH:MM:SS.mmm pattern expected by CTimecode.
Source code in src/cuemseditor/CuemsErrors.py
25 26 27 28 29 30 | |
CuemsWsUser
Per-connection session handler for the project-manager WebSocket endpoint.
Owns two asyncio queues — incoming (fed by :meth:consumer_handler)
and outgoing (drained by :meth:producer_handler). Three concurrent
:meth:consumer coroutines dispatch commands from the incoming queue so
that slow operations (e.g. engine IPC) do not block the interface.
All project and media operations are dispatched to the thread-pool
executor via server.event_loop.run_in_executor so they do not block
the event loop.
Attributes:
| Name | Type | Description |
|---|---|---|
session_id |
UUID string assigned by :meth: |
|
incoming |
|
|
outgoing |
|
Example
The server creates one instance per connection::
user = CuemsWsUser(server, websocket)
await server.register(user, path)
consumer_task = asyncio.create_task(user.consumer_handler())
producer_task = asyncio.create_task(user.producer_handler())
processor_tasks = [asyncio.create_task(user.consumer()) for _ in range(3)]
Source code in src/cuemseditor/CuemsWsUser.py
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 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 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | |
__init__(server, websocket)
Bind the session to server and websocket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
The parent |
required | |
websocket
|
The WebSocket connection for this session. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
comunicate_with_engine(action, action_uuid, engine_command, query_mode=False)
async
Send a command to cuems-engine via NNG and validate the response.
Waits up to TIMEOUT seconds for a response. Validates that the
response carries the expected action_uuid, type, and (unless
query_mode is True) a value of "OK".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
The action string used for type-checking the engine reply. |
required | |
action_uuid
|
UUID string embedded in the command; must be echoed back by the engine. |
required | |
engine_command
|
Dict to send as the NNG request payload. |
required | |
query_mode
|
When |
False
|
Returns:
| Type | Description |
|---|---|
|
|
Raises:
| Type | Description |
|---|---|
EngineError
|
On timeout, connection failure, UUID mismatch, error response, or unexpected response type. |
Example
action_uuid = str(new_uuid()) result = await self.comunicate_with_engine( ... "project_load", ... action_uuid, ... {"action": "project_load", "action_uuid": action_uuid, "value": "my-show"}, ... )
Source code in src/cuemseditor/CuemsWsUser.py
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 | |
consumer()
async
Dequeue and dispatch one command at a time from incoming.
Parses the JSON frame, looks up the action key in the dispatch
map, and awaits the corresponding handler coroutine. Errors at any
stage are caught and reported to the client via
:meth:notify_error_to_user.
The server launches three concurrent instances of this coroutine so that one slow handler (e.g. engine IPC) does not starve the other two.
Source code in src/cuemseditor/CuemsWsUser.py
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 | |
consumer_handler()
async
Read frames from the WebSocket and enqueue them on incoming.
Runs until the WebSocket closes. Connection-closed exceptions are caught and logged at DEBUG level.
Source code in src/cuemseditor/CuemsWsUser.py
64 65 66 67 68 69 70 71 72 73 74 | |
hw_discovery(action)
async
Ask the engine to run a hardware discovery scan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
list_file(action)
async
Send the list of live media files to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name echoed back in the response frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
816 817 818 819 820 821 822 823 824 825 826 827 828 | |
list_file_trash(action)
async
Send the list of trashed media files to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name echoed back in the response frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
911 912 913 914 915 916 917 918 919 920 921 922 923 | |
list_project(action)
async
Send the list of live projects to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name echoed back in the response frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
612 613 614 615 616 617 618 619 620 621 622 623 624 | |
list_project_trash(action)
async
Send the list of trashed projects to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name echoed back in the response frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
706 707 708 709 710 711 712 713 714 715 716 717 718 | |
node_status(action)
async
Ask the engine which nodes are answering right now.
Relays the engine's cluster_status:
{"alive": [...], "adopted": [...], "controller": uuid, "age_s": n}.
This is NOT the same thing as the online field in each node of
initial_mappings: that one is cuems-nodeconf's discovery view
(refreshed within ~30 s), while alive here is the engine's
sub-second ping/pong — the only signal the GO gate trusts. A UI must
show them as two separate indicators; merging them tells the operator
a node is dead when it was merely not seen by the last discovery pass,
or alive when it vanished 20 s ago.
age_s is how stale the probe behind this answer is. A failed or
timed-out call means unknown, never dead: while a project load is
in flight this request queues behind it (the engine serializes editor
commands) and can time out while every node is perfectly healthy.
The reply also carries the last load's diagnosis — missing (project
nodes not in the cluster at all) and unreachable (adopted, used by
the project, no pong). Their cues will not play, and GO is deliberately
not blocked. Nothing is done to them here on purpose: this method
relays the engine's dict verbatim, so new keys reach the browser with
no editor change. Do not add a hop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
nodeconf(action)
async
Ask the engine to run node configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
nodelist_get(action)
async
Re-read network_map.xml and send this client the current node list.
Same payload the client already gets on connect
(initial_mappings: nodes = adopted, new_nodes = discovered
but not adopted), so no new client-side handling is needed — it is just
a way to refresh on demand instead of reconnecting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
nodelist_modify(node_uuid, action, modify_action)
async
Add or remove a node from the engine's active node list.
After a successful engine response, triggers
server.notify_all_node_list_update to broadcast the refreshed
node list to all connected clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_uuid
|
UUID string of the node to add or remove. |
required | |
action
|
Action name from the WebSocket frame (echoed in the reply). |
required | |
modify_action
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If modify_action is not |
Source code in src/cuemseditor/CuemsWsUser.py
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 506 507 508 509 510 511 512 513 | |
notify_error_to_user(msg=None, uuid=None, action=None)
async
Enqueue an error notification to the client.
Three call forms depending on which combination of arguments is provided:
notify_error_to_user(msg=...)— bare error:{"type": "error", "value": msg}.notify_error_to_user(msg=..., action=...)— action error:{"type": "error", "action": action, "value": msg}.notify_error_to_user(msg=..., action=..., uuid=...)— item error:{"type": "error", "uuid": uuid, "action": action, "value": msg}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
Human-readable error description. |
None
|
|
uuid
|
UUID of the subject item, if applicable. |
None
|
|
action
|
Action name that triggered the error, if applicable. |
None
|
Source code in src/cuemseditor/CuemsWsUser.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
notify_user(msg=None, uuid=None, action=None, new_uuid=None)
async
Enqueue a success notification to the client.
Three call forms:
notify_user(msg=...)— state message:{"type": "state", "value": msg}.notify_user(uuid=..., action=...)— action confirmation:{"type": action, "value": uuid}.notify_user(uuid=..., action=..., new_uuid=...)— action with rename:{"type": action, "value": {"uuid": uuid, "new_uuid": new_uuid}}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
Plain state message string. |
None
|
|
uuid
|
Subject item UUID string. |
None
|
|
action
|
Action name echoed back to the client. |
None
|
|
new_uuid
|
New UUID string (used for |
None
|
Source code in src/cuemseditor/CuemsWsUser.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
producer_handler()
async
Dequeue messages from outgoing and send them over the WebSocket.
Runs until the WebSocket closes. Connection-closed exceptions break the loop cleanly.
Source code in src/cuemseditor/CuemsWsUser.py
76 77 78 79 80 81 82 83 84 85 86 87 88 | |
project_deploy(project_uuid, action)
async
Deploy a project to the engine for playback.
Resolves unix_name from the DB and sends a project_deploy
command to the engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to deploy. |
required | |
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
project_ready(project_uuid, action)
async
Tell the engine to arm the project identified by project_uuid.
Resolves the unix_name from the DB, checks the project's media
files first (869fat84r D20; never blocks the load), builds the
project_ready engine command, and awaits the response. After the
reply, the media check's media_check_report goes to this session
and to every other session on the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to arm. |
required | |
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
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 | |
project_status(action)
async
Query the engine for the current project load state without side effects.
Uses query_mode=True so the engine's dict response (not just
"OK") is accepted and forwarded to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
project_unload(action)
async
Tell the engine to unload the current project and clear session state.
On success, sets server.users[self] = None and clears
sessions[session_id]['loaded_project'].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action name from the WebSocket frame (echoed in the reply). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
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 | |
received_file_data(data, action)
async
Update metadata (name, description) for a media file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict with structure |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
received_new_project(data, action, unix_name)
async
Create a new project and notify the client and other users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
|
required | |
action
|
Action name echoed back in the confirmation. |
required | |
unix_name
|
Candidate directory name from the frontend. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
received_project(data, action)
async
Save an edited project and notify the client and other users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
|
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | |
request_delete_file(file_uuid, action)
async
Soft-delete a media file (move to trash) and notify affected clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the media file to trash. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | |
request_delete_file_trash(file_uuid, action)
async
Permanently delete a trashed media file and notify the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the trashed media file to delete permanently. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | |
request_delete_project(project_uuid, action)
async
Soft-delete a project (move to trash) and notify affected clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to trash. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | |
request_delete_project_trash(project_uuid, action)
async
Permanently delete a trashed project and notify the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the trashed project to delete. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
request_duplicate_project(project_uuid, action)
async
Duplicate a project and notify the client and other users.
The reply includes both the original and new UUID so the frontend can navigate to the copy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to duplicate. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | |
request_file_load_meta(file_uuid, action)
async
Send full metadata for a media file to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the media file. |
required | |
action
|
Action name echoed back in the response frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | |
request_file_load_thumbnail(file_uuid, action)
async
Send the thumbnail binary frame for a media file to the client.
The response is a raw binary WebSocket frame with a 36-byte UUID header prepended (not a JSON frame).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the media file. |
required | |
action
|
Action name (used only in error replies). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | |
request_file_load_waveform(file_uuid, action)
async
Send the waveform binary frame for a media file to the client.
The response is a raw binary WebSocket frame with a 36-byte UUID header prepended (not a JSON frame).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the media file. |
required | |
action
|
Action name (used only in error replies). |
required |
Source code in src/cuemseditor/CuemsWsUser.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 | |
request_restore_file(file_uuid, action)
async
Restore a trashed media file and notify affected clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_uuid
|
UUID string of the trashed media file to restore. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | |
request_restore_project(project_uuid, action)
async
Restore a trashed project and notify the client and other users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to restore. |
required | |
action
|
Action name echoed back in the confirmation. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | |
send_project(project_uuid, action)
async
Load a project's XML from disk and send it to the client.
Also records project_uuid as the session's loaded project in
server.users and server.sessions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_uuid
|
UUID string of the project to load. |
required | |
action
|
Action name from the WebSocket frame. |
required |
Source code in src/cuemseditor/CuemsWsUser.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |