gramex.install
¶
Defines command line services to install, setup and run apps.
install(args, kwargs)
¶
usage: gramex install
“app” is any name you want to locally call the application.
“url” can be a:
- local ZIP file (/path/to/app.zip)
- local directory (/path/to/directory)
- URL of a ZIP file (https://github.com/user/repo/archive/master.zip)
target is the directory to install at (defaults to user data directory.)
After installation, runs “gramex setup” which runs the Makefile, setup.ps1, setup.sh, requirements.txt, setup.py, bower install, npm install, yarn install.
Options:
--cmd="COMMAND"
is a shell command to run. Any word “TARGET” in caps is substituted by the target directory.
Installed apps: {apps}
Source code in gramex\install.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 |
|
setup(args, kwargs)
¶
usage: gramex setup
target is the directory to set up (required). This can be an absolute path, relative path, or a directory name under $GRAMEXPATH/apps/.
gramex setup –all sets up all apps under $GRAMEXPATH/apps/
Run the following commands at that directory in sequence, if possible:
- make
- powershell -File setup.ps1
- bash setup.sh
- pip install –upgrade -r requirements.txt
- python setup.py
- bower –allow-root install
- npm install
- yarn install –prefer-offline
Source code in gramex\install.py
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 |
|
uninstall(args, kwargs)
¶
usage: gramex uninstall
“app” is the name of the locally installed application. You can uninstall multiple applications in one command.
All information about the application is lost. You cannot undo this.
Installed apps: {apps}
Source code in gramex\install.py
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 |
|
run(args, kwargs)
¶
usage: gramex run
“app” is the name of the locally installed application.
If “app” is not installed, specify –target=DIR to run from DIR. The next “gramex run app” will automatically run from DIR.
“dir” is a sub-directory under “target” to run from. This is useful if “app” has multiple sub-applications.
All Gramex command line options can be used. These are saved. For example:
gramex run app --target=/path/to/dir --listen.port=8899 --browser=true
… will preserve the “target”, “listen.port” and “browser” values. Running “gramex run app” will re-use these values. To clear the option, leave the value blank. For example “–browser=” will clear the browser option.
Installed apps: {apps}
Source code in gramex\install.py
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 |
|
service(args, kwargs)
¶
usage: gramex service
Install a Gramex application as a Windows service
gramex service install
--cwd "C:/path/to/application/"
--user "DOMAIN\USER" # Optional user to run as
--password "user-password" # Required if user is specified
--startup manual|auto|disabled
Update the Windows service
gramex service update <same parameters as install>
Remove the Windows service
gramex service remove # or gramex service uninstall
Start / stop commands
gramex service start
gramex service stop
Source code in gramex\install.py
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 |
|
init(args, kwargs)
¶
usage: gramex init [minimal][--target=<path>]
Initializes a Gramex project at the current directory or target path. Specifically, it:
- Sets up a git repo
- Install supporting files for a Gramex project from a template
- “gramex init” sets up all dependencies
- “gramex init minimal” sets up minimal dependencies
- Runs gramex setup (which runs npm install and other dependencies)
Options:
--target <path>
is the location to install at. Defaults to $GRAMEXAPPS
Source code in gramex\install.py
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 |
|
mail(args, kwargs)
¶
usage
gramex mail <key> # Send mail named <key>
gramex mail --list # Lists all keys in config file
gramex mail --init # Initializes config file
The config is a gramex.yaml file. It must have email: and alert: sections. If the current folder has a gramex.yaml, that’s used. Else the default is $GRAMEXDATA/mail/gramexmail.yaml.
Options:
--conf <path>
specifies a different conf file location
Source code in gramex\install.py
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 |
|
license(args, kwargs)
¶
usage: gramex license [accept|reject]
Commands
gramex license # Show Gramex license
gramex license accept # Accept Gramex license
gramex license reject # Reject Gramex license
Source code in gramex\install.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
|
features(args, kwargs)
¶
usage: gramex features [
Counts gramex features used in a project path (or current directory) from gramex.yaml. Prints 3 columns:
- type: SVC=Service, MS=Microservice, KWARG=Config (keyword argument)
- feature: Feature name (e.g. FormHandler)
- count: Number of times the feature is used
Options:
--format [table|json|csv]
picks an output format. Defaults to table
Source code in gramex\install.py
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 |
|
complexity(args, kwargs)
¶
usage: gramex complexity [folder […]]
Source code in gramex\install.py
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 |
|
TryAgainError
¶
If shutil.rmtree fails, and we’ve fixed the problem, raise this to try again
safe_rmtree(target, retries=100, delay=0.05, gramexdata=True)
¶
A replacement for shutil.rmtree and os.remove that removes directories, optionally within $GRAMEXDATA. It tries to remove the target multiple times, recovering from errors.
Source code in gramex\install.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
|
zip_prefix_filter(members, prefix)
¶
Return only ZIP file members starting with directory prefix, with prefix stripped out.
Source code in gramex\install.py
700 701 702 703 704 705 706 707 708 709 710 711 |
|
run_install(config)
¶
Download config.url into config.target. If config.url is a directory, copy it. If config.url is a file or a URL (http, https, ftp), unzip it. If config.contentdir is True, skip parent folders with single subfolder. If no files match, log a warning.
Source code in gramex\install.py
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 |
|
run_command(config)
¶
Run config.cmd. If the command has a TARGET, replace it with config.target. Else append config.target as an argument.
Source code in gramex\install.py
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 |
|
run_setup(target)
¶
Install any setup file in target directory. Target directory can be:
- An absolute path
- A relative path to current directory
- A relative path to the Gramex apps/ folder
Returns the absolute path of the final target path.
Source code in gramex\install.py
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 |
|
get_app_config(appname, kwargs)
¶
Get the stored configuration for appname, and override it with kwargs.
.target
defaults to $GRAMEXDATA/apps/
Source code in gramex\install.py
883 884 885 886 887 888 889 890 891 892 |
|
flatten_config(config, base=None)
¶
Get flattened configurations
Source code in gramex\install.py
895 896 897 898 899 900 901 902 |
|