Skip to content

Commit e56ca3c

Browse files
committed
style: format all py code with ruff
1 parent de19884 commit e56ca3c

File tree

127 files changed

+5637
-3372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+5637
-3372
lines changed

docs/conf.py

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import sys
2121
from datetime import datetime
2222

23-
sys.path.insert(0, os.path.abspath('..'))
23+
sys.path.insert(0, os.path.abspath(".."))
2424

2525
# -- General configuration ------------------------------------------------
2626

@@ -31,35 +31,43 @@
3131
# Add any Sphinx extension module names here, as strings. They can be
3232
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3333
# ones.
34-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosectionlabel', 'sphinx.ext.graphviz',
35-
'sphinx.ext.inheritance_diagram', 'sphinx.ext.viewcode', 'sphinx.ext.autosummary',
36-
'sphinx.ext.githubpages', 'sphinx.ext.napoleon', 'sphinx_rtd_theme']
34+
extensions = [
35+
"sphinx.ext.autodoc",
36+
"sphinx.ext.autosectionlabel",
37+
"sphinx.ext.graphviz",
38+
"sphinx.ext.inheritance_diagram",
39+
"sphinx.ext.viewcode",
40+
"sphinx.ext.autosummary",
41+
"sphinx.ext.githubpages",
42+
"sphinx.ext.napoleon",
43+
"sphinx_rtd_theme",
44+
]
3745

3846
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
47+
templates_path = ["_templates"]
4048

4149
# The suffix(es) of source filenames.
4250
# You can specify multiple suffix as a list of string:
4351
#
4452
# source_suffix = ['.rst', '.md']
45-
source_suffix = '.rst'
53+
source_suffix = ".rst"
4654

4755
# The master toctree document.
48-
master_doc = 'index'
56+
master_doc = "index"
4957

5058
# General information about the project.
51-
project = u'Sysdig SDK for Python'
52-
copyright = f'2016-{datetime.now().year}, Sysdig Inc.'
53-
author = u'Sysdig Inc.'
59+
project = "Sysdig SDK for Python"
60+
copyright = f"2016-{datetime.now().year}, Sysdig Inc."
61+
author = "Sysdig Inc."
5462

5563
# The version info for the project you're documenting, acts as replacement for
5664
# |version| and |release|, also used in various other places throughout the
5765
# built documents.
5866
#
5967
# The short X.Y version.
60-
version = u''
68+
version = ""
6169
# The full version, including alpha/beta/rc tags.
62-
release = u''
70+
release = ""
6371

6472
# The language for content autogenerated by Sphinx. Refer to documentation
6573
# for a list of supported languages.
@@ -71,10 +79,10 @@
7179
# List of patterns, relative to source directory, that match files and
7280
# directories to ignore when looking for source files.
7381
# This patterns also effect to html_static_path and html_extra_path
74-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
82+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7583

7684
# The name of the Pygments (syntax highlighting) style to use.
77-
pygments_style = 'sphinx'
85+
pygments_style = "sphinx"
7886

7987
# If true, `todo` and `todoList` produce output, else they produce nothing.
8088
todo_include_todos = False
@@ -84,7 +92,7 @@
8492
# The theme to use for HTML and HTML Help pages. See the documentation for
8593
# a list of builtin themes.
8694
#
87-
html_theme = 'sphinx_rtd_theme'
95+
html_theme = "sphinx_rtd_theme"
8896

8997
# Theme options are theme-specific and customize the look and feel of a theme
9098
# further. For a list of options available for each theme, see the
@@ -100,23 +108,20 @@
100108
# -- Options for HTMLHelp output ------------------------------------------
101109

102110
# Output file base name for HTML help builder.
103-
htmlhelp_basename = 'python-sdc-clientdoc'
111+
htmlhelp_basename = "python-sdc-clientdoc"
104112

105113
# -- Options for LaTeX output ---------------------------------------------
106114

107115
latex_elements = {
108116
# The paper size ('letterpaper' or 'a4paper').
109117
#
110118
# 'papersize': 'letterpaper',
111-
112119
# The font size ('10pt', '11pt' or '12pt').
113120
#
114121
# 'pointsize': '10pt',
115-
116122
# Additional stuff for the LaTeX preamble.
117123
#
118124
# 'preamble': '',
119-
120125
# Latex figure (float) alignment
121126
#
122127
# 'figure_align': 'htbp',
@@ -126,17 +131,21 @@
126131
# (source start file, target name, title,
127132
# author, documentclass [howto, manual, or own class]).
128133
latex_documents = [
129-
(master_doc, 'python-sdc-client.tex', u'python-sdc-client Documentation',
130-
u'Sysdig Inc.', 'manual'),
134+
(
135+
master_doc,
136+
"python-sdc-client.tex",
137+
"python-sdc-client Documentation",
138+
"Sysdig Inc.",
139+
"manual",
140+
),
131141
]
132142

133143
# -- Options for manual page output ---------------------------------------
134144

135145
# One entry per manual page. List of tuples
136146
# (source start file, name, description, authors, manual section).
137147
man_pages = [
138-
(master_doc, 'python-sdc-client', u'python-sdc-client Documentation',
139-
[author], 1)
148+
(master_doc, "python-sdc-client", "python-sdc-client Documentation", [author], 1)
140149
]
141150

142151
# -- Options for Texinfo output -------------------------------------------
@@ -145,9 +154,15 @@
145154
# (source start file, target name, title, author,
146155
# dir menu entry, description, category)
147156
texinfo_documents = [
148-
(master_doc, 'python-sdc-client', u'python-sdc-client Documentation',
149-
author, 'python-sdc-client', 'One line description of project.',
150-
'Miscellaneous'),
157+
(
158+
master_doc,
159+
"python-sdc-client",
160+
"python-sdc-client Documentation",
161+
author,
162+
"python-sdc-client",
163+
"One line description of project.",
164+
"Miscellaneous",
165+
),
151166
]
152167

153168
# Napoleon settings

examples/add_notification_email.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# Parse arguments
1212
#
1313
if len(sys.argv) != 3:
14-
print(('usage: %s <sysdig-token> email' % sys.argv[0]))
15-
print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
14+
print(("usage: %s <sysdig-token> email" % sys.argv[0]))
15+
print("You can find your token at https://app.sysdigcloud.com/#/settings/user")
1616
sys.exit(1)
1717

1818
sdc_token = sys.argv[1]
@@ -32,7 +32,7 @@
3232
# Return the result
3333
#
3434
if ok:
35-
print('Recipient added successfully')
35+
print("Recipient added successfully")
3636
else:
3737
print(res)
3838
sys.exit(1)

examples/add_policy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
def usage():
13-
print(('usage: %s <sysdig-token>' % sys.argv[0]))
14-
print('Reads policy json from standard input')
15-
print('You can find your token at https://secure.sysdig.com/#/settings/user')
13+
print(("usage: %s <sysdig-token>" % sys.argv[0]))
14+
print("Reads policy json from standard input")
15+
print("You can find your token at https://secure.sysdig.com/#/settings/user")
1616
sys.exit(1)
1717

1818

@@ -29,7 +29,7 @@ def usage():
2929
#
3030
# Instantiate the SDC client
3131
#
32-
sdclient = SdSecureClient(sdc_token, 'https://secure.sysdig.com')
32+
sdclient = SdSecureClient(sdc_token, "https://secure.sysdig.com")
3333

3434
ok, res = sdclient.add_policy_json(policy_json)
3535

examples/add_policy_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
def usage():
13-
print(('usage: %s <sysdig-token>' % sys.argv[0]))
14-
print('Reads policy json from standard input')
15-
print('You can find your token at https://secure.sysdig.com/#/settings/user')
13+
print(("usage: %s <sysdig-token>" % sys.argv[0]))
14+
print("Reads policy json from standard input")
15+
print("You can find your token at https://secure.sysdig.com/#/settings/user")
1616
sys.exit(1)
1717

1818

@@ -29,7 +29,7 @@ def usage():
2929
#
3030
# Instantiate the SDC client
3131
#
32-
sdclient = SdSecureClientV1(sdc_token, 'https://secure.sysdig.com')
32+
sdclient = SdSecureClientV1(sdc_token, "https://secure.sysdig.com")
3333

3434
ok, res = sdclient.add_policy(policy_json)
3535

examples/add_users_to_secure.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,38 @@
2020
# Parse arguments
2121
#
2222
if len(sys.argv) != 2:
23-
print(('usage: %s <sysdig-token>' % sys.argv[0]))
24-
print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
23+
print(("usage: %s <sysdig-token>" % sys.argv[0]))
24+
print("You can find your token at https://app.sysdigcloud.com/#/settings/user")
2525
sys.exit(1)
2626

2727
sdc_token = sys.argv[1]
2828

29-
SECURE_TEAM_NAME = 'Secure Operations'
29+
SECURE_TEAM_NAME = "Secure Operations"
3030

3131
#
3232
# As of when this script was written, the Secure Operations team does
3333
# not have the concepts of RBAC roles like "Read User" vs. "Edit User".
3434
# Rather, all members of the Secure team have full visibility within
3535
# Secure, which is associated with ROLE_TEAM_EDIT.
3636
#
37-
SECURE_TEAM_ROLE = 'ROLE_TEAM_EDIT'
37+
SECURE_TEAM_ROLE = "ROLE_TEAM_EDIT"
3838

3939
#
4040
# Instantiate the SDC client
4141
#
42-
sdclient = SdcClient(sdc_token, sdc_url='https://app.sysdigcloud.com')
42+
sdclient = SdcClient(sdc_token, sdc_url="https://app.sysdigcloud.com")
4343

4444
ok, res = sdclient.list_memberships(SECURE_TEAM_NAME)
4545

4646
if not ok:
47-
print(('Unable to get memberships for ' + SECURE_TEAM_NAME + ' team: ', res))
47+
print(("Unable to get memberships for " + SECURE_TEAM_NAME + " team: ", res))
4848
sys.exit(1)
4949
memberships = res
5050

5151
ok, res = sdclient.get_users()
5252

5353
if not ok:
54-
print(('Unable to get users: ', res))
54+
print(("Unable to get users: ", res))
5555
sys.exit(1)
5656
all_users = res
5757

@@ -60,15 +60,15 @@
6060
# rather than ID, so convert the IDs.
6161
#
6262
for user in all_users:
63-
if user['username'] in memberships:
64-
print(('Will preserve existing membership for: ' + user['username']))
63+
if user["username"] in memberships:
64+
print(("Will preserve existing membership for: " + user["username"]))
6565
else:
66-
print(('Will add new member: ' + user['username']))
67-
memberships[user['username']] = SECURE_TEAM_ROLE
66+
print(("Will add new member: " + user["username"]))
67+
memberships[user["username"]] = SECURE_TEAM_ROLE
6868

6969
ok, res = sdclient.save_memberships(SECURE_TEAM_NAME, memberships=memberships)
7070
if not ok:
71-
print(('Could not edit team:', res, '. Exiting.'))
71+
print(("Could not edit team:", res, ". Exiting."))
7272
sys.exit(1)
7373
else:
7474
print(('Finished syncing memberships of "' + SECURE_TEAM_NAME + '" team'))

examples/create_access_keys.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,40 @@
1212
# Parse arguments
1313
#
1414
if len(sys.argv) != 2:
15-
print('usage: %s <sysdig-token>' % sys.argv[0])
16-
print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
17-
print('For this script to work, the user for the token must have Admin rights')
15+
print("usage: %s <sysdig-token>" % sys.argv[0])
16+
print("You can find your token at https://app.sysdigcloud.com/#/settings/user")
17+
print("For this script to work, the user for the token must have Admin rights")
1818
sys.exit(1)
1919

2020
sdc_token = sys.argv[1]
2121

2222
# Maximum number of agents allowed to connect for this access key. Set to '' if not required
23-
agent_limit = ''
23+
agent_limit = ""
2424
# Number of agent licenses that are ALWAYS available to this access key. This directly counts against the maximum number of available licenses. Set to '' if not required.
25-
agent_reserved = ''
25+
agent_reserved = ""
2626
# Team ID to which to assign the access key. Team ID must be valid. Set to '' if not required.
27-
team_id = ''
27+
team_id = ""
2828

2929

3030
#
3131
# Instantiate the SDC client
3232
#
33-
sdclient = SdcClient(sdc_token, 'https://app.sysdigcloud.com')
33+
sdclient = SdcClient(sdc_token, "https://app.sysdigcloud.com")
3434

3535
#
3636
# Get the configuration
3737
#
38-
ok, res = sdclient.create_access_key(
39-
agent_limit,
40-
agent_reserved,
41-
team_id)
38+
ok, res = sdclient.create_access_key(agent_limit, agent_reserved, team_id)
4239

4340
if ok:
44-
print('Access Key: {}\nTeam ID: {}\nAgent Limit: {}\nAgent Reserved: {}\n==========='.format(res['customerAccessKey']['accessKey'], res['customerAccessKey']['teamId'], res['customerAccessKey']['limit'], res['customerAccessKey']['reservation']))
41+
print(
42+
"Access Key: {}\nTeam ID: {}\nAgent Limit: {}\nAgent Reserved: {}\n===========".format(
43+
res["customerAccessKey"]["accessKey"],
44+
res["customerAccessKey"]["teamId"],
45+
res["customerAccessKey"]["limit"],
46+
res["customerAccessKey"]["reservation"],
47+
)
48+
)
4549
else:
4650
print(res)
4751
sys.exit(1)

examples/create_alert.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# Parse arguments
1717
#
1818
def usage():
19-
print(('usage: %s [-a|--alert <name>] <sysdig-token>' % sys.argv[0]))
20-
print('-a|--alert: Set name of alert to create')
21-
print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
19+
print(("usage: %s [-a|--alert <name>] <sysdig-token>" % sys.argv[0]))
20+
print("-a|--alert: Set name of alert to create")
21+
print("You can find your token at https://app.sysdigcloud.com/#/settings/user")
2222
sys.exit(1)
2323

2424

@@ -45,10 +45,14 @@ def usage():
4545
#
4646
# Find notification channels (you need IDs to create an alert).
4747
#
48-
notify_channels = [{'type': 'SLACK', 'channel': '#python-sdc-test-alert'},
49-
{'type': 'EMAIL', 'emailRecipients': ['[email protected]', '[email protected]']},
50-
{'type': 'SNS', 'snsTopicARNs': ['arn:aws:sns:us-east-1:273107874544:alarms-stg']}
51-
]
48+
notify_channels = [
49+
{"type": "SLACK", "channel": "#python-sdc-test-alert"},
50+
{
51+
"type": "EMAIL",
52+
"emailRecipients": ["[email protected]", "[email protected]"],
53+
},
54+
{"type": "SNS", "snsTopicARNs": ["arn:aws:sns:us-east-1:273107874544:alarms-stg"]},
55+
]
5256

5357
ok, res = sdclient.get_notification_ids(notify_channels)
5458
if not ok:
@@ -62,17 +66,21 @@ def usage():
6266
#
6367
ok, res = sdclient.create_alert(
6468
alert_name, # Alert name.
65-
'this alert was automatically created using the python Sysdig Cloud library', # Alert description.
69+
"this alert was automatically created using the python Sysdig Cloud library", # Alert description.
6670
6, # Syslog-encoded severity. 6 means 'info'.
6771
60, # The alert will fire if the condition is met for at least 60 seconds.
68-
'avg(cpu.used.percent) > 80', # The condition.
69-
['host.mac', 'proc.name'], # Segmentation. We want to check this metric for every process on every machine.
70-
'ANY',
72+
"avg(cpu.used.percent) > 80", # The condition.
73+
[
74+
"host.mac",
75+
"proc.name",
76+
], # Segmentation. We want to check this metric for every process on every machine.
77+
"ANY",
7178
# in case there is more than one tomcat process, this alert will fire when a single one of them crosses the 80% threshold.
7279
'proc.name = "tomcat"',
7380
# Filter. We want to receive a notification only if the name of the process meeting the condition is 'tomcat'.
7481
notification_channel_ids,
75-
False) # This alert will be disabled when it's created.
82+
False,
83+
) # This alert will be disabled when it's created.
7684

7785
#
7886
# Validate a print the results.

0 commit comments

Comments
 (0)