Exemple #1
0
 def create_controls(self):
     self.logger = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
     self.labelChangeMonitorFolder = wx.StaticText(self, label="Отслеживаемая папка")
     self.btnChangeMonitorFolder = wx.Button(self, label="...")
     self.textMonitorFolder = wx.TextCtrl(self, style=wx.TE_READONLY, value=config.get_config_value("Local", "MonitorPath"))
     self.labelAccessKey = wx.StaticText(self, label="Ключ доступа")
     self.textAccessKey = wx.TextCtrl(self, value=config.get_config_value("Amazon", "AccessKey"))
     self.btnSecretKeyChange = wx.Button(self, label="Изменить секрет")
     #self.labelSecretKey = wx.StaticText(self, label="Секретный ключ")
     #self.textSecretKey = wx.TextCtrl(self, value="Введите секретный ключ")
     self.labelBucket = wx.StaticText(self, label="Репозиторий")
     self.textBucket = wx.TextCtrl(self, value=config.get_config_value("Amazon", "bucket"))
Exemple #2
0
    def change_secret_key(self, event):
        self.__log('Change secret button pressed')
        dlg = wx.TextEntryDialog(None, "Введите секретный ключ, выданный вам", "Секретный ключ",
                                 config.get_config_value("Amazon", "SecretKey"), style=wx.OK|wx.CANCEL)

        if dlg.ShowModal() == wx.ID_OK:
            config.set_config_value("Amazon", "SecretKey", dlg.GetValue())
            self.__log("SecretKey changed")
        dlg.Destroy()
def start(identifier, threads, loops):
    init_ssh()
    path = get_path(identifier)
    controlHost = get_config_value('control_host')
    allHosts    = get_all_hosts()

    execute(start_jmeter_server,   identifier=identifier, path=path, hosts=allHosts)
    execute(start_jmeter_loadtest, path=path, allHosts=allHosts, threads=threads, loops=loops, hosts=controlHost)
    execute(close_screen_sessions, identifier=identifier, hosts=allHosts)
    execute(get_jmeter_logs,       hosts=controlHost, path=path)
Exemple #4
0
def main():
    while True:
        time_str = get_config_value("general", "update_time").strip()
        update_time = [int(part) for part in time_str.split(":")]
        wait_until_time(*update_time)
        print("-" * 20)
        print("updating", time.strftime("%d/%m/%y"))
        print()
        try:
            update()
        except Exception as e:
            print(e)
Exemple #5
0
def main():
    while True:
        time_str = get_config_value("general", "update_time").strip()
        update_time = [int(part) for part in time_str.split(":")]
        wait_until_time(*update_time)
        print("-" * 20)
        print("updating", time.strftime("%d/%m/%y"))
        print()
        try:
            update()
        except Exception as e:
            print(e)
Exemple #6
0
def show_gui():
    window = Tk()
    window.title("Укажите Excel файл:")
    window.geometry('300x400+300+300')
    window.resizable(False, False)
    kw_pause_txt = StringVar(value=get_config_value("keyword_pause"))
    st_pause_txt = StringVar(value=get_config_value("ste_pause"))
    Label(window,
          text='Пауза между \nключевыми словами (сек):').place(relx=0.1,
                                                               rely=0.13)
    kw_text = Entry(textvariable=kw_pause_txt)
    kw_text.place(relx=0.1, rely=0.23)
    Label(window, text='Пауза между офферами (сек):').place(relx=0.1,
                                                            rely=0.33)
    st_text = Entry(textvariable=st_pause_txt)
    st_text.place(relx=0.1, rely=0.43)
    Button(window,
           text="Старт",
           command=lambda: parser_process(kw_text, st_text),
           width=25,
           height=2).place(relx=0.1, rely=0.53)
    window.mainloop()
def start(identifier, threads, loops):
    init_ssh()
    path = get_path(identifier)
    controlHost = get_config_value('control_host')
    allHosts = get_all_hosts()

    execute(start_jmeter_server,
            identifier=identifier,
            path=path,
            hosts=allHosts)
    execute(start_jmeter_loadtest,
            path=path,
            allHosts=allHosts,
            threads=threads,
            loops=loops,
            hosts=controlHost)
    execute(close_screen_sessions, identifier=identifier, hosts=allHosts)
    execute(get_jmeter_logs, hosts=controlHost, path=path)
Exemple #8
0
    async def __play_audio(self, ctx):
        '''
        Generic function to play an audio file specified by the context object
        '''

        await self.connect(ctx)
        vc = ctx.voice_client
        filename = ctx.command.name

        audio_source = discord.PCMVolumeTransformer(
            discord.FFmpegPCMAudio(
                source='{}\\{}.mp3'.format(AUDIO_FOLDER, filename)))
        audio_source.volume = get_config_value('volume')

        if not vc.is_playing():
            vc.play(audio_source)
        else:
            await Audio.__play_audio(self, ctx)
Exemple #9
0
def get_json():
    show_peaks = request.args.get('show_peaks')
    per_month_max = request.args.get('per_month_max')
    if per_month_max == "1":
        return json.dumps(list(get_max_json().items()))
    csv_enum = csv_enumerator(show_peaks == "1")
    hide = get_config_value("webserver", "hide").strip().split(",")
    res = OrderedDict()

    last_date = None
    for line in csv_enum:
        date = line.pop("Date")
        insert_empty_values(res, last_date, date)
        last_date = date
        date = get_timestamp(date)
        for key, val in line.items():
            if key not in hide:
                val = float(val)
                res.setdefault(key, list()).append([date, val])
        total = sum([float(val) for val in line.values()])
        res.setdefault("Total", list()).append([date, total])

    return json.dumps(list(res.items()))
Exemple #10
0
def help(text=None, recent=False):
    """Open VACUMM website in a web browser and optionally search for a string

    :Params:

        - **text**, optional: String to search for.
        - **recent**, optional: Use the most recent version of the documentation.
    """
    from config import get_config_value
    key = 'url_recent' if recent else 'url'
    url = get_config_value('vacumm', key)
    if url is None: url = 'http://www.ifremer.fr/vacumm'
    from webbrowser import open
    if text is not None:
        if not isinstance(text, basestring):
            if hasattr(text, 'func_name'):
                text = text.func_name
            else:
                text = text.__class__.__name__
        if not text.startswith('/'):
            text = '/search.html?q=%s&check_keywords=yes&area=default' % text
        url += text
    open(url, new=2)
Exemple #11
0
def help(text=None, recent=False):
    """Open VACUMM website in a web browser and optionally search for a string

    :Params:

        - **text**, optional: String to search for.
        - **recent**, optional: Use the most recent version of the documentation.
    """
    from config import get_config_value
    key = 'url_recent' if recent else 'url'
    url = get_config_value('vacumm', key)
    if url is None: url = 'http://www.ifremer.fr/vacumm'
    from webbrowser import open
    if text is not None:
        if not isinstance(text, basestring):
            if hasattr(text, 'func_name'):
                text = text.func_name
            else:
                text = text.__class__.__name__
        if not text.startswith('/'):
            text = '/search.html?q=%s&check_keywords=yes&area=default'%text
        url += text
    open(url,  new=2)
Exemple #12
0
def get_json():
    show_peaks = request.args.get('show_peaks')
    per_month_max = request.args.get('per_month_max')
    if per_month_max == "1":
        return json.dumps(list(get_max_json().items()))
    csv_enum = csv_enumerator(show_peaks == "1")
    hide = get_config_value("webserver", "hide").strip().split(",")
    res = OrderedDict()

    last_date = None
    for line in csv_enum:
        date = line.pop("Date")
        insert_empty_values(res, last_date, date)
        last_date = date
        date = get_timestamp(date)
        for key, val in line.items():
            if key not in hide:
                val = float(val)
                res.setdefault(key, list()).append([date, val])
        total = sum([float(val) for val in line.values()])
        res.setdefault("Total", list()).append([date, total])

    return json.dumps(list(res.items()))
def upload_files(filelist):
    putpath = datetime.now().strftime("%Y/%m/%d/%H/%M/%S")

    # длина префикса мониторируемой папки для отрезания этой части от пути
    # (формирование относительного пути) + 1 для backslash
    pathprefix = config.get_config_value("Local", "MonitorPath")
    pathprefixlen = pathprefix.__len__() + 1

    for file in filelist:
        meta = {}  # dict для метаданных, передаваемых с файлом

        hash = md5_for_file(file)
        # отрезание префикса и формирование относительного пути
        originalpath = file[pathprefixlen:]
        meta['md5'] = hash
        meta['path'] = originalpath

        print meta #originalpath + " - " + hash
        amazon.put_item_to_bucket(file, hash, putpath, meta)

        meta['storepath'] = putpath + hash
        amazon.put_message_to_queue(meta)
        pass
    return True
Exemple #14
0
LoggingSection = enum(
    'CLIENT',
    'CRAWLER',
    'DATA',
    'FRONTIER',
    'TEST',
    'UTILITIES',
)

#region Setup
logging.basicConfig(level=logging.INFO,
                    format='[%(asctime)s %(levelname)s] %(name)s::%(funcName)s - %(message)s',
                    datefmt='%x %X %Z')
module_dir = os.path.dirname(__file__)
logfile = os.path.join(module_dir, get_config_value('LOG', 'path'))
logdir = os.path.join(module_dir, get_config_value('LOG', 'dir'))

if not os.path.exists(logdir):
    os.mkdir(logdir)

handler = logging.handlers.RotatingFileHandler(logfile,
                                               maxBytes=8192,
                                               backupCount=10, )
formatter = logging.Formatter('[%(asctime)s %(levelname)s] %(name)s::%(funcName)s - %(message)s')
formatter.datefmt = '%x %X %Z'
formatter.converter = time.gmtime
handler.setFormatter(formatter)
#endregion

Exemple #15
0
def get_asset(asset_section):
    # type: (str) -> AssetBase
    class_name = get_config_value(asset_section, "type")
    asset_options = get_config_options(asset_section)
    return getattr(assets, class_name)(asset_section, **asset_options)
def get_ctes(keyword, count):
    logging.info(f'Ключевое слово: {keyword}')
    url_sku = 'https://old.zakupki.mos.ru/api/Cssp/Sku/PostQuery'
    url_offer = 'https://old.zakupki.mos.ru/api/Cssp/Offer/PostQuery'
    result = []
    output = []
    query_cte = {
        "filter": {
            "nameLike": None,
            "costPerUnitGreatEqual": None,
            "costPerUnitLessEqual": None,
            "regionPaths": [],
            "okpdPaths": [],
            "vendorCodeLike": None,
            "offersCountGreatEqual": None,
            "offersCountLessEqual": None,
            "keyword": keyword,
            "partNumberLike": None,
            "productionPaths": [],
            "productionDirectoryPaths": [],
            "characteristicFilter": [],
            "vendorIdIn": None,
            "hasOffers": None,
            "state": "actual",
            "entityStateIn": [1]
        },
        "take": count,
        "skip": 0,
        "order": [{
            "field": "relevance",
            "desc": True
        }],
        "withCount": True
    }
    query_offers = {
        "filter": {
            "offerStateIdIn": [2],
            "skuIdIn": [18800324],
            "onlyMyOffer": False
        },
        "order": [{
            "field": "costPerUnit",
            "desc": False
        }],
        "withCount": True,
        "take": 10,
        "skip": 0
    }
    while True:
        response_tuple = api_post(url_sku, query_cte)
        if response_tuple[1] == 200:
            response = response_tuple[0]
            break
        else:
            sleep(get_config_value("keyword_pause"))
    if response.get('count', 0) == 0:
        logging.warn('Пост-запрос вернул 0 записей!')
        return [[keyword, 'По ключевому слову ничего не найдено!']]
    else:
        logging.info(f'Всего {response.get("count", 0)} СТЕ.')
        logging.info(f'Получено {len(response.get("items", []))} СТЕ.')
        for item in response.get('items', []):
            item_id = item.get("id", 0)
            item_offer_count = item.get("offersCount", 0)
            offers = []
            if item_offer_count != 0:
                query_offers['filter']['skuIdIn'] = [item_id]
                query_offers['take'] = item_offer_count
                while True:
                    offers_resp_tuple = api_post(url_offer, query_offers)
                    if offers_resp_tuple[1] == 200:
                        offers_resp = offers_resp_tuple[0]
                        break
                    else:
                        sleep(get_config_value("ste_pause"))
                for offer in offers_resp.get('items', []):
                    offers.append([
                        offer.get('supplierName', 'Не найдено'),
                        offer.get('supplierInn', 'Не найдено'),
                        offer.get('costPerUnit', 'Не найдено'),
                        ', '.join(offer.get('regionNames', 'Не найдено')),
                    ])
            result.append([
                keyword,
                item.get('name', 'Не найдено'),
                item.get('id', 'Не найдено'),
                item.get('offersCount', 'Не найдено'),
                offers,
                (f"{item.get('productionCode', 'Не найдено') or ''} - "
                 f" {item.get('productionDirectoryName', 'Не найдено').upper()}"
                 ),
            ])
        logging.info(f'Всего нашлось {len(result)} записей.')
        output = merge_output(result)
        return output
Exemple #17
0
LoggingSection = enum(
    'CLIENT',
    'CRAWLER',
    'DATA',
    'FRONTIER',
    'TEST',
    'UTILITIES',
)

#region Setup
logging.basicConfig(
    level=logging.INFO,
    format='[%(asctime)s %(levelname)s] %(name)s::%(funcName)s - %(message)s',
    datefmt='%x %X %Z')
module_dir = os.path.dirname(__file__)
logfile = os.path.join(module_dir, get_config_value('LOG', 'path'))
logdir = os.path.join(module_dir, get_config_value('LOG', 'dir'))

if not os.path.exists(logdir):
    os.mkdir(logdir)

handler = logging.handlers.RotatingFileHandler(
    logfile,
    maxBytes=8192,
    backupCount=10,
)
formatter = logging.Formatter(
    '[%(asctime)s %(levelname)s] %(name)s::%(funcName)s - %(message)s')
formatter.datefmt = '%x %X %Z'
formatter.converter = time.gmtime
handler.setFormatter(formatter)
def init_ssh():
	env.user =  get_config_value('ssh_user')
	env.key_filename = [get_config_value('ssh_key_file')]
def get_all_hosts():
	hostsArray = get_hosts_array_from_string(get_config_value('remote_hosts'))
	hostsArray.append(get_config_value('control_host'))
	return hostsArray  
def get_path(identifier):
	if not is_valid_identifier(identifier):
		raise Exception('Session identifier \'' + identifier + '\' is not in a valid format. Session identifier can only contain alphanumerical characters or on of the following special characters: _ - .')
	return get_config_value('remote_base_path') + '/' + identifier
Exemple #21
0
def get_asset(asset_section):
    class_name = get_config_value(asset_section, "type")
    asset_options = get_config_options(asset_section)
    return getattr(assets, class_name)(asset_section, **asset_options)
def list_monitor_folder():
    # возвращает список файлов в директории (из настроек), рекурсивно
    path = config.get_config_value("Local", "MonitorPath")
    file_list = list_files(path)
    return file_list