Skip to content

Commit 8430644

Browse files
authored
Merge pull request #80231 from sptramer/pep8/1
[Cog Svcs] Format Python code for PEP8 (1)
2 parents 330094d + 52ee216 commit 8430644

File tree

47 files changed

+733
-563
lines changed

Some content is hidden

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

47 files changed

+733
-563
lines changed

articles/api-management/api-management-api-templates.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ The templates in this section allow you to customize the content of the API page
341341

342342
|Property|Type|Description|
343343
|--------------|----------|-----------------|
344-
|`apiId`|string|The id of the current API.|
344+
|`apiId`|string|The ID of the current API.|
345345
|`apiName`|string|The name of the API.|
346346
|`apiDescription`|string|A description of the API.|
347347
|`api`|[API summary](api-management-template-data-model-reference.md#APISummary) entity.|The current API.|
@@ -1359,7 +1359,7 @@ except Exception as e:
13591359
print("[Errno {0}] {1}".format(e.errno, e.strerror))
13601360

13611361
####################################
1362-
```
1362+
```
13631363

13641364
#### Controls
13651365
The code sample templates do not allow the use of any [page controls](api-management-page-controls.md).

articles/app-service/containers/tutorial-python-postgresql-app.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ In this step, you deploy the Postgres-connected Python application to Azure App
281281
Django validates the `HTTP_HOST` header in incoming requests. For your Django app to work in App Service, you need to add the full-qualified domain name of the app to the allowed hosts. Open _azuresite/settings.py_ and find the `ALLOWED_HOSTS` setting. Change the line to:
282282

283283
```python
284-
ALLOWED_HOSTS = [os.environ['WEBSITE_SITE_NAME'] + '.azurewebsites.net', '127.0.0.1'] if 'WEBSITE_SITE_NAME' in os.environ else []
284+
ALLOWED_HOSTS = [os.environ['WEBSITE_SITE_NAME'] + '.azurewebsites.net',
285+
'127.0.0.1'] if 'WEBSITE_SITE_NAME' in os.environ else []
285286
```
286287

287288
Next, Django doesn't support [serving static files in production](https://docs.djangoproject.com/en/2.1/howto/static-files/deployment/), so you need to enable this manually. For this tutorial, you use [WhiteNoise](https://whitenoise.evans.io/en/stable/). The WhiteNoise package is already included in _requirements.txt_. You just need to configure Django to use it.
@@ -391,7 +392,7 @@ Navigate to `<app-name>.azurewebsites.net` and sign in using same admin user you
391392

392393
[!INCLUDE [Access diagnostic logs](../../../includes/app-service-web-logs-access-no-h.md)]
393394

394-
## Manage your app in the Azure Portal
395+
## Manage your app in the Azure portal
395396

396397
Go to the [Azure portal](https://portal.azure.com) to see the app you created.
397398

@@ -424,4 +425,4 @@ Advance to the next tutorial to learn how to map a custom DNS name to your app.
424425
Or, check out other resources:
425426

426427
> [!div class="nextstepaction"]
427-
> [Configure Python app](how-to-configure-python.md)
428+
> [Configure Python app](how-to-configure-python.md)

articles/automation/automation-connections.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,36 +121,40 @@ The following sample shows how to authenticate using the Run As connection in a
121121
import azure.mgmt.resource
122122
import automationassets
123123

124+
124125
def get_automation_runas_credential(runas_connection):
125-
""" Returns credentials to authenticate against Azure resoruce manager """
126-
from OpenSSL import crypto
127-
from msrestazure import azure_active_directory
128-
import adal
129-
130-
# Get the Azure Automation Run As service principal certificate
131-
cert = automationassets.get_automation_certificate("AzureRunAsCertificate")
132-
pks12_cert = crypto.load_pkcs12(cert)
133-
pem_pkey = crypto.dump_privatekey(crypto.FILETYPE_PEM, pks12_cert.get_privatekey())
134-
135-
# Get Run As connection information for the Azure Automation service principal
136-
application_id = runas_connection["ApplicationId"]
137-
thumbprint = runas_connection["CertificateThumbprint"]
138-
tenant_id = runas_connection["TenantId"]
139-
140-
# Authenticate with service principal certificate
141-
resource = "https://management.core.windows.net/"
142-
authority_url = ("https://login.microsoftonline.com/" + tenant_id)
143-
context = adal.AuthenticationContext(authority_url)
144-
return azure_active_directory.AdalAuthentication(
145-
lambda: context.acquire_token_with_client_certificate(
146-
resource,
147-
application_id,
148-
pem_pkey,
149-
thumbprint)
150-
)
126+
""" Returns credentials to authenticate against Azure resoruce manager """
127+
from OpenSSL import crypto
128+
from msrestazure import azure_active_directory
129+
import adal
130+
131+
# Get the Azure Automation Run As service principal certificate
132+
cert = automationassets.get_automation_certificate("AzureRunAsCertificate")
133+
pks12_cert = crypto.load_pkcs12(cert)
134+
pem_pkey = crypto.dump_privatekey(
135+
crypto.FILETYPE_PEM, pks12_cert.get_privatekey())
136+
137+
# Get Run As connection information for the Azure Automation service principal
138+
application_id = runas_connection["ApplicationId"]
139+
thumbprint = runas_connection["CertificateThumbprint"]
140+
tenant_id = runas_connection["TenantId"]
141+
142+
# Authenticate with service principal certificate
143+
resource = "https://management.core.windows.net/"
144+
authority_url = ("https://login.microsoftonline.com/" + tenant_id)
145+
context = adal.AuthenticationContext(authority_url)
146+
return azure_active_directory.AdalAuthentication(
147+
lambda: context.acquire_token_with_client_certificate(
148+
resource,
149+
application_id,
150+
pem_pkey,
151+
thumbprint)
152+
)
153+
151154

152155
# Authenticate to Azure using the Azure Automation Run As service principal
153-
runas_connection = automationassets.get_automation_connection("AzureRunAsConnection")
156+
runas_connection = automationassets.get_automation_connection(
157+
"AzureRunAsConnection")
154158
azure_credential = get_automation_runas_credential(runas_connection)
155159
```
156160

articles/automation/automation-first-runbook-textual-python2.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,14 @@ Use the Compute client to start the VM. Add the following code to the runbook:
149149
```python
150150
# Initialize the compute management client with the RunAs credential and specify the subscription to work against.
151151
compute_client = ComputeManagementClient(
152-
azure_credential,
153-
str(runas_connection["SubscriptionId"])
152+
azure_credential,
153+
str(runas_connection["SubscriptionId"])
154154
)
155155

156156

157157
print('\nStart VM')
158-
async_vm_start = compute_client.virtual_machines.start("MyResourceGroup", "TestVM")
158+
async_vm_start = compute_client.virtual_machines.start(
159+
"MyResourceGroup", "TestVM")
159160
async_vm_start.wait()
160161
```
161162

@@ -184,7 +185,8 @@ Notice that the element of the argument list, `sys.argv[0]`, is the name of the
184185
Now you can modify the last two lines of the runbook to use the input parameter values instead of using hard-coded values:
185186

186187
```python
187-
async_vm_start = compute_client.virtual_machines.start(resource_group_name, vm_name)
188+
async_vm_start = compute_client.virtual_machines.start(
189+
resource_group_name, vm_name)
188190
async_vm_start.wait()
189191
```
190192

articles/azure-cache-for-redis/cache-python-get-started.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ import redis
7979
myHostname = "<Your Host Name>.redis.cache.windows.net"
8080
myPassword = "<Your Access Key>"
8181

82-
r = redis.StrictRedis(host=myHostname, port=6380,password=myPassword,ssl=True)
82+
r = redis.StrictRedis(host=myHostname, port=6380,
83+
password=myPassword, ssl=True)
8384

8485
result = r.ping()
8586
print("Ping returned : " + str(result))
@@ -91,9 +92,9 @@ result = r.get("Message")
9192
print("GET Message returned : " + result.decode("utf-8"))
9293

9394
result = r.client_list()
94-
print("CLIENT LIST returned : ")
95+
print("CLIENT LIST returned : ")
9596
for c in result:
96-
print("id : " + c['id'] + ", addr : " + c['addr'])
97+
print("id : " + c['id'] + ", addr : " + c['addr'])
9798
```
9899

99100
Run the script with Python.

articles/azure-databricks/connect-databricks-excel-python-r.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ The following code snippet performs these tasks:
147147
import pyodbc
148148

149149
# establish a connection using the DSN you created earlier
150-
conn = pyodbc.connect("DSN=<ENTER DSN NAME HERE>", autocommit = True)
150+
conn = pyodbc.connect("DSN=<ENTER DSN NAME HERE>", autocommit=True)
151151

152152
# run a SQL query using the connection you created
153153
cursor = conn.cursor()
@@ -156,7 +156,6 @@ cursor.execute("SELECT * FROM radio_sample_data")
156156
# print the rows retrieved by the query.
157157
for row in cursor.fetchall():
158158
print(row)
159-
160159
```
161160

162161
## Next steps

articles/azure-functions/functions-add-output-binding-storage-queue-python.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def main(req: func.HttpRequest, msg: func.Out[func.QueueMessage]) -> str:
112112
return func.HttpResponse(f"Hello {name}!")
113113
else:
114114
return func.HttpResponse(
115-
"Please pass a name on the query string or in the request body",
116-
status_code=400
115+
"Please pass a name on the query string or in the request body",
116+
status_code=400
117117
)
118118
```
119119

articles/azure-functions/functions-bindings-cosmosdb-v2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ Here's the Python code:
12391239
```python
12401240
import azure.functions as func
12411241

1242+
12421243
def main(queuemsg: func.QueueMessage, documents: func.DocumentList) -> func.Document:
12431244
if documents:
12441245
document = documents[0]
@@ -1293,6 +1294,7 @@ Here's the Python code:
12931294
import logging
12941295
import azure.functions as func
12951296

1297+
12961298
def main(req: func.HttpRequest, todoitems: func.DocumentList) -> str:
12971299
if not todoitems:
12981300
logging.warning("ToDo item not found")
@@ -1351,6 +1353,7 @@ Here's the Python code:
13511353
import logging
13521354
import azure.functions as func
13531355

1356+
13541357
def main(req: func.HttpRequest, todoitems: func.DocumentList) -> str:
13551358
if not todoitems:
13561359
logging.warning("ToDo item not found")

articles/azure-functions/functions-bindings-event-grid.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Here's the Python code:
210210
import logging
211211
import azure.functions as func
212212

213+
213214
def main(event: func.EventGridEvent):
214215
logging.info("Python Event Grid function processed a request.")
215216
logging.info(" Subject: %s", event.subject)

articles/azure-functions/functions-bindings-http-webhook.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ Here's the Python code:
304304
import logging
305305
import azure.functions as func
306306

307+
307308
def main(req: func.HttpRequest) -> func.HttpResponse:
308309
logging.info('Python HTTP trigger function processed a request.')
309310

0 commit comments

Comments
 (0)