How to use print_report method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

report.py

Source:report.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2# #############################################################################3#4# OpenERP, Open Source Management Solution5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).6#7# vals program is free software: you can redistribute it and/or modify8# it under the terms of the GNU Affero General Public License as9# published by the Free Software Foundation, either version 3 of the10# License, or (at your option) any later version.11#12# vals program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU Affero General Public License for more details.16#17# You should have received a copy of the GNU Affero General Public License18# along with vals program. If not, see <http://www.gnu.org/licenses/>.19#20##############################################################################21import time22from openerp.report import report_sxw23""" Modelo24class print__report(report_sxw.rml_parse):25 def __init__(self, cr, uid, name, context):26 super(print__report, self).__init__(cr, uid, name, context=context)27 self.localcontext.update( {'time': time, 'jasper_report': True,})28report_sxw.report_sxw('report.sncp__report', 'sncp_',29 'print_report/sncp_.jrxml',30 parser=print__report)31"""32# ================================================== ADDONS ========================================33class print_account_analytic_account_report(report_sxw.rml_parse):34 def __init__(self, cr, uid, name, context):35 super(print_account_analytic_account_report, self).__init__(cr, uid, name, context=context)36 self.localcontext.update({'time': time, 'jasper_report': True})37report_sxw.report_sxw('report.account_analytic_account_report', 'account_analytic_account',38 'print_report/account_analytic_account.jrxml',39 parser=print_account_analytic_account_report)40class print_account_invoice_report(report_sxw.rml_parse):41 def __init__(self, cr, uid, name, context):42 super(print_account_invoice_report, self).__init__(cr, uid, name, context=context)43 self.localcontext.update({'time': time, 'jasper_report': True})44report_sxw.report_sxw('report.account_invoice_report', 'account_invoice',45 'print_report/account_invoice.jrxml',46 parser=print_account_invoice_report)47class print_account_invoice_line_report(report_sxw.rml_parse):48 def __init__(self, cr, uid, name, context):49 super(print_account_invoice_line_report, self).__init__(cr, uid, name, context=context)50 self.localcontext.update({'time': time, 'jasper_report': True})51report_sxw.report_sxw('report.account_invoice_line_report', 'account_invoice_line',52 'print_report/account_invoice_line.jrxml',53 parser=print_account_invoice_line_report)54# ================================================== COMUM =========================================55class print_comum_calendario_report(report_sxw.rml_parse):56 def __init__(self, cr, uid, name, context):57 super(print_comum_calendario_report, self).__init__(cr, uid, name, context=context)58 self.localcontext.update({'time': time, 'jasper_report': True})59report_sxw.report_sxw('report.sncp_comum_calendario_report', 'sncp_comum_calendario',60 'print_report/sncp_comum_calendario.jrxml',61 parser=print_comum_calendario_report)62class print_comum_cond_pagam_report(report_sxw.rml_parse):63 def __init__(self, cr, uid, name, context):64 super(print_comum_cond_pagam_report, self).__init__(cr, uid, name, context=context)65 self.localcontext.update({'time': time, 'jasper_report': True})66report_sxw.report_sxw('report.sncp_comum_cond_pagam_report', 'sncp_comum_cond_pagam',67 'print_report/sncp_comum_cond_pagam.jrxml',68 parser=print_comum_cond_pagam_report)69class print_comum_cpv_report(report_sxw.rml_parse):70 def __init__(self, cr, uid, name, context):71 super(print_comum_cpv_report, self).__init__(cr, uid, name, context=context)72 self.localcontext.update({'time': time, 'jasper_report': True})73report_sxw.report_sxw('report.sncp_comum_cpv_report', 'sncp_comum_cpv',74 'print_report/sncp_comum_cpv.jrxml',75 parser=print_comum_cpv_report)76class print_comum_meios_pagamento_report(report_sxw.rml_parse):77 def __init__(self, cr, uid, name, context):78 super(print_comum_meios_pagamento_report, self).__init__(cr, uid, name, context=context)79 self.localcontext.update({'time': time, 'jasper_report': True})80report_sxw.report_sxw('report.sncp_comum_meios_pagamento_report', 'sncp_comum_meios_pagamento',81 'print_report/sncp_comum_meios_pagamento.jrxml',82 parser=print_comum_meios_pagamento_report)83# ================================================== ORCAMENTO =========================================84class print_orcamento_despesa_report(report_sxw.rml_parse):85 def __init__(self, cr, uid, name, context):86 super(print_orcamento_despesa_report, self).__init__(cr, uid, name, context=context)87 self.localcontext.update({'time': time, 'jasper_report': True})88report_sxw.report_sxw('report.sncp_orcamento_despesa_report', 'sncp_orcamento_despesa',89 'print_report/sncp_orcamento_despesa.jrxml',90 parser=print_orcamento_despesa_report)91class print_orcamento_receita_report(report_sxw.rml_parse):92 def __init__(self, cr, uid, name, context):93 super(print_orcamento_receita_report, self).__init__(cr, uid, name, context=context)94 self.localcontext.update({'time': time, 'jasper_report': True})95report_sxw.report_sxw('report.sncp_orcamento_receita_report', 'sncp_orcamento_receita',96 'print_report/sncp_orcamento_receita.jrxml',97 parser=print_orcamento_receita_report)98class print_orcamento_resumo_config_report(report_sxw.rml_parse):99 def __init__(self, cr, uid, name, context):100 super(print_orcamento_resumo_config_report, self).__init__(cr, uid, name, context=context)101 self.localcontext.update({'time': time, 'jasper_report': True})102report_sxw.report_sxw('report.sncp_orcamento_resumo_config_report', 'sncp_orcamento_resumo_config',103 'print_report/sncp_orcamento_resumo_config.jrxml',104 parser=print_orcamento_resumo_config_report)105class print_modificacao_receita_report(report_sxw.rml_parse):106 def __init__(self, cr, uid, name, context):107 super(print_modificacao_receita_report, self).__init__(cr, uid, name, context=context)108 self.localcontext.update({'time': time, 'jasper_report': True})109report_sxw.report_sxw('report.sncp_modificacao_receita_report', 'sncp_modificacao_imprimir_receita',110 'print_report/sncp_modificacao_receita.jrxml',111 parser=print_modificacao_receita_report)112class print_modificacao_despesa_report(report_sxw.rml_parse):113 def __init__(self, cr, uid, name, context):114 super(print_modificacao_despesa_report, self).__init__(cr, uid, name, context=context)115 self.localcontext.update({'time': time, 'jasper_report': True})116report_sxw.report_sxw('report.sncp_modificacao_despesa_report', 'sncp_modificacao_imprimir_despesa',117 'print_report/sncp_modificacao_despesa.jrxml',118 parser=print_modificacao_despesa_report)119class print_orcamento_historico_receita_report(report_sxw.rml_parse):120 def __init__(self, cr, uid, name, context):121 super(print_orcamento_historico_receita_report, self).__init__(cr, uid, name, context=context)122 self.localcontext.update({'time': time, 'jasper_report': True})123report_sxw.report_sxw('report.sncp_orcamento_historico_cabecalho_receita_report', 'sncp_orcamento_historico_cabecalho',124 'print_report/sncp_orcamento_historico_receita.jrxml',125 parser=print_orcamento_historico_receita_report)126class print_orcamento_historico_despesa_report(report_sxw.rml_parse):127 def __init__(self, cr, uid, name, context):128 super(print_orcamento_historico_despesa_report, self).__init__(cr, uid, name, context=context)129 self.localcontext.update({'time': time, 'jasper_report': True})130report_sxw.report_sxw('report.sncp_orcamento_historico_cabecalho_despesa_report', 'sncp_orcamento_historico_cabecalho',131 'print_report/sncp_orcamento_historico_despesa.jrxml',132 parser=print_orcamento_historico_despesa_report)133class print_orcamento_acumulados_receita_report(report_sxw.rml_parse):134 def __init__(self, cr, uid, name, context):135 super(print_orcamento_acumulados_receita_report, self).__init__(cr, uid, name, context=context)136 self.localcontext.update({'time': time, 'jasper_report': True})137report_sxw.report_sxw('report.sncp_orcamento_acumulados_cabecalho_receita_report',138 'sncp_orcamento_acumulados_cabecalho',139 'print_report/sncp_orcamento_acumulados_receita.jrxml',140 parser=print_orcamento_acumulados_receita_report)141class print_orcamento_acumulados_despesa_report(report_sxw.rml_parse):142 def __init__(self, cr, uid, name, context):143 super(print_orcamento_acumulados_despesa_report, self).__init__(cr, uid, name, context=context)144 self.localcontext.update({'time': time, 'jasper_report': True})145report_sxw.report_sxw('report.sncp_orcamento_acumulados_cabecalho_despesa_report',146 'sncp_orcamento_acumulados_cabecalho',147 'print_report/sncp_orcamento_acumulados_despesa.jrxml',148 parser=print_orcamento_acumulados_despesa_report)149class print_orcamento_ppi_imprimir_report(report_sxw.rml_parse):150 def __init__(self, cr, uid, name, context):151 super(print_orcamento_ppi_imprimir_report, self).__init__(cr, uid, name, context=context)152 self.localcontext.update({'time': time, 'jasper_report': True})153report_sxw.report_sxw('report.sncp_orcamento_ppi_imprimir_report', 'sncp_orcamento_ppi_imprimir',154 'print_report/sncp_orcamento_ppi_imprimir.jrxml',155 parser=print_orcamento_ppi_imprimir_report)156class print_comum_codigos_contab_report(report_sxw.rml_parse):157 def __init__(self, cr, uid, name, context):158 super(print_comum_codigos_contab_report, self).__init__(cr, uid, name, context=context)159 self.localcontext.update({'time': time, 'jasper_report': True})160report_sxw.report_sxw('report.sncp_comum_codigos_contab_report', 'sncp_comum_codigos_contab',161 'print_report/sncp_comum_codigos_contab.jrxml',162 parser=print_comum_codigos_contab_report)163# ================================================== DESPESA =========================================164class print_despesa_cabimento_report(report_sxw.rml_parse):165 def __init__(self, cr, uid, name, context):166 super(print_despesa_cabimento_report, self).__init__(cr, uid, name, context=context)167 self.localcontext.update({'time': time, 'jasper_report': True})168report_sxw.report_sxw('report.sncp_despesa_cabimento_report', 'sncp_despesa_cabimento',169 'print_report/sncp_despesa_cabimento.jrxml',170 parser=print_despesa_cabimento_report)171class print_despesa_cofinanciamentos_report(report_sxw.rml_parse):172 def __init__(self, cr, uid, name, context):173 super(print_despesa_cofinanciamentos_report, self).__init__(cr, uid, name, context=context)174 self.localcontext.update({'time': time, 'jasper_report': True})175report_sxw.report_sxw('report.sncp_despesa_cofinanciamentos_report', 'sncp_despesa_cofinanciamentos',176 'print_report/sncp_despesa_cofinanciamentos.jrxml',177 parser=print_despesa_cofinanciamentos_report)178class print_despesa_compromisso_report(report_sxw.rml_parse):179 def __init__(self, cr, uid, name, context):180 super(print_despesa_compromisso_report, self).__init__(cr, uid, name, context=context)181 self.localcontext.update({'time': time, 'jasper_report': True})182report_sxw.report_sxw('report.sncp_despesa_compromisso_report', 'sncp_despesa_compromisso',183 'print_report/sncp_despesa_compromisso.jrxml',184 parser=print_despesa_compromisso_report)185class print_despesa_fundamentos_report(report_sxw.rml_parse):186 def __init__(self, cr, uid, name, context):187 super(print_despesa_fundamentos_report, self).__init__(cr, uid, name, context=context)188 self.localcontext.update({'time': time, 'jasper_report': True})189report_sxw.report_sxw('report.sncp_despesa_fundamentos_report', 'sncp_despesa_fundamentos',190 'print_report/sncp_despesa_fundamentos.jrxml',191 parser=print_despesa_fundamentos_report)192class print_despesa_naturezas_report(report_sxw.rml_parse):193 def __init__(self, cr, uid, name, context):194 super(print_despesa_naturezas_report, self).__init__(cr, uid, name, context=context)195 self.localcontext.update({'time': time, 'jasper_report': True})196report_sxw.report_sxw('report.sncp_despesa_naturezas_report', 'sncp_despesa_naturezas',197 'print_report/sncp_despesa_naturezas.jrxml',198 parser=print_despesa_naturezas_report)199class print_despesa_pagamentos_ordem_report(report_sxw.rml_parse):200 def __init__(self, cr, uid, name, context):201 super(print_despesa_pagamentos_ordem_report, self).__init__(cr, uid, name, context=context)202 self.localcontext.update({'time': time, 'jasper_report': True})203report_sxw.report_sxw('report.sncp_despesa_pagamentos_ordem_report', 'sncp_despesa_pagamentos_ordem',204 'print_report/sncp_despesa_pagamentos_ordem.jrxml',205 parser=print_despesa_pagamentos_ordem_report)206class print_despesa_pagamentos_reposicoes_report(report_sxw.rml_parse):207 def __init__(self, cr, uid, name, context):208 super(print_despesa_pagamentos_reposicoes_report, self).__init__(cr, uid, name, context=context)209 self.localcontext.update({'time': time, 'jasper_report': True})210report_sxw.report_sxw('report.sncp_despesa_pagamentos_reposicoes_report', 'sncp_despesa_pagamentos_reposicoes',211 'print_report/sncp_despesa_pagamentos_reposicoes.jrxml',212 parser=print_despesa_pagamentos_reposicoes_report)213class print_despesa_procedimentos_report(report_sxw.rml_parse):214 def __init__(self, cr, uid, name, context):215 super(print_despesa_procedimentos_report, self).__init__(cr, uid, name, context=context)216 self.localcontext.update({'time': time, 'jasper_report': True})217report_sxw.report_sxw('report.sncp_despesa_procedimentos_report', 'sncp_despesa_procedimentos',218 'print_report/sncp_despesa_procedimentos.jrxml',219 parser=print_despesa_procedimentos_report)220class print_despesa_requisicoes_report(report_sxw.rml_parse):221 def __init__(self, cr, uid, name, context):222 super(print_despesa_requisicoes_report, self).__init__(cr, uid, name, context=context)223 self.localcontext.update({'time': time, 'jasper_report': True})224report_sxw.report_sxw('report.sncp_despesa_requisicoes_report', 'sncp_despesa_requisicoes',225 'print_report/sncp_despesa_requisicoes.jrxml',226 parser=print_despesa_requisicoes_report)227# ================================================== RECEITA =========================================228class print_receita_guia_rec_report(report_sxw.rml_parse):229 def __init__(self, cr, uid, name, context):230 super(print_receita_guia_rec_report, self).__init__(cr, uid, name, context=context)231 self.localcontext.update({'time': time, 'jasper_report': True})232report_sxw.report_sxw('report.sncp_receita_guia_rec_report', 'sncp_receita_guia_rec',233 'print_report/sncp_receita_guia_rec.jrxml',234 parser=print_receita_guia_rec_report)235class print_receita_print_report_report(report_sxw.rml_parse):236 def __init__(self, cr, uid, name, context):237 super(print_receita_print_report_report, self).__init__(cr, uid, name, context=context)238 self.localcontext.update({'time': time, 'jasper_report': True})239report_sxw.report_sxw('report.sncp_receita_print_report_report', 'sncp_receita_print_report',240 'print_report/sncp_receita_print_report.jrxml',241 parser=print_receita_print_report_report)242# ================================================== TESOURARIA =========================================243class print_tesouraria_conta_corrente_report(report_sxw.rml_parse):244 def __init__(self, cr, uid, name, context):245 super(print_tesouraria_conta_corrente_report, self).__init__(cr, uid, name, context=context)246 self.localcontext.update({'time': time, 'jasper_report': True})247report_sxw.report_sxw('report.sncp_tesouraria_conta_corrente_report', 'sncp_tesouraria_conta_corrente',248 'print_report/sncp_tesouraria_conta_corrente.jrxml',249 parser=print_tesouraria_conta_corrente_report)250class print_tesouraria_folha_caixa_report(report_sxw.rml_parse):251 def __init__(self, cr, uid, name, context):252 super(print_tesouraria_folha_caixa_report, self).__init__(cr, uid, name, context=context)253 self.localcontext.update({'time': time, 'jasper_report': True})254report_sxw.report_sxw('report.sncp_tesouraria_folha_caixa_report', 'sncp_tesouraria_folha_caixa',255 'print_report/sncp_tesouraria_folha_caixa.jrxml',256 parser=print_tesouraria_folha_caixa_report)257class print_tesouraria_mapa_ots_report(report_sxw.rml_parse):258 def __init__(self, cr, uid, name, context):259 super(print_tesouraria_mapa_ots_report, self).__init__(cr, uid, name, context=context)260 self.localcontext.update({'time': time, 'jasper_report': True})261report_sxw.report_sxw('report.sncp_tesouraria_mapa_ots_report', 'sncp_tesouraria_mapa_ots',262 'print_report/sncp_tesouraria_mapa_ots.jrxml',263 parser=print_tesouraria_mapa_ots_report)264class print_tesouraria_mapas_diario_resumo_report(report_sxw.rml_parse):265 def __init__(self, cr, uid, name, context):266 super(print_tesouraria_mapas_diario_resumo_report, self).__init__(cr, uid, name, context=context)267 self.localcontext.update({'time': time, 'jasper_report': True})268report_sxw.report_sxw('report.sncp_tesouraria_mapas_diario_resumo_report', 'sncp_tesouraria_mapas_diario_resumo',269 'print_report/sncp_tesouraria_mapas_diario_resumo.jrxml',270 parser=print_tesouraria_mapas_diario_resumo_report)271class print_tesouraria_movim_fundos_maneio_report(report_sxw.rml_parse):272 def __init__(self, cr, uid, name, context):273 super(print_tesouraria_movim_fundos_maneio_report, self).__init__(cr, uid, name, context=context)274 self.localcontext.update({'time': time, 'jasper_report': True})275report_sxw.report_sxw('report.sncp_tesouraria_movim_fundos_maneio_report', 'sncp_tesouraria_movim_fundos_maneio',276 'print_report/sncp_tesouraria_movim_fundos_maneio.jrxml',...

Full Screen

Full Screen

iphone_backup_parser.py

Source:iphone_backup_parser.py Github

copy

Full Screen

1import subprocess2import plistlib3import argparse4import sqlite35import logging6import magic7import math8import time9import re10import os11# Global Variables12start_time = time.time()13report_list = []14url_set = set()15output_database = {}16file_walk_database = {}17sms_db_hash = None18sms_database = {}19magic_generator = magic.Magic(flags=magic.MAGIC_MIME_TYPE)20url_block_list = [21 'content.icloud.com',22]23def is_sqlite3(_path):24 process = subprocess.run(['file', _path], check=True, stdout=subprocess.PIPE, universal_newlines=True)25 output = f'{process.stdout}'.lower()26 if 'sqlite' in output:27 return True28 else:29 return False30def parse_args():31 parser = argparse.ArgumentParser()32 parser.add_argument('-f', '--file_path', help='Target SQLite3 Path', type=str, required=True)33 arguments = parser.parse_args()34 return arguments35def print_elapsed_time(_start_time):36 seconds = round(int(time.time() - _start_time), 2)37 minutes = math.trunc(seconds / 60)38 remaining_seconds = math.trunc(seconds - (minutes * 60))39 if len(f'{remaining_seconds}') != 2:40 remaining_seconds = f'0{remaining_seconds}'41 elapsed_time = f'{minutes}:{remaining_seconds}'42 print(f'[i] Total_Time Elapsed: {elapsed_time}')43def convert_sqlite3_to_sql_dict(_path):44 result_dict = {}45 conn = sqlite3.connect(_path)46 cursor = conn.cursor()47 cursor.execute('SELECT name from sqlite_master where type="table"')48 tables = cursor.fetchall()49 for table in tables:50 table_name = table[0]51 qry = f'SELECT * from "{table_name}"'52 cursor.execute(qry)53 contents = cursor.fetchall()54 for content in contents:55 uuid = content[0]56 key = f'{table_name}_{uuid}'57 result_dict[key] = content58 return result_dict59def iterate_sql_dict(_sqlite3_dict):60 global report_list, sms_database61 for key in _sqlite3_dict:62 report_list.append(f'[+] Item: {key}\n')63 if isinstance(_sqlite3_dict[key], dict):64 iterate_sql_dict(_sqlite3_dict[key])65 else:66 data_body = _sqlite3_dict[key]67 report_list.append(f'[^] {data_body}\n')68 try:69 generate_cleaned_manifest_entry(data_body, print_item=False) # Do Iterative Action From Here Down...70 except:71 pass72 if sms_db_hash:73 sms_database[key] = data_body74def global_filter(_obj):75 global url_set, url_allow_list76 if isinstance(_obj, int) or isinstance(_obj, str):77 re_extract_urls(_obj)78 return _obj79 elif isinstance(_obj, bytes):80 _obj_raw_ascii = _obj.decode('ascii', 'ignore')81 if 'bplist' in _obj_raw_ascii:82 try:83 _obj = plistlib.loads(_obj, fmt=None, dict_type=dict)84 re_extract_urls(_obj)85 except:86 pass87 return _obj88 elif isinstance(_obj, dict):89 re_extract_urls(_obj)90 for key in _obj:91 _obj[key] = global_filter(_obj[key])92 return _obj93 elif isinstance(_obj, list) or isinstance(_obj, tuple):94 re_extract_urls(_obj)95 new_list = []96 for item in _obj:97 new_list.append(global_filter(item))98 _obj = new_list99 return _obj100 elif isinstance(_obj, set):101 re_extract_urls(_obj)102 new_set = set()103 for item in _obj:104 new_set.add(global_filter(item))105 _obj = new_set106 return _obj107def generate_cleaned_manifest_entry(_data_body, print_item=True):108 global output_database, sms_db_hash109 serial = _data_body[0]110 directory_data = 'Unknown'111 data_type = 'Unknown'112 manifest_entry_dict = {113 'path': directory_data,114 'domain': _data_body[1],115 'sql_entry': _data_body[2],116 'unknown_number': _data_body[3],117 'data': _data_body[4],118 'type': data_type,119 }120 output_database[serial] = manifest_entry_dict121 try:122 if 'sms.db' in manifest_entry_dict['sql_entry']:123 sms_db_hash = serial124 except TypeError:125 pass126 if print_item:127 msg = f'{"-" * 50}\n[+] {serial}\n' \128 f'[^] Directory:\t{manifest_entry_dict["directory"]}\n' \129 f'[^] Domain:\t{manifest_entry_dict["domain"]}\n' \130 f'[^] SQL Entry:\t{manifest_entry_dict["sql_entry"]}\n' \131 f'[^] Unknown:\t{manifest_entry_dict["unknown_number"]}\n' \132 f'[^] Manifest Data:\t{manifest_entry_dict["manifest_data"]}\n' \133 f'[^] Type:\t{manifest_entry_dict["type"]}'134 print(msg)135def add_url(_url):136 global url_set, url_block_list137 for blocked_url in url_block_list:138 if blocked_url in _url:139 return None140 url_set.add(_url)141def re_extract_urls(_data):142 try:143 if isinstance(_data, list) or isinstance(_data, tuple) or isinstance(_data, set):144 for entry in _data:145 url_list = re.findall(r'(https?://\S+)', entry)146 for url in url_list:147 add_url(url)148 elif isinstance(_data, dict):149 for key in _data:150 url_list0 = re.findall(r'(https?://\S+)', key)151 url_list1 = re.findall(r'(https?://\S+)', _data[key])152 for url in url_list0:153 add_url(url)154 for url in url_list1:155 add_url(url)156 elif isinstance(_data, str):157 url_list = re.findall(r'(https?://\S+)', _data)158 for url in url_list:159 add_url(url)160 elif isinstance(_data, bytes):161 url_list = re.findall(r'(https?://\S+)', _data.decode('ascii', 'ignore'))162 for url in url_list:163 add_url(url)164 except TypeError as e:165 logging.info(e)166def process_data_set(_sqlite3_dict, print_report=False):167 global report_list168 report_list.clear()169 iterate_sql_dict(_sqlite3_dict)170 if print_report:171 for entry in report_list:172 print(entry)173def walk_the_backup(_path):174 global file_walk_database175 target_path = '/'.join(_path.split('/')[:-1])176 for root, dirs, files in os.walk(target_path, topdown=False):177 for filename in files:178 full_path = f'{root}/{filename}'179 file_walk_database[filename] = full_path180def print_types_dict(_input_dict):181 for key in _input_dict:182 print(f'[+] MIME Type: {key}\t\t{_input_dict[key]}')183def filter_by_domain_str(_filter_str, print_types=False):184 global output_database185 result_dict = {}186 type_dict = {}187 for key in output_database:188 if output_database[key]['path'] != 'Unknown' and output_database[key]['domain'] == _filter_str:189 if print_types:190 print(f'[+] {key}\n[^] {output_database[key]}\n{"-" * 50}\n')191 result_dict[key] = output_database[key]192 if output_database[key]['type'] not in type_dict:193 type_dict[output_database[key]['type']] = 1194 elif output_database[key]['type'] in type_dict:195 type_dict[output_database[key]['type']] += 1196 if print_types:197 print_types_dict(type_dict)198 return result_dict199def filter_manifest_by_mime_type(_mime_type_str, print_report=False): # This is a `contains` filter200 global output_database201 result_dict = {}202 type_dict = {}203 for key in output_database:204 if output_database[key]['path'] != 'Unknown' and _mime_type_str in output_database[key]['type']:205 if print_report:206 print(f'[+] {key}\n[^] {output_database[key]}\n{"-" * 50}\n')207 result_dict[key] = output_database[key]208 if output_database[key]['type'] not in type_dict:209 type_dict[output_database[key]['type']] = 1210 elif output_database[key]['type'] in type_dict:211 type_dict[output_database[key]['type']] += 1212 if print_report:213 print_types_dict(type_dict)214 return result_dict215def filter_manifest_by_sql_entry(_sql_entry_str, print_report=False): # This is a `contains` filter216 global output_database217 result_dict = {}218 type_dict = {}219 for key in output_database:220 if output_database[key]['path'] != 'Unknown' and _sql_entry_str in output_database[key]['sql_entry']:221 if print_report:222 print(f'[+] {key}\n[^] {output_database[key]}\n{"-" * 50}\n')223 result_dict[key] = output_database[key]224 if output_database[key]['type'] not in type_dict:225 type_dict[output_database[key]['type']] = 1226 elif output_database[key]['type'] in type_dict:227 type_dict[output_database[key]['type']] += 1228 if print_report:229 print_types_dict(type_dict)230 return result_dict231def copy_to_tmp(_output_database):232 target_path = f'{time.strftime("%Y%m%d-%H%M%S")}_output'233 subprocess.run(f'mkdir {target_path}', shell=True, check=True, stdout=subprocess.PIPE)234 for key in _output_database:235 filename = output_database[key]['sql_entry'].split('/')[-1].replace(' ', '_')236 file_path = output_database[key]['path']237 cmd = f'cp "{file_path}" "{target_path}/{filename}"'238 subprocess.run(cmd, shell=True, check=True, stdout=subprocess.PIPE)239def examine_and_process_db_file(_file_path, print_report=False):240 global output_database241 output_database = {}242 if is_sqlite3(_file_path):243 sqlite3_dict = convert_sqlite3_to_sql_dict(_file_path)244 if print_report:245 process_data_set(sqlite3_dict, print_report=True)246 else:247 process_data_set(sqlite3_dict)248 walk_the_backup(_file_path)249 else:250 logging.info(f'[!] The following supplied file path is not SQLite3\n{_file_path}\n')251def add_metadata_to_db_file():252 global file_walk_database253 sha1_file_set = set(file_walk_database.keys())254 for key in output_database:255 if key in sha1_file_set:256 location = file_walk_database[key]257 file_type = magic_generator.id_filename(location)258 output_database[key]['path'] = location259 output_database[key]['type'] = file_type260def process_url_file():261 global sms_database, output_database, sms_database, url_set262 if sms_db_hash is not None:263 _path = output_database[sms_db_hash]['path']264 examine_and_process_db_file(_path)265 for key in sms_database:266 sms_database[key] = global_filter(sms_database[key])267 f_out = open('urls.txt', 'w')268 for url in url_set:269 f_out.write(f'{url}\n')270 f_out.close()271def main():272 global start_time273 args = parse_args()274 file_path = args.file_path275 examine_and_process_db_file(file_path)276 add_metadata_to_db_file()277 # filter_manifest_by_domain_str('RootDomain', print_report=True) # Filter By Domain String Example278 # filter_manifest_by_mime_type('text/plain', print_report=True) # Filter By MIME Extension Type Example279 # filter_manifest_by_sql_entry('sms.db', print_report=True) # Filter By SQL Entry String Example280 # Copy Images Example281 # filter_manifest_by_mime_type('image', print_report=True) # Filter Only Images for Image Copy Next282 # copy_to_tmp(output_database) # Copy ALL MIME Image Type Files to /tmp283 process_url_file()284 print_elapsed_time(start_time)285if __name__ == "__main__":...

Full Screen

Full Screen

brunel_delta.py

Source:brunel_delta.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#3# brunel-delta-nest.py4#5# This file is part of NEST.6#7# Copyright (C) 2004 The NEST Initiative8#9# NEST is free software: you can redistribute it and/or modify10# it under the terms of the GNU General Public License as published by11# the Free Software Foundation, either version 2 of the License, or12# (at your option) any later version.13#14# NEST is distributed in the hope that it will be useful,15# but WITHOUT ANY WARRANTY; without even the implied warranty of16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17# GNU General Public License for more details.18#19# You should have received a copy of the GNU General Public License20# along with NEST. If not, see <http://www.gnu.org/licenses/>.21# This version uses NEST's Connect functions.22import nest23import time24from numpy import exp25import pandas as pd26import numpy as np27def sim_brunel_delta(dt=0.1,28 simtime=1000.0,29 delay=1.5,30 g=5.0,31 eta=2.0,32 epsilon=0.1,33 order=2500,34 J=0.1,35 V_reset=0.0,36 input_stop=np.inf,37 N_rec=50,38 num_threads=1,39 print_report=True):40 nest.ResetKernel()41 nest.set_verbosity('M_WARNING')42 43 startbuild = time.time()44 NE = 4*order45 NI = 1*order46 N_neurons = NE+NI47 CE = int(epsilon*NE) # number of excitatory synapses per neuron48 CI = int(epsilon*NI) # number of inhibitory synapses per neuron 49 C_tot = int(CI+CE) # total number of synapses per neuron50 # Initialize the parameters of the integrate and fire neuron51 tauMem = 20.052 theta = 20.053 J_ex = J54 J_in = -g*J_ex55 nu_th = theta/(J*CE*tauMem)56 nu_ex = eta*nu_th57 p_rate = 1000.0*nu_ex*CE58 nest.SetKernelStatus({"resolution": dt, "print_time": True,59 "local_num_threads": num_threads})60 if print_report:61 print("Building network")62 neuron_params= {"C_m": 1.0,63 "tau_m": tauMem,64 "t_ref": 2.0,65 "E_L": 0.0,66 "V_reset": V_reset,67 "V_m": 0.0,68 "V_th": theta}69 nest.SetDefaults("iaf_psc_delta", neuron_params)70 nodes_ex=nest.Create("iaf_psc_delta",NE)71 nodes_in=nest.Create("iaf_psc_delta",NI)72 nest.SetDefaults("poisson_generator",{"rate": p_rate, 'stop': input_stop})73 noise=nest.Create("poisson_generator")74 espikes=nest.Create("spike_detector")75 ispikes=nest.Create("spike_detector")76 nest.SetStatus(espikes,[{"label": "brunel-py-ex",77 "withtime": True,78 "withgid": True,79 "to_file": False}])80 nest.SetStatus(ispikes,[{"label": "brunel-py-in",81 "withtime": True,82 "withgid": True,83 "to_file": False}])84 if print_report:85 print("Connecting devices")86 nest.CopyModel("static_synapse","excitatory",{"weight":J_ex, "delay":delay})87 nest.CopyModel("static_synapse","inhibitory",{"weight":J_in, "delay":delay})88 nest.Connect(noise,nodes_ex, syn_spec="excitatory")89 nest.Connect(noise,nodes_in, syn_spec="excitatory")90 nest.Connect(nodes_ex[:N_rec], espikes, syn_spec="excitatory")91 nest.Connect(nodes_in[:N_rec], ispikes, syn_spec="excitatory")92 if print_report:93 print("Connecting network")94 if print_report:95 print("Excitatory connections")96 conn_params_ex = {'rule': 'fixed_indegree', 'indegree': CE}97 nest.Connect(nodes_ex, nodes_ex+nodes_in, conn_params_ex, "excitatory")98 if print_report:99 print("Inhibitory connections")100 conn_params_in = {'rule': 'fixed_indegree', 'indegree': CI}101 nest.Connect(nodes_in, nodes_ex+nodes_in, conn_params_in, "inhibitory")102 endbuild=time.time()103 if print_report:104 print("Simulating")105 nest.Simulate(simtime)106 endsimulate= time.time()107 if print_report:108 events_ex = nest.GetStatus(espikes,"n_events")[0]109 rate_ex = events_ex/simtime*1000.0/N_rec110 events_in = nest.GetStatus(ispikes,"n_events")[0]111 rate_in = events_in/simtime*1000.0/N_rec112 num_synapses = nest.GetDefaults("excitatory")["num_connections"]+\113 nest.GetDefaults("inhibitory")["num_connections"]114 build_time = endbuild-startbuild115 sim_time = endsimulate-endbuild116 print("Brunel network simulation (Python)")117 print("Number of neurons : {0}".format(N_neurons))118 print("Number of synapses: {0}".format(num_synapses))119 print(" Exitatory : {0}".format(int(CE * N_neurons) + N_neurons))120 print(" Inhibitory : {0}".format(int(CI * N_neurons)))121 print("Excitatory rate : %.2f Hz" % rate_ex)122 print("Inhibitory rate : %.2f Hz" % rate_in)123 print("Building time : %.2f s" % build_time)124 print("Simulation time : %.2f s" % sim_time)125 exc_spikes = nest.GetStatus(espikes, 'events')[0]126 inh_spikes = nest.GetStatus(ispikes, 'events')[0]127 return pd.DataFrame(exc_spikes), pd.DataFrame(inh_spikes)128def build_brunel_delta_plastic(dt=0.1,129 delay=1.5,130 g=5.0,131 eta=2.0,132 epsilon=0.1,133 order=2500,134 J=0.1,135 alpha=2.02,136 lambd=0.01,137 Wmax=3.,138 V_reset=0.0,139 input_stop=np.inf,140 N_rec=50,141 num_threads=1,142 print_report=True):143 nest.ResetKernel()144 nest.set_verbosity('M_WARNING')145 146 startbuild = time.time()147 NE = 4*order148 NI = 1*order149 N_neurons = NE+NI150 CE = int(epsilon*NE) # number of excitatory synapses per neuron151 CI = int(epsilon*NI) # number of inhibitory synapses per neuron 152 C_tot = int(CI+CE) # total number of synapses per neuron153 # Initialize the parameters of the integrate and fire neuron154 tauMem = 20.0155 theta = 20.0156 J_ex = J157 J_in = -g*J_ex158 nu_th = theta/(J*CE*tauMem)159 nu_ex = eta*nu_th160 p_rate = 1000.0*nu_ex*CE161 nest.SetKernelStatus({"resolution": dt, "print_time": True,162 "local_num_threads": num_threads})163 if print_report:164 print("Building network")165 neuron_params= {"C_m": 1.0,166 "tau_m": tauMem,167 "t_ref": 2.0,168 "E_L": 0.0,169 "V_reset": V_reset,170 "V_m": 0.0,171 "V_th": theta}172 nest.SetDefaults("iaf_psc_delta", neuron_params)173 nodes_ex=nest.Create("iaf_psc_delta",NE)174 nodes_in=nest.Create("iaf_psc_delta",NI)175 nest.SetStatus(nodes_ex+nodes_in, 'V_m', np.random.uniform(low=-20., high=20., size=(NE+NI,)))176 nest.SetDefaults("poisson_generator",{"rate": p_rate, 'stop': input_stop})177 noise=nest.Create("poisson_generator")178 espikes=nest.Create("spike_detector")179 ispikes=nest.Create("spike_detector")180 nest.SetStatus(espikes,[{"label": "brunel-py-ex",181 "withtime": True,182 "withgid": True,183 "to_file": False}])184 nest.SetStatus(ispikes,[{"label": "brunel-py-in",185 "withtime": True,186 "withgid": True,187 "to_file": False}])188 if print_report:189 print("Connecting devices")190 nest.CopyModel("stdp_synapse","excitatory_plastic",{'alpha': alpha, 'lambda': lambd, 'Wmax': Wmax,191 "delay":delay})192 nest.CopyModel("static_synapse","excitatory",{"weight":J_ex, "delay":delay})193 nest.CopyModel("static_synapse","inhibitory",{"weight":J_in, "delay":delay})194 nest.Connect(noise,nodes_ex, syn_spec="excitatory")195 nest.Connect(noise,nodes_in, syn_spec="excitatory")196 nest.Connect(nodes_ex[:N_rec], espikes, syn_spec="excitatory")197 nest.Connect(nodes_in[:N_rec], ispikes, syn_spec="excitatory")198 if print_report:199 print("Connecting network")200 if print_report:201 print("Excitatory connections")202 conn_params_ex = {'rule': 'fixed_indegree', 'indegree': CE}203 nest.Connect(nodes_ex, nodes_ex, conn_params_ex, {'model': 'excitatory_plastic',204 'weight': {'distribution': 'uniform',205 'low': 0.5 * J_ex,206 'high': 1.5 * J_ex}})207 nest.Connect(nodes_ex, nodes_in, conn_params_ex, {'model': 'excitatory',208 'weight': {'distribution': 'uniform',209 'low': 0.5 * J_ex,210 'high': 1.5 * J_ex}})211 if print_report:212 print("Inhibitory connections")213 conn_params_in = {'rule': 'fixed_indegree', 'indegree': CI}214 nest.Connect(nodes_in, nodes_ex+nodes_in, conn_params_in, "inhibitory")215 endbuild=time.time()216 if print_report:217 num_synapses = sum(nest.GetDefaults(syn_model)["num_connections"]218 for syn_model in ('excitatory', 'excitatory_plastic',219 'inhibitory'))220 build_time = endbuild-startbuild221 print("Brunel network (Python)")222 print("Number of neurons : {0}".format(N_neurons))223 print("Number of synapses: {0}".format(num_synapses))224 print(" Exitatory : {0}".format(int(CE * N_neurons) + N_neurons))225 print(" Inhibitory : {0}".format(int(CI * N_neurons)))226 print("Building time : %.2f s" % build_time)227 return espikes, ispikes, nodes_ex, nodes_in228def sim_brunel_delta_plastic(simtime,229 ex_spike_det, in_spike_det,230 nodes_ex_wgt=None, nodes_in_wgt=None,231 print_report=True):232 nodes_ex_wgt = list(nodes_ex_wgt) if nodes_ex_wgt is not None else []233 nodes_in_wgt = list(nodes_in_wgt) if nodes_in_wgt is not None else []234 235 startsimulate=time.time()236 if print_report:237 print("Simulating")238 nest.Simulate(simtime)239 endsimulate= time.time()240 if print_report:241 sim_time = endsimulate-startsimulate242 print("Brunel network simulation (Python)")243 print("Simulation time : %.2f s" % sim_time)244 exc_spikes = nest.GetStatus(ex_spike_det, 'events')[0]245 inh_spikes = nest.GetStatus(in_spike_det, 'events')[0]246 w_pl = nest.GetStatus(nest.GetConnections(source=nodes_ex_wgt+nodes_in_wgt, synapse_model='excitatory_plastic'), 'weight')247 ...

Full Screen

Full Screen

check_doc.py

Source:check_doc.py Github

copy

Full Screen

...48 decl = re.sub( r'\binline\b', r'', decl )49 decl = re.sub( r' +', r' ', decl )50 decl = re.sub( r' ?= ?', r'=', decl )51 return decl.strip()52def print_report(filename, line_no, msg):53 print '%s(%d): %s' % (filename,line_no,msg)54for comp in comps:55 print "==================================================="56 print 'Checking %s...' % (comp.name,)57 header_path = comp.header_path58 func_list = {}59 if not header_path.endswith('/') and not header_path.endswith('\\'):60 header_path += '/'61 for header_glob in comp.headers:62 glob_expr = header_path + header_glob63 for header in glob.glob(glob_expr):64 f = open(header,'r')65 func_name = ""66 mode = line_no = 0 # mode - outside func declaration (0) or inside (1)67 for l in f.xreadlines():68 line_no += 169 ll = ""70 71 #if re.findall(r'\b([abd-z]|([c][a-uw-z]))[a-z]*[A-Z]', l):72 # print_report(header,line_no,"Bad-style identifier:\n\t"+l) 73 74 if mode == 0:75 if l.startswith(comp.ext_macro):76 ll = l[len(comp.ext_macro):]77 decl = ""78 mode = 179 elif l.startswith(comp.inline_macro):80 temp_func_name = re.findall( r'^.+?\b(' + comp.func_prefix + '\w+)', l )81 if temp_func_name and temp_func_name[0] != func_name:82 ll = l[len(comp.inline_macro):]83 decl = ""84 mode = 185 else:86 ll = l87 if ll:88 decl += ll.rstrip('\n') + ' '89 if ll.find(';') >= 0:90 mode = 091 decl = normalize_decl(decl)92 func_name = re.findall( r'^.+?\b(' + comp.func_prefix + '\w+)', decl )[0]93 if func_list.get(func_name,[]):94 print_report(header,line_no,"Duplicated declaration of " + \95 func_name + "... ignored") 96 else:97 func_list[func_name] = [decl,header,line_no,0]98 else:99 mode = 1100 f.close()101 102 doc_path = comp.doc_path103 if not doc_path.endswith('/') and not doc_path.endswith('\\'):104 doc_path += '/'105 blurb_re = re.compile( r'^<p class="Blurb"' )106 for doc_glob in comp.docs:107 glob_expr = doc_path + doc_glob108 for doc in glob.glob(glob_expr):109 f = open(doc, 'r')110 mode = line_no = 0 # mode - 0 outside function declaration, 2 - inside,111 # 1 transitional state ('cause <pre> is used not only112 # for declaring functions)113 for l in f.xreadlines():114 line_no += 1115 #if re.findall(r'\b([abd-z]|([c][a-uw-z]))[a-z]*[A-Z]', l):116 # print_report(doc,line_no,"Bad-style identifier:\n\t" + l) 117 if mode == 0:118 if blurb_re.match(l):119 mode = 1120 elif mode == 1:121 if l.endswith('<pre>\n'):122 mode = 2123 decl = ""124 elif mode == 2:125 if l.startswith('</pre>'):126 mode = 0127 if decl.find('CV_DEFAULT') >= 0:128 print_report(doc,line_no,'CV_DEFAULT is used in documentation')129 decl = normalize_decl(decl)130 decl_list = decl.split(';')131 for decl in decl_list:132 decl = decl.strip()133 if decl:134 decl = decl + ';'135 #print '***', decl136 func_name = re.findall( r'^.+?\b(' + comp.func_prefix + '\w+)\(', decl )137 if not func_name: continue138 func_name = func_name[0]139 decl_info = func_list.get(func_name,[])140 if decl_info:141 if decl_info[3] == 0:142 if decl_info[0] != decl:143 print_report(doc,line_no,'Incorrect documentation on ' + func_name + ':')144 print ' hdr: ' + decl_info[0]145 print ' doc: ' + decl146 decl_info[3] = 1147 else:148 print_report(doc,line_no,'Duplicated documentation on ' + func_name)149 else:150 print_report(doc,line_no,'The function '+func_name+' is not declared')151 elif not l.startswith('#define'):152 decl += l.rstrip('\n')153 f.close()154 print "---------------------------------------------------"155 keys = func_list.keys()156 undocumented_funcs = []157 for k in keys:158 decl_info = func_list[k]159 if decl_info[3] == 0:160 undocumented_funcs.append((decl_info[1],decl_info[2],k))161 undocumented_funcs.sort()162 163 for decl_info in undocumented_funcs:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful