本文整理匯總了Python中azure.storage.TableService類的典型用法代碼示例。如果您正苦於以下問題:Python TableService類的具體用法?Python TableService怎麽用?Python TableService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TableService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: home
def home():
"""Renders the home page."""
form = MessageForm(request.form)
if request.method == 'POST' and form.validate():
#Save to db
table_service = TableService(account_name=config.ACC_NAME,
account_key=config.ACC_KEY)
message = {'PartitionKey': 'message',
'RowKey': form.name.data + datetime.datetime.now().isoformat(),
'name' : form.name.data,
'email': form.email.data,
'date' : str(datetime.datetime.now())}
if form.message_body.data:
message["message"] = form.message_body.data
table_service.insert_entity('landingmessages', message)
return render_template(
'index.html',
hiden_block='#wright-us',
form=form,
)
return render_template(
'index.html',
hiden_block='#got-ur-message',
form=form,
)
示例2: main
def main(argv=None):
#we created four azureML service endpoints to maximize parallelism.
#the program is invoked with one parameter: a number between 0 and 3 that select the
#end point that is used.
#you need to create at least one endpoint
#you also need your stream namespace to listen for events
#and you need a table service to store the results
endpoints=[]
url = 'the original service endpoint url'
api_key = 'the original service key'
endpoints.extend([[url, api_key]])
url2 = 'a second enpoint url'
api_key2 = 'the key for the second'
endpoints.extend([[url2, api_key2]])
url3 = 'the third endpoint url'
api_key3 = 'the key for the third'
endpoints.extend([[url3, api_key3]])
url4 = 'the fourth endpint url'
api_key4 = 'the key for the fourth'
endpoints.extend([[url4, api_key4]])
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "h", ["help"])
except getopt.error, msg:
raise Usage(msg)
bus_service = ServiceBusService(
service_namespace='your stream',
shared_access_key_name='listenpolicy',
shared_access_key_value='your access key')
#next set up the table service
table_service = TableService(account_name='your table account', account_key='account key')
table_service.create_table('scimlevents')
hostname = socket.gethostname()
if len(args)< 1:
print "need the endpoint number"
return 2
endpointid = int(args[0])
url = endpoints[endpointid][0]
api_key = endpoints[endpointid][1]
print url
print api_key
print "starting with endpoint "+str(endpointid)
while True:
print "running"
processevents(table_service, hostname, bus_service, url, api_key)
print "all done."
示例3: __init__
def __init__(self, table):
self._partition = table
with open('azure.txt') as f:
lines = f.readlines()
acc = lines[0].strip()
key = lines[1].strip()
self._table_service = TableService(account_name=acc, account_key=key)
示例4: setUp
def setUp(self):
self.ts = TableService(credentials.getStorageServicesName(),
credentials.getStorageServicesKey())
set_service_options(self.ts)
self.table_name = getUniqueName('uttable')
self.additional_table_names = []
示例5: main
def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "h", ["help"])
except getopt.error, msg:
raise Usage(msg)
#next set up the table service
table_service = TableService(account_name='azure table', account_key='long account key for this storage service')
table_service.create_table('name of table')
hostname = socket.gethostname()
quename = gettopic()
processevents(quename, table_service, hostname)
print "all done."
示例6: __init__
def __init__(self,table):
self.DataCollector = []
self.i=0
self.Table=table
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
self.task = self.table_service.query_entities(self.Table, None, None, 100)
if table=="Customer":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'Name' : line.Name ,
'Country' : line.Country,
'City' : line.City})
self.iteratorCustomer(self.task)
if table=="Order":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'CustomerID' : line.CustomerID,
'ProductID' : line.ProductID,
'Datetime' : line.Datetime,
'TotalPrice' : line.TotalPrice})
self.iteratorOrder(self.task)
示例7: do_step
def do_step(context):
settings = context.meta['settings']
# Prepare the containers
storage_account_name = settings["STORAGE-ACCOUNT-NAME"]
storage_access_key = settings["STORAGE-ACCESS-KEY"]
blob_service = BlobService(storage_account_name, storage_access_key)
blob_service.create_container('bosh')
blob_service.create_container(container_name='stemcell', x_ms_blob_public_access='blob')
# Prepare the table for storing meta datas of storage account and stemcells
table_service = TableService(storage_account_name, storage_access_key)
table_service.create_table('stemcells')
context.meta['settings'] = settings
return context
示例8: __init__
class conobj:
def __init__(self,pikaIP, rabbitid, rabbitpasswd, TableAccountName, TableKey ):
self.ipad = socket.gethostname()
self.pikaIP = pikaIP
self.creds = pika.PlainCredentials(rabbitid, rabbitpasswd)
self.connec = pika.BlockingConnection(pika.ConnectionParameters(pikaIP, 5672,'/',self.creds))
self.chan = self.connec.channel()
self.chan.queue_declare(queue='hello', auto_delete=False, exclusive=False)
self.table_service = TableService(account_name=TableAccountName, account_key=TableKey)
self.table_service.create_table('sciml')
self.chan.basic_publish(exchange='',
routing_key='hello',
body='start up newest server at address '+self.ipad)
self.chan.cancel()
self.connec.close()
self.chan = None
def recon(self):
#this is the slow method. but reliable.
try:
self.connec = pika.BlockingConnection(pika.ConnectionParameters(self.pikaIP, 5672,'/',self.creds))
self.chan = self.connec.channel()
self.chan.queue_declare(queue='hello', auto_delete=False, exclusive=False)
except:
self.fullrecon()
def fullrecon(self):
if self.chan is not None:
self.chan.cancel()
#self.connec.close()
time.sleep(2.0)
print "reconnecting to rabbitmq"
self.connec = pika.BlockingConnection(pika.ConnectionParameters(self.pikaIP, 5672,'/',self.creds))
self.chan = self.connec.channel()
self.chan.queue_declare(queue='hello', auto_delete=False, exclusive=False)
self.chan.basic_publish(exchange='', routing_key='hello',
body='reconnecting to rabbitmq')
def decon(self):
if self.chan is not None:
#self.chan.basic_publish(exchange='',
# routing_key='hello',
# body='disconect from address '+self.ipad)
self.chan.cancel()
self.connec.close()
self.chan = None
示例9: getStorageMetrics
def getStorageMetrics(account, key, hostBase, table, startKey, endKey):
try:
waagent.Log("Retrieve storage metrics data.")
tableService = TableService(account_name = account,
account_key = key,
host_base = hostBase)
ofilter = ("PartitionKey ge '{0}' and PartitionKey lt '{1}'"
"").format(startKey, endKey)
oselect = ("TotalRequests,TotalIngress,TotalEgress,AverageE2ELatency,"
"AverageServerLatency,RowKey")
metrics = tableService.query_entities(table, ofilter, oselect)
waagent.Log("{0} records returned.".format(len(metrics)))
return metrics
except Exception, e:
waagent.Error(("Failed to retrieve storage metrics data: {0} {1}"
"").format(printable(e), traceback.format_exc()))
AddExtensionEvent(message=FAILED_TO_RETRIEVE_STORAGE_DATA)
return None
示例10: friend_email_get
def friend_email_get(mine):
l=[]
try:
# will return a list of email ids of freinds
table_service = TableService(account_name='****', account_key='******')
#since table is already created
#table_service.create_table('friendstable')
tuple1 = table_service.get_entity('friendlisttable', 'friend', mine)
count=tuple1.count
for i in range(1,count+1):
field="friend"+str(i);
k_dict=tuple1.__dict__
print("\n\n",k_dict,"\n\n")
data=k_dict[field]
print("\n\n",data)
l.append(data)
print("\n\n",l,"\n\n")
except Exception as e:
print(e)
return l
示例11: __init__
def __init__(self, table):
if os.environ.get("raspberry") is None:
table += 'Test'
print table
self._partition = table
with open('azure.txt') as f:
lines = f.readlines()
acc = lines[0].strip()
key = lines[1].strip()
self._table_service = TableService(account_name=acc, account_key=key)
示例12: getAzureDiagnosticMemoryData
def getAzureDiagnosticMemoryData(accountName, accountKey, hostBase,
startKey, endKey, hostname):
try:
waagent.Log("Retrieve diagnostic data: Memory")
table = "LinuxPerfMemVer1v0"
tableService = TableService(account_name = accountName,
account_key = accountKey,
host_base = hostBase)
ofilter = ("PartitionKey ge '{0}' and PartitionKey lt '{1}' "
"and Host eq '{2}'").format(startKey, endKey, hostname)
oselect = ("PercentAvailableMemory,Host")
data = tableService.query_entities(table, ofilter, oselect, 1)
if data is None or len(data) == 0:
return None
memoryPercent = 100 - float(data[0].PercentAvailableMemory)
return memoryPercent
except Exception, e:
waagent.Error(("Failed to retrieve diagnostic data(Memory): {0} {1}"
"").format(printable(e), traceback.format_exc()))
AddExtensionEvent(message=FAILED_TO_RETRIEVE_MDS_DATA)
return None
示例13: setUp
def setUp(self):
self.tc = TableService(credentials.getStorageServicesName(),
credentials.getStorageServicesKey())
self.tc.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
__uid = getUniqueTestRunID()
table_base_name = u'testtable%s' % (__uid)
self.table_name = getUniqueNameBasedOnCurrentTime(table_base_name)
self.additional_table_names = []
示例14: __init__
class CustomerTable:
def __init__(self):
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
def insert(self,ID,Name,Country,City):
task = {'PartitionKey': 'Customer',
'RowKey': ID,
'Name' : Name ,
'Country' : Country,
'City' : City}
try:
self.table_service.insert_entity('Customer', task)
except:
print"azure.WindowsAzureConflictError: Customer Conflict"
def listAll(self):
tasks = self.table_service.query_entities('Customer', "PartitionKey eq 'Customer'")
i=0
for task in tasks:
i=i+1
print("Name: %s, Country: %s, City: %s") %(task.Name,task.Country,task.City)
print("Total Customer: %s") %(i)
示例15: setUp
def setUp(self):
self.tc = TableService(account_name=credentials.getStorageServicesName(),
account_key=credentials.getStorageServicesKey())
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
if proxy_host:
self.tc.set_proxy(proxy_host, proxy_port)
__uid = getUniqueTestRunID()
table_base_name = u'testtable%s' % (__uid)
self.table_name = getUniqueNameBasedOnCurrentTime(table_base_name)
self.additional_table_names = []