This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient | |
import csv | |
import sys | |
def create_csv(blob_list): | |
try: | |
header = ["blob_name"] # csv file header row (first row) | |
file_name = "blob_list_output.csv" # csv filename | |
with open(file_name, 'w', newline='', encoding="utf-8") as csv_file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_csv(blob_list): | |
try: | |
header = ["blob_name"] # csv file header row (first row) | |
file_name = "blob_list_output.csv" # csv filename | |
with open(file_name, 'w', newline='', encoding="utf-8") as csv_file: | |
writer = csv.writer(csv_file) | |
writer.writerow(header) # write header | |
for blob in blob_list: | |
writer.writerow([blob]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def container_content_list(connection_instance, blob_path): | |
try: | |
blob_name_list = [] | |
source_blob_list = connection_instance.list_blobs(name_starts_with=blob_path) | |
print (source_blob_list) | |
for blob in source_blob_list: | |
blob_name = blob.name.rsplit('/',1)[1] | |
blob_name_list.append(blob_name) | |
print (blob_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient | |
def azure_connect_sas_token(token, account_url, source_container_name): | |
try: | |
blob_source_service_client = BlobServiceClient(account_url = account_url, credential = token) | |
source_container_client = blob_source_service_client.get_container_client(source_container_name) | |
print ("SAS Token -- Connected.") | |
return source_container_client | |
except Exception as ex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient | |
def azure_connect_sas_url(source_container_sas_url, source_container_name): | |
try: | |
blob_source_service_client = BlobServiceClient(source_container_sas_url) | |
source_container_client = blob_source_service_client.get_container_client(source_container_name) | |
print ("SAS URL -- Connected.") | |
return source_container_client | |
except Exception as ex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient | |
def azure_connect_conn_string(source_container_connection_string, source_container_name): | |
try: | |
blob_source_service_client = BlobServiceClient.from_connection_string(source_container_connection_string) | |
source_container_client = blob_source_service_client.get_container_client(source_container_name) | |
print ("Connection String -- Connected.") | |
return source_container_client | |
except Exception as ex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This script will simulate a keypress and prevent Windows from locking | |
import pyautogui | |
import time | |
def no_lock(button): | |
try: | |
print ('Press CTRL+C to stop.') | |
while True: | |
pyautogui.press(button) # Key pressed |