def check(run=True, test=False): if not run: return rows = get_rows() msg = '<b>journals</b>\n' if rows: msg += '\n'.join(get_notes(rows)) else: msg += 'Замечаний нет.' send_message(msg, test=test)
def sync(run=True, commit=True, test=False): if not run: return count = 0 for company in alch.session.query(Company): count += 1 print('Find Cycle:', count, end=' ') _find_uid(company) if commit: alch.session.commit() send_message(_get_msg(), test=test)
def _result_sending(test): for key in sorted(RESULT): text = '<b>jobs</b>\n<i>' + key + '</i>\n' rows = RESULT[key] if rows is None: text += 'Не отвечает.\n' elif not rows: text += 'Замечаний нет.\n' else: for row in rows: text += _get_row_text(row) send_message(text, test=test)
def sync(run=True, commit=True, quick=False, test=False): if not run: return dumper = Dumper('housing') data = {} for entity in ENTITIES: if quick: data[entity] = list(dumper.read(entity)) else: data[entity] = list( _get_url_data_thread(API['base_url'], API['login'], API['password'], entity)) dumper.write(entity, data[entity]) sync_entity(data, entity) if commit: alch.session.commit() send_message(_get_msg(), test=test)
def load(run=True, test=False): if not run: return if test: global MODE MODE = 'samba_test' # local_test, samba_test targets = [] path = os.path.join(PACKAGE_DIR, 'targets') for name in os.listdir(path): if name[0] == '_': continue with open(os.path.join(path, name), encoding='UTF-8') as file: targets.append(json.load(file)) connection = get_connection() for target in targets: handle(connection, **target) if connection: connection.close() send_message(TITLE + f'Загружено реестров: {len(NAMES)}', test=test)
def telegram_consumer(message): """Consume messages queued into messengers.telegram.""" text = message['text'] username = message['username'] filepath = message['filepath'] send_message(username, text, filepath)