-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
45 lines (38 loc) · 1.2 KB
/
example.py
File metadata and controls
45 lines (38 loc) · 1.2 KB
1
2
3
4
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
#!/usr/bin/env python
"""
Example script file showing basic pyacli usage.
"""
import os
from pyacli import site_factory
# Set up your site factories, passing in
# - Site factory URI
# - Username
# - Key
dev_auth = {
"ACSF_FACTORY_URI": os.environ["ACSF_DEV_FACTORY"],
"ACSF_USERNAME": os.environ["ACSF_DEV_USERNAME"],
"ACSF_KEY": os.environ["ACSF_DEV_KEY"],
}
dev_acli = site_factory.SiteFactory(**dev_auth)
test_auth = {
"ACSF_FACTORY_URI": os.environ["ACSF_TEST_FACTORY"],
"ACSF_USERNAME": os.environ["ACSF_TEST_USERNAME"],
"ACSF_KEY": os.environ["ACSF_TEST_KEY"],
}
test_acli = site_factory.SiteFactory(**test_auth)
# Get a list of all sites with IDs
print(dev_acli.get_sites())
# Or filter to specific sites
print(dev_acli.get_sites("mysite1", "mysite2"))
# Run commands directly against multiple factories
print(dev_acli.run(["acsf:sites:find"], wait=False, verbose=False))
print(test_acli.run(["acsf:sites:find"], wait=False, verbose=False))
# Or run one or more commands and wait for the tasks they create to complete
print(
dev_acli.run(
["acsf:sites:clear-cache", "123"],
["acsf:sites:clear-cache", "456"],
interval=5,
max_attempts=10,
)
)