當前位置: 首頁>>代碼示例>>Python>>正文


Python storage.TableService類代碼示例

本文整理匯總了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,
    )
開發者ID:catInet,項目名稱:landingPage,代碼行數:25,代碼來源:views.py

示例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."
開發者ID:dbgannon,項目名稱:eventstreams,代碼行數:52,代碼來源:pull-events-from-eventhub-through-queue.py

示例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)
開發者ID:kovacsbalu,項目名稱:HomeAutomatization,代碼行數:7,代碼來源:AzureDataServices.py

示例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 = []
開發者ID:algaruda,項目名稱:azure-sdk-for-python,代碼行數:7,代碼來源:test_tableservice.py

示例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."
開發者ID:dbgannon,項目名稱:dcos,代碼行數:16,代碼來源:generic-worker.py

示例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)
開發者ID:freshmenyuan,項目名稱:PointOfSale,代碼行數:28,代碼來源:Iterator.py

示例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
開發者ID:KundanaP,項目名稱:bosh-azure-template,代碼行數:17,代碼來源:prep_containers_and_tables.py

示例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
開發者ID:dbgannon,項目名稱:sciml,代碼行數:46,代碼來源:scimlservice.py

示例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
開發者ID:dutonc,項目名稱:azure-linux-extensions,代碼行數:18,代碼來源:aem.py

示例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
開發者ID:HIMANSHURANJAN2015,項目名稱:clique,代碼行數:20,代碼來源:views.py

示例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)
開發者ID:acsehi,項目名稱:HomeAutomatization,代碼行數:12,代碼來源:AzureDataServices.py

示例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
開發者ID:dutonc,項目名稱:azure-linux-extensions,代碼行數:21,代碼來源:aem.py

示例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 = []
開發者ID:duggan,項目名稱:azure-sdk-for-python,代碼行數:13,代碼來源:test_tableservice.py

示例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)
開發者ID:freshmenyuan,項目名稱:PointOfSale,代碼行數:22,代碼來源:CustomerTable.py

示例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 = []
開發者ID:Bunkerbewohner,項目名稱:azure-sdk-for-python,代碼行數:13,代碼來源:test_tableservice.py


注:本文中的azure.storage.TableService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。