pymediawikidocker API Documentation
config
Created on 2023-04-06
@author: wf
Host
Host name getter
Source code in mwdocker/config.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
get_default_host()
classmethod
Get the default host as a usable hostname or IP, never returning reverse-DNS PTRs and avoiding localhost which might cause to try socket access instead of proper host access
Source code in mwdocker/config.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 | |
MwClusterConfig
dataclass
Bases: MwConfig
MediaWiki Cluster configuration for multiple wikis
Source code in mwdocker/config.py
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 | |
addArgs(parser)
add my arguments to the given parser
Source code in mwdocker/config.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | |
fromArgs(args)
initialize me from the given commmand line arguments
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args(Namespace)
|
the command line arguments |
required |
Source code in mwdocker/config.py
590 591 592 593 594 595 596 597 598 599 600 601 602 | |
MwConfig
MediaWiki and docker configuration for a Single Wiki
Source code in mwdocker/config.py
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 | |
has_external_db
property
Check if using external database container
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if db_container_name differs from default pattern |
__post_init__()
post initialization configuration
Source code in mwdocker/config.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
addArgs(parser)
add Arguments to the given parser
Source code in mwdocker/config.py
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 | |
addExtensions(extensionNameList)
add extensions for the given list of extension names
Source code in mwdocker/config.py
327 328 329 330 331 332 333 334 335 | |
as_dict()
return my fields as a dict dataclasses to dict conversion convenienc and information hiding
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
my fields in dict format |
Source code in mwdocker/config.py
186 187 188 189 190 191 192 193 194 195 | |
as_json()
return me as a json string
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
my json representation |
Source code in mwdocker/config.py
197 198 199 200 201 202 203 204 205 206 | |
create_random_password(length=15)
create a random password
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length(int)
|
the length of the password |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
a random password with the given length |
Source code in mwdocker/config.py
272 273 274 275 276 277 278 279 280 281 282 283 | |
default_docker_path()
get the default docker path
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
$HOME/.pymediawikidocker |
Source code in mwdocker/config.py
115 116 117 118 119 120 121 122 123 124 | |
fromArgs(args)
initialize me from the given commmand line arguments
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args(Namespace)
|
the command line arguments |
required |
Source code in mwdocker/config.py
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 | |
getExtensionMap(extensionNameList=None, extensionJsonFile=None)
get map of extensions to handle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extensionNameList
|
list
|
a list of extension names |
None
|
extensionJsonFile
|
str
|
the name of an extra extensionJsonFile (if any) |
None
|
Source code in mwdocker/config.py
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 | |
getShortVersion(separator='')
get my short version e.g. convert 1.27.7 to 127
Returns:
| Name | Type | Description |
|---|---|---|
str |
the short version string |
Source code in mwdocker/config.py
259 260 261 262 263 264 265 266 267 268 269 270 | |
getWikiId()
get the wikiId
Returns:
| Name | Type | Description |
|---|---|---|
str |
e.g. mw-9080 |
Source code in mwdocker/config.py
285 286 287 288 289 290 291 292 293 294 295 296 | |
get_config_path()
get my configuration base path
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
the path to my configuration |
Source code in mwdocker/config.py
208 209 210 211 212 213 214 215 216 217 218 | |
load(path=None)
load the the MwConfig from the given path of if path is None (default) use the config_path for the current configuration
restores the ExtensionMap on load
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path(str)
|
the path to load from |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MwConfig |
MwConfig
|
a MediaWiki Configuration |
Source code in mwdocker/config.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
reset_container_base_name(container_base_name=None)
reset the container base name to the given name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_base_name(str)
|
the new container base name |
required |
Source code in mwdocker/config.py
176 177 178 179 180 181 182 183 184 | |
reset_url(url)
reset my url
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url(str)
|
the url to set |
required |
Source code in mwdocker/config.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
save(path=None)
save my json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path(str)
|
the path to store to - if None use {docker_path}/{container_base_name}/MwConfig.json |
required |
Returns: str: the path
Source code in mwdocker/config.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
docker
Created on 2021-08-06
@author: wf
DBStatus
dataclass
the Database Status
Source code in mwdocker/docker.py
157 158 159 160 161 162 163 164 165 166 167 | |
DockerApplication
Bases: object
MediaWiki Docker image
Source code in mwdocker/docker.py
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 | |
__init__(config)
Constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MwClusterConfig
|
MwClusterConfig, |
required |
home
|
the home directory to use |
required |
Source code in mwdocker/docker.py
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 | |
check()
check me
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
exitCode: 0 if ok, 1 if not ok |
Source code in mwdocker/docker.py
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 | |
checkDBConnection(timeout=10, initialSleep=4.0, factor=1.5, maxTries=9)
check database connection with retries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
number of seconds for timeout |
10
|
initialSleep
|
float
|
number of seconds to initially wait/sleep |
4.0
|
maxTries
|
int
|
maximum number of retries before giving up between each try a sleep is done that starts |
9
|
Returns:
| Name | Type | Description |
|---|---|---|
dbStatus |
DBStatus
|
the status |
Source code in mwdocker/docker.py
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 | |
checkDockerEnvironment(debug=False)
staticmethod
check the docker environment
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
debug
|
bool
|
if True show debug information |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
an error message or None |
Source code in mwdocker/docker.py
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 | |
checkWiki(version_url)
check this wiki against the content of the given version_url
Source code in mwdocker/docker.py
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 | |
close()
close the database
Source code in mwdocker/docker.py
418 419 420 421 422 | |
createOrModifyWikiUser(wikiId, force_overwrite=False, lenient=False)
create or modify the WikiUser for this DockerApplication
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wikiId
|
str
|
the wikiId to create or modify a wiki user for |
required |
force_overwrite
|
bool
|
if True overwrite the wikiuser info |
False
|
lenient(bool)
|
do not throw Exception if wikiuser exists |
required |
Source code in mwdocker/docker.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
createWikiUser(wikiId=None, store=False)
create my wikiUser and optionally save it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
bool
|
if True save my user data to the relevant ini File |
False
|
Source code in mwdocker/docker.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
dbClose()
close the database connection
Source code in mwdocker/docker.py
441 442 443 444 445 446 | |
dbConnect(timeout=10)
connect to the database and return the connection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
number of seconds for timeout |
10
|
Returns:
| Type | Description |
|---|---|
|
the connection |
Source code in mwdocker/docker.py
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 | |
doCheckDBConnection(dbStatus, timeout=10)
check the database connection of this application
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
how many seconds to wait |
10
|
Returns:
| Type | Description |
|---|---|
|
DBStatus |
Source code in mwdocker/docker.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
down(forceRebuild=False)
run docker compose down
see https://docs.docker.com/engine/reference/commandline/compose_down/ and https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/#down
Source code in mwdocker/docker.py
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 | |
execute(*commands)
Execute the given variable list of command strings inside the MediaWiki container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
str
|
str - command parts to be executed |
()
|
Source code in mwdocker/docker.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
genComposerRequire(composerFilePath, overwrite=False)
gen the composer.local.json require file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
composerFilePath
|
str
|
the name of the file to generate |
required |
Source code in mwdocker/docker.py
616 617 618 619 620 621 622 623 624 | |
generate(templateName, targetPath, overwrite=False, **kwArgs)
generate file at targetPath using the given templateName
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templateName
|
str
|
the Jinja2 template to use |
required |
targetPath
|
str
|
the path to the target file |
required |
overwrite
|
bool
|
if True overwrite existing files |
False
|
kwArgs()
|
generic keyword arguments to pass on to template rendering |
required |
Source code in mwdocker/docker.py
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 | |
generateAll(overwrite=False)
generate all files needed for the docker handling
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overwrite
|
bool
|
if True overwrite the existing files |
False
|
Source code in mwdocker/docker.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 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 | |
getComposerRequire()
get the json string for the composer require e.g. composer.local.json
Source code in mwdocker/docker.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
getContainerName(kind, separator)
get my container Name
Source code in mwdocker/docker.py
312 313 314 315 316 317 | |
getContainers()
get my containers
Returns:
| Type | Description |
|---|---|
|
Tuple( |
Source code in mwdocker/docker.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
getJinjaEnv()
get a Jinja2 environment
Source code in mwdocker/docker.py
342 343 344 345 346 347 348 349 350 351 | |
get_version_url(host_port)
get the Special:Version url
Source code in mwdocker/docker.py
234 235 236 237 238 239 240 241 242 243 | |
optionalWrite(targetPath, content, overwrite=False)
optionally Write the modified content to the given targetPath
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targetPath
|
str
|
the path to write the content to |
required |
content
|
str
|
the content to write |
required |
overwrite
|
bool
|
if True overwrite the existing content |
False
|
Source code in mwdocker/docker.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
prepare_external_db_access(network_name='db', db_alias='db')
make sure the external database container can be reached
Source code in mwdocker/docker.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | |
setupMediaWiki()
setup MediaWiki via the generated script with explicit args
Source code in mwdocker/docker.py
940 941 942 943 944 945 946 947 948 949 950 951 952 | |
sqlQuery(query)
run the given SQL query
Source code in mwdocker/docker.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
start(forceRebuild=False, withInitDB=True)
start my containers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forceRebuild
|
bool
|
if True force rebuilding |
False
|
withInitDB
|
bool
|
if True intialize my database |
True
|
Source code in mwdocker/docker.py
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 | |
up(forceRebuild=False)
start this docker application
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forceRebuild
|
bool
|
if true stop and remove the existing containers |
False
|
Source code in mwdocker/docker.py
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 | |
DockerContainer
helper class for docker container info
Source code in mwdocker/docker.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 | |
__init__(name, kind, container)
constructor
Source code in mwdocker/docker.py
41 42 43 44 45 46 47 | |
check()
check the given docker container
print check message and Return if container is running
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dc
|
the docker container |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the container is not None |
Source code in mwdocker/docker.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
detect_crash()
check that we are still running and get crash details if not
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
None if running, log if crashed |
Source code in mwdocker/docker.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
execute(*commands, verbose=False)
Execute the given variable list of command strings inside the MediaWiki container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
str
|
str - command parts to be executed |
()
|
Source code in mwdocker/docker.py
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 | |
getHostPort(local_port=80)
get the host port for the given local port
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_port
|
int
|
the local port to get the mapping for |
80
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
the host port or None |
Source code in mwdocker/docker.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
wait_for_state(running, interval=0.2, timeout=60.0)
Wait until the container reaches the desired running state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
running
|
bool
|
desired running state (True = wait until started, False = wait until stopped) |
required |
interval
|
float
|
polling interval in seconds |
0.2
|
timeout
|
float
|
max time to wait |
60.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Time in seconds it took to reach the desired state |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
if the desired state is not reached within timeout |
Source code in mwdocker/docker.py
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 | |
docker_map
Created on 2025-08-21
@author: wf
DockerMap
helper class to convert lists of docker elements to maps for improved lookup functionality
Source code in mwdocker/docker_map.py
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 | |
getContainerMap(force_refresh=True)
staticmethod
get a cached map/dict of containers by container name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_refresh
|
bool
|
if True, refresh from docker instead of using cache |
True
|
Source code in mwdocker/docker_map.py
42 43 44 45 46 47 48 49 50 51 52 53 54 | |
html_table
Created on 2022-10-25
@author: wf
HtmlTables
Bases: WebScrape
HtmlTables extractor
Source code in mwdocker/html_table.py
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 60 61 62 | |
__init__(url, debug=False, showHtml=False)
Constructor
url(str): the url to read the tables from debug(bool): if True switch on debugging showHtml(bool): if True show the HTML retrieved
Source code in mwdocker/html_table.py
15 16 17 18 19 20 21 22 23 24 | |
get_tables(header_tag=None)
get all tables from my soup as a list of list of dicts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_tag(str)
|
if set search the table name from the given header tag |
required |
Return
dict: the list of list of dicts for all tables
Source code in mwdocker/html_table.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
logger
Created on 2022-10-25
@author: wf
Logger
Bases: object
simple logger
Source code in mwdocker/logger.py
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 | |
check_and_log(msg, ok)
classmethod
log the given message with the given ok flag
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg(str)
|
the message to log/print |
required | |
ok(bool)
|
if True show ✅ marker else ❌ |
required |
Return
bool: the ok parameter for fluid syntax
Source code in mwdocker/logger.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
mariadb
Created on 2022-10-25
@author: wf
MariaDB
Maria DB handling
Source code in mwdocker/mariadb.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
getVersion(versionStr)
classmethod
get the version from the version String
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
versionStr(str)
|
the version string to check |
required |
Return
str: the extracted version
Source code in mwdocker/mariadb.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
mw
Created on 2021-06-23
@author: wf
Extension
represents a MediaWiki extension
Source code in mwdocker/mw.py
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 | |
asScript(branch='master')
return me as a shell script command line string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
branch
|
str
|
the MediaWiki branch (e.g. REL1_39) |
'master'
|
Source code in mwdocker/mw.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 | |
asWikiMarkup()
return me as wiki Markup
Source code in mwdocker/mw.py
106 107 108 109 110 111 112 113 114 115 116 117 118 | |
fromSpecialVersionTR(exttr, debug=False)
classmethod
Construct an extension from a beautifl soup TR tag derived from Special:Version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exttr
|
the beautiful soup TR tag |
required | |
debug(bool)
|
if True show debugging information |
required |
Source code in mwdocker/mw.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
getDetailsFromUrl(showHtml=False, debug=False)
get more details from my url
Source code in mwdocker/mw.py
92 93 94 95 96 97 98 99 100 101 102 103 104 | |
getLocalSettingsLine(mwShortVersion)
get my local settings line
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mwShortVersion(str)
|
the MediaWiki short version e.g. 127 |
required |
Returns:
| Type | Description |
|---|---|
|
entry for LocalSettings |
Source code in mwdocker/mw.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
ExtensionList
represents a list of MediaWiki extensions
Source code in mwdocker/mw.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 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 | |
fromSpecialVersion(url, excludes=['skin', 'editor'], showHtml=False, debug=False)
classmethod
get an extension List from the given url
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url(str)
|
the Special:Version MediaWiki page to read the information from |
required | |
exclude
|
list
|
a list of types of extensions to exclude |
required |
showHtml(bool)
|
True if the html code should be printed for debugging |
required | |
debug(bool)
|
True if debugging should be active |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ExtensionList |
an extension list derived from the url |
Source code in mwdocker/mw.py
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 | |
restore()
classmethod
restore the extension list
Source code in mwdocker/mw.py
229 230 231 232 233 234 235 236 237 | |
storeFilePrefix()
staticmethod
get my storeFilePrefix
Returns:
| Name | Type | Description |
|---|---|---|
str |
the path to where my stored files (e.g. JSON) should be kept |
Source code in mwdocker/mw.py
180 181 182 183 184 185 186 187 188 189 190 191 | |
mwcluster
Created on 2021-08-06 @author: wf
MediaWikiCluster
Bases: object
a cluster of mediawiki docker Applications
Source code in mwdocker/mwcluster.py
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 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 | |
__init__(config, args=None)
Constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config(MWClusterConfig)
|
the MediaWiki Cluster Configuration to use |
required |
Source code in mwdocker/mwcluster.py
37 38 39 40 41 42 43 44 45 46 | |
check()
check the composer applications
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
exitCode - 0 if ok 1 if failed |
Source code in mwdocker/mwcluster.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
checkDocker()
check the Docker environment
print an error message on stderr if check fails
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
exitCode - 0 if ok 1 if failed |
Source code in mwdocker/mwcluster.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
close()
close my apps
Source code in mwdocker/mwcluster.py
149 150 151 152 153 154 | |
createApps(withGenerate=True)
create my apps
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
withGenerate(bool)
|
if True generate the config files |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
str
|
a dict of apps by version |
Source code in mwdocker/mwcluster.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
down(forceRebuild=False)
run docker compose down
Source code in mwdocker/mwcluster.py
101 102 103 104 105 106 107 108 109 110 | |
getDockerApplication(i, count, version)
get the docker application for the given version index and version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i(int)
|
the index of the version |
required | |
count(int)
|
total number of Docker applications in this cluster |
required | |
version(str)
|
the mediawiki version to use |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DockerApplication |
the docker application |
Source code in mwdocker/mwcluster.py
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 | |
listWikis()
list my wikis
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
exitCode - 0 if ok 1 if failed |
Source code in mwdocker/mwcluster.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
start(forceRebuild=False, withInitDB=True)
create and start the composer applications
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
exitCode - 0 if ok 1 if failed |
Source code in mwdocker/mwcluster.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
mwdocker_cmd
Created on 2025-08-01
@author: wf
MediaWikiDockerCmd
Bases: BaseCmd
pymediawiki docker main
Source code in mwdocker/mwdocker_cmd.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 | |
add_arguments(parser)
add parser arguments
Source code in mwdocker/mwdocker_cmd.py
43 44 45 46 47 48 49 50 51 52 | |
getMwConfig(argv=None, version=None)
get a mediawiki configuration for the given command line arguments
Source code in mwdocker/mwdocker_cmd.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
version
Created on 2022-04-07
@author: wf
Version
Bases: object
Version handling for pymediawikidocker
Source code in mwdocker/version.py
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 | |
webscrape
Created on 2020-08-20
@author: wf
WebScrape
Bases: object
WebScraper
Source code in mwdocker/webscrape.py
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 | |
__init__(debug=False, showHtml=False)
Constructor
Source code in mwdocker/webscrape.py
17 18 19 20 21 22 23 24 | |
getSoup(url, showHtml)
get the beautiful Soup parser
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
showHtml(boolean)
|
True if the html code should be pretty printed and shown |
required |
Source code in mwdocker/webscrape.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
printPrettyHtml(soup)
print the prettified html for the given soup
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soup(BeuatifulSoup)
|
the parsed html to print |
required |
Source code in mwdocker/webscrape.py
41 42 43 44 45 46 47 48 49 | |