Пример #1
0
def main(user, password, product_list):
    metadata = URI.from_path('metadata.xml')
    service = URI.from_path('scihub.copernicus.eu.xml')
    credentials = BasicCredentials()
    credentials.userid = user
    credentials.password = password
    credentials.protectionSpace = URI.from_octets(SERVICE).get_canonical_root()
    # the full link of odata is https://scihub.copernicus.eu/apihub/odata/v1
    # this is for the authentication
    c = Client(ca_certs=CERTIFICATE)
    c.add_credentials(credentials)
    c.load_service(service_root=service, metadata=metadata)
    with c.feeds['Products'].open() as products:
        for pid in product_list:
            p = products[pid]
            name = p['Name'].value
            size = p['ContentLength'].value
            output("Product: %s [%i]\n" % (name, size))
            with open('%s.zip' % name, 'wb') as f:
                products.read_stream(p.key(), f)
        if not product_list:
            i = 0
            for p in products.itervalues():
                name = p['Name'].value
                type = p['ContentType'].value
                size = p['ContentLength'].value
                output("%s\n" % str(p.get_location()))
                output("    %s %s[%i]\n" % (name, type, size))
                i += 1
                if i > MAX_LIST:
                    break
Пример #2
0
def main(user, password, product_list):
    metadata = URI.from_path('metadata.xml')
    credentials = BasicCredentials()
    credentials.userid = user
    credentials.password = password
    credentials.protectionSpace = URI.from_octets(SERVICE).get_canonical_root()
    # the full link of odata is https://scihub.esa.int/dhus/odata/v1
    # this is for the authentication
    c = Client(ca_certs=CERTIFICATE)
    c.add_credentials(credentials)
    c.LoadService(SERVICE, metadata=metadata)

    with c.feeds['Products'].OpenCollection() as products:
        for pid in product_list:
            p = products[pid]
            name = p['Name'].value
            size = p['ContentLength'].value
            print name, size
            with open('%s.zip' % name, 'wb') as f:
                products.read_stream(p.key(), f)
Пример #3
0
def main(user, password, product_list):
    metadata = URI.from_path('metadata.xml')
    credentials = BasicCredentials()
    credentials.userid = user
    credentials.password = password
    credentials.protectionSpace = URI.from_octets(SERVICE).get_canonical_root()
    # the full link of odata is https://scihub.esa.int/dhus/odata/v1
    # this is for the authentication
    c = Client(ca_certs=CERTIFICATE)
    c.add_credentials(credentials)
    c.LoadService(SERVICE, metadata=metadata)

    with c.feeds['Products'].OpenCollection() as products:
        for pid in product_list:
            p = products[pid]
            name = p['Name'].value
            size = p['ContentLength'].value
            print name, size
            with open('%s.zip' % name, 'wb') as f:
                products.read_stream(p.key(), f)
Пример #4
0
 def GET(self):
     #c=Client("http://services.odata.org/V2/Northwind/Northwind.svc/")
     import pdb
     pdb.set_trace()
     #c=Client("http://localhost:13579/demo.svc/users?$top=3")
     c = Client("http://localhost:8080/odata.svc/")
     products = c.feeds['Pet'].OpenCollection()
     productNames = []
     for k, p in products.iteritems():
         productNames.append(p['ProductName'].value)
         web.header('Content-Type', 'text/html')
         return render_template('index.html', products=productNames)
Пример #5
0
def main(user, password, product_list):
    metadata = URI.from_path('metadata.xml')
    service = URI.from_path('scihub.copernicus.eu.xml')
    credentials = BasicCredentials()
    credentials.userid = user
    credentials.password = password
    credentials.protectionSpace = URI.from_octets(SERVICE).get_canonical_root()
    # the full link of odata is https://scihub.copernicus.eu/apihub/odata/v1
    # this is for the authentication
    c = Client(ca_certs=CERTIFICATE)
    c.add_credentials(credentials)
    c.load_service(service_root=service, metadata=metadata)
    with c.feeds['Products'].open() as products:
        for pid in product_list:
            p = products[pid]
            name = p['Name'].value
            size = p['ContentLength'].value
            output("Product: %s [%i]\n" % (name, size))
            with open('%s.zip' % name, 'wb') as f:
                products.read_stream(p.key(), f)
        if not product_list:
            i = 0
            for p in products.itervalues():
                name = p['Name'].value
                type = p['ContentType'].value
                size = p['ContentLength'].value
                output("%s\n" % str(p.get_location()))
                output("    %s %s[%i]\n" % (name, type, size))
                i += 1
                if i > MAX_LIST:
                    break
Пример #6
0
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy import API
consumer_key = os.environ['CONKEY']
consumer_secret = os.environ['CONSEC']
access_token = os.environ['ACCKEY']
access_token_secret = os.environ['ACCSEC']
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)


# In[15]:

from pyslet.odata2.client import Client
c = Client("http://data.parliament.uk/membersdataplatform/open/OData.svc")


# In[16]:

import pyslet.odata2.core as core


# In[ ]:

#m=c.feeds['Members'].OpenCollection()


# In[ ]:

class ReplyToTweet(StreamListener):
Пример #7
0
def get_cert():
    c = Client()
    url = URI.from_octets(SERVICE)
    output = c.get_server_certificate_chain(url)
    with open(CERTIFICATE, 'wb') as f:
        f.write(output)
Пример #8
0
def get_cert():
    c = Client()
    url = URI.from_octets(SERVICE)
    output = c.get_server_certificate_chain(url)
    with open(CERTIFICATE, 'wb') as f:
        f.write(output)
Пример #9
0
'''

import helper
import logging

logging.basicConfig(level=logging.INFO)

from pyslet.odata2.client import Client
import pyslet.odata2.core as core

KMMRS_PICKLE_FILENAME = 'kmmrs2.pickle'
LAWS_PICKLE_FILENAME = 'laws2.pickle'
kmmbrs = {}
laws = {}

c = Client('http://knesset.gov.il/Odata/Votes.svc/')
with c.feeds['vote_rslts_kmmbr_shadow'].open() as collection:
    filter = core.CommonExpression.from_str("knesset_num eq 20")
    collection.set_filter(filter)

    num_total = len(collection)
    print(f'Total votes: {num_total}')

    count = 0
    for p in collection.itervalues():
        vote_id, kmmbr_id, kmmbr_name, vote_result, faction_id, faction_name = p[
            'vote_id'].value, p['kmmbr_id'].value, p['kmmbr_name'].value, p[
                'vote_result'].value, p['faction_id'].value, p[
                    'faction_name'].value
        if vote_id in laws:
            laws[vote_id]["kmmbrs2votes"][kmmbr_id] = vote_result