コード例 #1
0
def main():

    # получим логин, пароль из файла auth.ini
    auth = configparser.ConfigParser()
    auth.optionxform = str
    auth.read('auth.ini')

    settings = configparser.ConfigParser()
    settings.optionxform = str
    settings.read('settings.ini')

    # создадим объект аторизации
    a = Authentication(auth['Authorization']['Login'],
                       auth['Authorization']['Password'],
                       dict(settings['Browser Headers']))
    print(a.uid)

    # создадим объект коллекции
    # c = Collection(a)
    # print(c.req_id, c.csrf_token, sep='\n')
    # new_coll = c.create('new-coll1', 'description new-coll1')

    # создадим карточку-ссылку
    link = 'https://zip-sm.ru/product/mufta-motora-kuhonnogo-kombajna-kenwood'
    collection_url = 'https://yandex.ru/collections/user/company%40zip/mekhanika-dlia-blenderov-zapchasti-dlia-miasorubok-i-blenderov/'
    l = Link(a, link, collection_url)
    print(l.link, l.collection_url, l.collection_id, sep='\n')
コード例 #2
0
ファイル: REST.py プロジェクト: changeyourname/im
def get_auth_header():
    """
    Get the Authentication object from the AUTHORIZATION header
    replacing the new line chars.
    """
    auth_data = bottle.request.headers['AUTHORIZATION'].replace(
        AUTH_NEW_LINE_SEPARATOR, "\n")
    auth_data = auth_data.split(AUTH_LINE_SEPARATOR)
    return Authentication(Authentication.read_auth_data(auth_data))
コード例 #3
0
def start():
    config = Config("config.json")
    url1 = config.get_url1()
    url2 = config.get_url2()

    aws_auth_value1 = ""
    aws_auth_value2 = ""
    
    if ".amazonaws.com/" in url1:
        aws_auth = Authentication(es_host=urlparse(url1).netloc, region="eu-west-1", aws_type="es")
        aws_auth_value1 = aws_auth.get_auth();

    if ".amazonaws.com/" in url2:
        aws_auth = Authentication(es_host=urlparse(url2).netloc, region="eu-west-1", aws_type="es")
        aws_auth_value2 = aws_auth.get_auth();

    print("Comparing results from:\n%s\n%s\n" %(url1, url2))
    search_terms = config.get_search_terms()

    process_data(config=config, terms=search_terms, aws_auth_value1=aws_auth_value1, aws_auth_value2=aws_auth_value2)
コード例 #4
0
def load(info):
    urls = ['//dev-developer.bsvecosystem.net/sdk/api/BSVE.API.js']
    events.trigger('minerva.additional_js_urls', urls)

    info['apiRoot'].bsve = Authentication()

    # Add an endpoint for bsve wms dataset
    info['apiRoot'].bsve_datasets_wms = bsve_wms.BsveWmsDataset()

    # Add test endpoints
    info['apiRoot'].test = TestEndpoint()

    events.bind('minerva.get_layer_info', 'bsve', get_layer_info)
コード例 #5
0
 def _call_function(self):
     self._error_mesage = "Error Exporting Inf."
     (inf_id, delete, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.ExportInfrastructure(
         inf_id, delete, Authentication(auth_data))
コード例 #6
0
 def _call_function(self):
     self._error_mesage = "Error Importing Inf."
     (str_inf, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.ImportInfrastructure(
         str_inf, Authentication(auth_data))
コード例 #7
0
 def _call_function(self):
     self._error_mesage = "Error Getting VM Property."
     (inf_id, vm_id, property_name, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.GetVMProperty(
         inf_id, vm_id, property_name, Authentication(auth_data))
コード例 #8
0
 def _call_function(self):
     self._error_mesage = "Error stopping VM"
     (inf_id, vm_id, auth_data) = self.arguments
     InfrastructureManager.InfrastructureManager.StopVM(
         inf_id, vm_id, Authentication(auth_data))
     return ""
コード例 #9
0
 def _call_function(self):
     self._error_mesage = "Error Adding resources."
     (inf_id, radl_data, auth_data, context) = self.arguments
     return InfrastructureManager.InfrastructureManager.AddResource(
         inf_id, radl_data, Authentication(auth_data), context)
コード例 #10
0
 def _call_function(self):
     self._error_mesage = "Error Removing resources."
     (inf_id, vm_list, auth_data, context) = self.arguments
     return InfrastructureManager.InfrastructureManager.RemoveResource(
         inf_id, vm_list, Authentication(auth_data), context)
コード例 #11
0
ファイル: __init__.py プロジェクト: spbrien/reflect
                description="Method not allowed for this endpoint"
            )

    def on_delete(self, req, resp, resource_name=None, resource_id=None):
        if resource_name and resource_id:
            result = connection.delete(
                table=resource_name,
                id=resource_id,
            )
            resp.status = falcon.HTTP_200  # This is the default status
            resp.content_type = 'application/json'
            resp.body = json.dumps(result)
            return
        else:
            raise falcon.HTTPBadRequest(
                title="Error",
                description="Method not allowed for this endpoint"
            )


# falcon.API instances are callable WSGI apps
app = falcon.API(
    middleware=[Authentication()]
)

# Resources are represented by long-lived class instances
api = ApiResource()

app.add_route('/{resource_name}', api)
app.add_route('/{resource_name}/{resource_id}', api)
コード例 #12
0
 def __init__(self):
     # Authenticating with store token
     self.auth = Authentication()
     self.api = Authentication.load_api(self.auth)
コード例 #13
0
from tkinter import *
from tkinter import filedialog as fd
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from auth import Authentication

from tkinter import *
from tkinter import messagebox

root = Tk()
root.geometry('300x500')
root.title('Войти в систему')

auth = Authentication(len_key=448, file_name='Include/DB.json')

frame_start = Frame(root)

frame_start.pack()

text_start = Label(master=frame_start, text='Выберите действие')
Button_reg = Button(master=frame_start, text='Зарегистрироваться', command=lambda: registrarion())
Button_log = Button(master=frame_start, text='Войти', command=lambda: login())
text_start.pack()
Button_reg.pack()
Button_log.pack()

frame_reg = Frame(root)
text = Label(master=frame_reg, text='Для входа в систему - зарегистрируйтесь!')
text_log = Label(master=frame_reg, text='Введите логин :')
registr_login = Entry(master=frame_reg)
text_password1 = Label(master=frame_reg, text='Введите свой пароль :')
コード例 #14
0
 def _call_function(self):
     self._error_mesage = "Error Getting VM cont msg."
     (inf_id, vm_id, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.GetVMContMsg(
         inf_id, vm_id, Authentication(auth_data))
コード例 #15
0
 def _call_function(self):
     self._error_mesage = "Error Changing VM Info."
     (inf_id, vm_id, radl, auth_data) = self.arguments
     return str(
         InfrastructureManager.InfrastructureManager.AlterVM(
             inf_id, vm_id, radl, Authentication(auth_data)))
コード例 #16
0
 def _call_function(self):
     self._error_mesage = "Error gettinf the Inf. cont msg"
     (inf_id, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.GetInfrastructureContMsg(
         inf_id, Authentication(auth_data))
コード例 #17
0
 def _call_function(self):
     self._error_mesage = "Error Stopping Inf."
     (inf_id, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.StopInfrastructure(
         inf_id, Authentication(auth_data))
コード例 #18
0
 def _call_function(self):
     self._error_mesage = "Error getting the Inf. state"
     (inf_id, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.GetInfrastructureState(
         inf_id, Authentication(auth_data))
コード例 #19
0
 def _call_function(self):
     self._error_mesage = "Error Creating Inf."
     (radl_data, auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.CreateInfrastructure(
         radl_data, Authentication(auth_data))
コード例 #20
0
 def __init__(self):
     self._reddit_client = Authentication().GetRedditClient()
コード例 #21
0
 def _call_function(self):
     self._error_mesage = "Error Getting Inf. List."
     (auth_data) = self.arguments
     return InfrastructureManager.InfrastructureManager.GetInfrastructureList(
         Authentication(auth_data))
コード例 #22
0
def fan_tweet():
    # Created data frame to store the tweets
    tweets_fan = pd.DataFrame(columns=[
        "CREATED_AT", "TWEET_ID", "TWEET", "USER_ID", "USER_NAME",
        "RETWEET_COUNT", "FAVORITE_COUNT", "HASHTAGS"
    ])
    # Open the csv contains selected 20 players from NBA
    fan_df = pd.read_csv("rawData//fan//fan_twitter.csv")
    # Iterate through each player and scrape their tweets
    for i in range(0, fan_df.shape[0]):
        account = fan_df.at[i, "TWITTER_ACC"]
        current_fan = TweetProcress()
        current_fan_tweets = current_fan.request_tweet(screen_name=account,
                                                       count=200,
                                                       pages=40)
        tweets_fan = tweets_fan.append(current_fan_tweets)
        file = "Tweet " + fan_df.at[i, "FULL_NAME"] + ".csv"
        current_fan_tweets.to_csv("rawData//fan//" + file, index=False)
        print(file + " is done")
    # One single csv contains all the tweets
    tweets_fan.to_csv("rawData//fan//tweets_fan.csv", index=False)


if __name__ == "__main__":
    auth = Authentication()
    api = Authentication.load_api(auth)
    #team_tweet()
    #player_tweet()
    #fan_tweet()
コード例 #23
0
 def _call_function(self):
     self._error_mesage = "Error Reconfiguring Inf."
     (inf_id, radl_data, auth_data, vm_list) = self.arguments
     return InfrastructureManager.InfrastructureManager.Reconfigure(
         inf_id, radl_data, Authentication(auth_data), vm_list)
コード例 #24
0
def main():
    # ----- load inputs ----- #
    with open('inputs.json') as f:
        inputs = json.load(f)

    # ----- load single geometry ----- #
    geometry_geojson = inputs['geometry_geojson']
    with open(geometry_geojson) as f:
        extent = geojson.load(f)

    # ----- authentication ----- #
    print('authentication - get JWT')
    username = inputs['username']
    password = inputs['password']
    authorize = Authentication(username, password)
    headers = authorize.get_headers()

    # ----- search imagery with rangar ----- #
    print('search imagery (ragnar)')
    startDatetime = inputs['startDatetime']
    endDatetime = inputs['endDatetime']
    search_ragnar = SearchImagery(headers, extent, startDatetime, endDatetime)
    search_ragnar.init_image()
    resolve_pipeline = Wait(headers, search_ragnar.pipelineId, timeout=100)
    sceneIds = search_ragnar.ret_image()
    sceneIds = sceneIds[:min(len(sceneIds), inputs['max_pictures'])]

    n_cars_all = []
    images_all = []
    date_times = []
    i = 1
    for sceneId in sceneIds:
        # ----- get imagery with rangar ----- #
        print('-----------------------------------')
        print('Process scene no. ' + str(i))
        print('-----------------------------------')
        print('get imagery (ragnar)')
        get_ragnar = GetImagery(headers, extent, sceneId)
        get_ragnar.init_image()
        resolve_pipeline = Wait(headers, get_ragnar.pipelineId,
                                inputs['timeout'])
        if resolve_pipeline.status == 'PROCESSING':
            continue
        url, meta = get_ragnar.ret_image()

        # ----- detect cars with kraken ----- #
        print('detect cars (kraken)')
        map_type = 'cars'
        kraken = Analyses(headers, sceneId, map_type, extent)
        kraken.init_image()
        resolve_pipeline = Wait(headers, kraken.pipelineId, inputs['timeout'])
        if resolve_pipeline.status == 'PROCESSING':
            continue
        map_id, max_zoom, tiles = kraken.ret_image()
        cars = Cars(map_id, tiles)
        n_cars = cars.count_cars()
        mask_cars = cars.combine_tiles()

        # ----- analyze scene with kraken ----- #
        print('analyze imagery (kraken)')
        map_type = 'imagery'
        kraken = Analyses(headers, sceneId, map_type, extent)
        kraken.init_image()
        resolve_pipeline = Wait(headers, kraken.pipelineId, inputs['timeout'])
        if resolve_pipeline.status == 'PROCESSING':
            continue
        map_id, zoom, tiles = kraken.ret_image()
        background = TrueImage(map_id, tiles)
        true_image = background.combine_tiles()
        combined_picture = combine_pictures(mask_cars, true_image)
        n_cars_all.append(n_cars)
        images_all.append(combined_picture)
        date_times.append(meta['datetime'])
        i += 1

    for image, date_time, n_cars in zip(images_all, date_times, n_cars_all):
        file_name = 'scene_' + date_time
        im = Image.fromarray(image)
        im.save("{}.png".format(file_name))
        plt.imshow(image)
        plt.show()
        print('Number of cars on ' + date_time + ': ' + str(n_cars))
コード例 #25
0
ファイル: base.py プロジェクト: tsaklidis/CarGrSDK
 def __init__(self):
     self.auth = Authentication()
     self.user = User()