Пример #1
0
from libs import utils
import json
from libs import logger
from selenium.webdriver.common.action_chains import ActionChains

log = logger.get_logger(__name__)


class Tiger:
    def __init__(self, browser_name):

        with open('framework_mapping.json') as json_file:
            self.fwk_mapping = json.load(json_file)
            self.login_url = self.fwk_mapping['url']['login_url'] + 'login'

            with open('page_layouts/login.json') as json_file:
                self.login_mapping = json.load(json_file)

            self.browser_obj = utils.Base(browser_name=browser_name)

    def login(self, username, password):
        """
        This method authenticates login mechanism
        :param username: (String) username of account
        :param password: (String) password of account
        :return: (boolean) login_status
        """
        try:
            login_url = self.fwk_mapping['url']['login_url']
            username_locator = self.login_mapping['username']['locator']
            username_type = self.login_mapping['username']['type']
Пример #2
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os
from gensim.models.doc2vec import Doc2Vec, TaggedDocument
from conf.paths import MODEL_HOME
from conf.config import cpu_count
from model.base import SimBaseModel
from libs.wrapper import costime
from libs.logger import get_logger

logger = get_logger(_file_=__file__)


class Doc2Vector(SimBaseModel):
    # https://radimrehurek.com/gensim/models/doc2vec.html#usage-examples
    model_path = os.path.join(MODEL_HOME, "doc2vec.m")

    def __init__(self, dataframe=None, load=False):
        super(Doc2Vector, self).__init__(name="doc2vec", dataframe=dataframe)
        # 暂不dump/load corpus, dataframe索引必须保持不变
        self.corpus = [
            TaggedDocument(doc, [i])
            for i, doc in enumerate(self.dataframe["tokens"])
        ]
        self.build(load=load)

    @costime("doc2vec", msg="model query nearest")
    def nearest(self, text, topn=5, score=False):
        if not self._ready_df_model():
            return None
Пример #3
0
import traceback
from PIL import Image
import signal
import sys
from libs.logger import get_logger



DataPath = os.path.join(os.getcwd(), "data")
# Below here there are the folders with the product number
Product_DataPath = os.path.join(DataPath, "products")
Working_DataPath = os.path.join(DataPath, "working")
PrintFiles_DataPath = os.path.join(DataPath, "files")

Main_DB = os.path.join(DataPath, "data.db")
log = get_logger('Backend API')

# This is the API that the app will call
class WebAPI(object):
    
    def __init__(self, iface):
        self.control = iface
        self.ip = ""
        self.port = ""
        print ("WebAPI starting")


    # Function called by the android to fetch the Product Data and the Category data
    @cherrypy.expose
    def fetchCategoryData(self, catid):
        print ("Fetching Category Data ", catid)