def create_template(self): master_list_trend_id = utility.read_json_file( join(realpath(''), "configuration", "measures_config.json")) list_measures_for_template = self.create_list_measures() list_trend_id_not_found = [] self.dict_meters_not_found = {} for list_measures in list_measures_for_template: control = True new_template = utility.read_json_file( join(realpath(''), "configuration", "empty_template.json")) for measure in list_measures: if (measure in master_list_trend_id): new_template['parameters']['filter_tag'].append({ "id": master_list_trend_id[measure]['TrendID'], "period": 900, "tag": "resource." + measure }) else: list_trend_id_not_found.append(measure) control = False break if (control == True): uuid_string = str(uuid.uuid1()) utility.save_json_file( join(self.json_templates_path, "custom_template_" + uuid_string + ".json"), new_template) utility.refresh_template_configuration() return list_trend_id_not_found
def create_json(self): try: if (self.hierarchy_name not in listdir(join(self.json_files_path))): mkdir(join(self.json_files_path, self.hierarchy_name)) for meter_name, template in self.dict_meter_template.items(): if (template != "Not Found"): file_template = utility.read_json_file( join(self.json_templates_path, template)) file_template["gateway_id"] = self.gateway_id file_template["parameters"][ "environment_prefix"] = self.environment_prefix file_template["parameters"][ "serial_number"] = self.serial_number file_template["parameters"]["model"] = template[:template. find(".")] file_template["parameters"]["user_name"] = self.username file_template["parameters"]["password"] = self.password key = file_template["parameters"]["file_name_filter"] key["match_group_value"] = self.match_group_value file_template["parameters"]["meter_name"] = meter_name file_template["parameters"]["maker"] = meter_name for measure_meter in file_template["parameters"][ "filter_tag"]: if (measure_meter["tag"] != "CommunicationCode"): measure_meter["tag"] = measure_meter[ "tag"].replace( measure_meter["tag"] [:measure_meter["tag"].find(".")], meter_name) utility.save_json_file( join(self.json_files_path, self.hierarchy_name, meter_name + ".json"), file_template) except Exception as e: logging.error(e, exc_info=True)
def __init__(self, site_name, hierarchy_name, environment_prefix, dict_meters, period, gateway_id): '''Set path''' dict_configuration_path = utility.get_configuration_path() self.json_templates_path = dict_configuration_path[ "json_templates_path"] self.excel_templates_path = dict_configuration_path[ "excel_templates_path"] self.json_files_path = dict_configuration_path["json_files_path"] self.excel_files_path = dict_configuration_path["excel_files_path"] self.hierarchy_file_path = dict_configuration_path["hierarchy_path"] self.logs_path = dict_configuration_path["logs_path"] '''Set Data''' self.site_name = site_name self.hierarchy_name = hierarchy_name self.environment_prefix = environment_prefix self.period = period self.gateway_id = gateway_id '''Dict''' self.dict_logs_file = self.getdict_logs_file() self.dict_from_template = self.get_template_data() self.dict_from_json_configuration = utility.read_json_file( join(realpath(''), "configuration", "measures_config.json")) self.dict_meters = self.create_dict_meter_data(dict_meters) self.createExcelSheet()
def reportDoubleSign(param, address, offline, config, style): """ this is government submodule reportDoubleSign command. """ if not os.path.isfile(param): cust_print('file {} not exits! please check!'.format(param), fg='r') sys.exit(1) params = read_json_file(param) wallet_dir = g_dict_dir_config["wallet_dir"] _, private_key, _, _ = verify_password(address, wallet_dir) ppos = get_eth_obj(config, 'ppos') try: _params = {'typ': params['type'], 'data': params['data']} except KeyError as e: cust_print( 'reportDoubleSign need params {},but it does not exist,please check!' .format(e), fg='r') sys.exit(1) try: if offline: data = rlp.encode([ rlp.encode(int(3000)), rlp.encode(params['type']), rlp.encode(params['data']) ]) _params['transaction_cfg'] = params.get('transaction_cfg', None) _params['to_type'] = 'penalty' transaction_dict = un_sign_data(data, _params, ppos, private_key[2:]) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_government_reportDoubleSign_{}.csv".format( get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: _params['pri_key'] = private_key[2:] _params['transaction_cfg'] = params.get('transaction_cfg', None) txhash = ppos.reportDuplicateSign(*_params.values()) cust_print( 'send raw transfer transaction successful, tx hash:{}.'.format( txhash), fg='g') except Exception as e: cust_print( 'government send transfer transaction fail,error info:{}'.format( e), fg='r') sys.exit(1)
def change_email(string): try: path_file = join(realpath(''), "configuration", "email_config.json") file_config = utility.read_json_file(path_file) file_config["send_to"] = string utility.save_json_file(path_file, file_config) return True except: return False
def getdict_logs_file(self): list_logs_file = utility.create_file_list(self.logs_path, ".json") if (list_logs_file != []): for logs_file in list_logs_file: if (utility.get_substring(logs_file, start="-", stop=".") == self.hierarchy_name): return utility.read_json_file( join(self.logs_path, logs_file)) return self.gateway_id + "_" + "thing§" else: return self.gateway_id + "_" + "thing§"
def verify_password(address, wallet_dir, passwd=None): if address.endswith(".json"): config = os.path.join(g_dict_dir_config["conf_dir"], "node_config.json") info = read_json_file(config) find, wallet_file_path = get_dir_by_name(wallet_dir, address) if not find: cust_print('The wallet file of {} could not be found on {}'.format( address, wallet_dir), fg='r') sys.exit(1) try: hrp = info['hrp'] except: cust_print( 'the wallet {} is not alaya or platon,please check!'.format( wallet_file_path), fg='r') sys.exit(1) elif 42 != len(address): cust_print("Wrong address parameter: --address {}".format(address), fg='r') sys.exit(1) else: # 根据地址找钱包 hrp = address[:3] net_type = "mainnet" if hrp == 'lax' or hrp == 'atx': net_type = 'testnet' find, wallet_file_path, fileName = get_wallet_file_by_address( wallet_dir, address, net_type) if not find: cust_print('The wallet file of {} could not be found on {}'.format( fileName, wallet_dir), fg='r') sys.exit(1) check_name = fileName check_address = address cust_print("Name:{}, Address:{}".format(check_name, check_address), fg='g') if not passwd: if 'windows' == g_system: passwd = b''.join(input_passwd_for_win()).decode() else: passwd = input_passwd_for_linux() if 'lat' == hrp or 'lax' == hrp: from precompile_lib import Account, keys else: from precompile_lib import Alaya_Account as Account, Alaya_keys as keys privateKey = get_private_key_from_wallet_file(Account, keys, wallet_file_path, passwd) return wallet_file_path, privateKey, hrp, Account
def get_template_data(self): list_json_file = utility.create_file_list( join(self.json_files_path, self.hierarchy_name), ".json") dict_measures = {} for _file in list_json_file: file_json = utility.read_json_file( join(self.json_files_path, self.hierarchy_name, _file)) for measure in file_json["parameters"]["filter_tag"]: if (measure["tag"] != "CommunicationCode"): dict_measures[measure["tag"]] = [ measure["id"], measure["period"] ] return (dict_measures)
def create_template_list(self, template): try: logging.info("creating Template list") file_template = utility.read_json_file( join(self.json_templates_path, template)) list_measures = [] for model in file_template["parameters"]["filter_tag"]: if (model["tag"] != "CommunicationCode"): list_measures.append( utility.get_substring(model["tag"], start=".")) return (list_measures) except Exception as e: logging.error(e, exc_info=True)
def vote(param, address, offline, config, style): """ this is government submodule vote command. """ if not os.path.isfile(param): cust_print('file {} not exits! please check!'.format(param), fg='r') sys.exit(1) params = read_json_file(param) try: _params = {'verifier': params['verifier'], 'proposalId': params['proposalId'], 'option': int(params['option'])} except KeyError as e: cust_print('vote need params {},but it does not exist,please check!'.format(e), fg='r') sys.exit(1) wallet_dir = g_dict_dir_config["wallet_dir"] _, private_key, _, _ = verify_password(address, wallet_dir) ppos = get_eth_obj(config, 'ppos') pip = get_eth_obj(config, 'pip') msg = ppos.admin.getProgramVersion() program_version = msg['Version'] version_sign = msg['Sign'] try: if offline: data = rlp.encode( [rlp.encode(int(2003)), rlp.encode(bytes.fromhex(params['verifier'])), rlp.encode(bytes.fromhex(params['proposalId'])), rlp.encode(params['option']), rlp.encode(int(program_version)), rlp.encode(bytes.fromhex(version_sign))]) _params['transaction_cfg'] = params.get('transaction_cfg', None) _params['to_type'] = 'pip' transaction_dict = un_sign_data(data, _params, pip, private_key[2:]) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_government_vote_{}.csv".format(get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: _params['program_version'] = program_version _params['version_sign'] = version_sign _params['pri_key'] = private_key[2:] _params['transaction_cfg'] = params.get('transaction_cfg', None) txhash = pip.vote(*_params.values()) cust_print('send raw transfer transaction successful, tx hash:{}.'.format(txhash), fg='g') except Exception as e: cust_print('vote send transfer transaction fail,error info:{}'.format(e), fg='r') sys.exit(1)
def unStaking(address, file, config, offline, style): """ this is staking submodule unStaking command. """ params = read_json_file(file) node_id = params['node_id'] transaction_cfg = params['transaction_cfg'] check_node_id(node_id) wallet_dir = g_dict_dir_config["wallet_dir"] _, private_key, _, _ = verify_password(address, wallet_dir) private_key = private_key[2:] ppos = get_eth_obj(config, 'ppos') try: if offline: unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_staking_unStaking_{}.csv".format( get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) data = rlp.encode( [rlp.encode(int(1003)), rlp.encode(bytes.fromhex(node_id))]) params['to_type'] = 'staking' transaction_dict = un_sign_data(data, params, ppos, private_key) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: tx_hash = ppos.withdrewStaking(node_id, private_key, transaction_cfg) cust_print( 'withdrewStaking send transfer transaction successful, tx hash:{}.' .format(tx_hash), fg='g') except ValueError as e: cust_print( 'unStaking send transfer transaction fail,error info:{}'.format(e), fg='r') sys.exit(1)
def search_template(self, list_meter_measures): try: dict_meters_config = utility.read_json_file( join(realpath(''), "configuration", "template_measures_config.json")) for model_meter, diz_value in dict_meters_config.items(): for key, value in diz_value.items(): if (key == "measures_selected" and value == len(list_meter_measures)): response = self.control_template( model_meter + ".json", list_meter_measures) if (response != False): logging.info('found corespondence with Template' + response) return response return False except Exception as e: logging.error(e, exc_info=True)
def refresh_get(post_file, hierarchy_name, env): file_path = join(realpath(''), get_configuration_path()["post_files_path"], hierarchy_name, post_file) if (env == 'dev_ap11531'): credentials_g = read_credentials( "saml-GG-SH-AWS-IOT-E-Solution-DevQa-esol-ap11531-dev") elif (env == 'qa_ap11531'): credentials_g = read_credentials( "saml-GG-SH-AWS-IOT-E-Solution-DevQa-esol-ap11531-qa") elif (env == 'prod_ap11531'): credentials_g = read_credentials( "saml-GG-SH-AWS-IOT-E-Solution-Prod-esol-ap11531-prod") thing = read_json_file(file_path) endpoint = thing[post_file][0]["endpoint"] commandId = thing[post_file][0]["commandId"] env_prefix = thing[post_file][0]["environmentPrefix"] response = httpReq.get(credentials_g, endpoint, commandId, env_prefix, env) return response
def getDelegateReward(param, config): """ this is delegate submodule getDelegateReward command. """ ppos = get_eth_obj(config, 'ppos') if not os.path.isfile(param): cust_print('file {} not exits! please check!'.format(param), fg='r') sys.exit(1) params = read_json_file(param) _params = {} try: _params['address'] = params['address'] _params['node_ids'] = params['nodeIDs'] except KeyError as e: cust_print('Key {} does not exist in file {},please check!'.format(e, params), fg='r') sys.exit(1) try: receive = ppos.getDelegateReward(*_params.values()) for node in receive['Ret']: cust_print('{}'.format(json.dumps(node, indent=2)), fg='g') except ValueError as e: cust_print('delegate getDelegateReward send transfer transaction fail,error info:{}'.format(e), fg='r') sys.exit(1)
def create(file, address, template, config, offline, style): """ this is staking submodule create command. """ if template: show_params() return if not os.path.isfile(file): cust_print('file {} not exits! please check!'.format(file), fg='r') sys.exit(1) params = read_json_file(file) wallet_dir = g_dict_dir_config["wallet_dir"] wallet_file_path, private_key, hrp, _ = verify_password(address, wallet_dir) ppos = get_eth_obj(config, 'ppos') msg = ppos.admin.getProgramVersion() bls_pubkey = ppos.admin.nodeInfo.blsPubKey bls_proof = ppos.admin.getSchnorrNIZKProve() program_version = msg['Version'] program_version_sign = msg['Sign'] _params = {} try: _params['typ'] = params['typ'] _params['benifit_address'] = params['benifit_address'] _params['node_id'] = params['node_id'] or ppos.admin.nodeInfo.id _params['external_id'] = params['external_id'] _params['node_name'] = params['node_name'] _params['website'] = params['website'] _params['details'] = params['details'] _params['amount'] = ppos.w3.toWei(str(params['amount']), "ether") _params['program_version'] = params['program_version'] or program_version _params['program_version_sign'] = params['program_version_sign'] or program_version_sign _params['bls_pubkey'] = params['bls_pubkey'] or bls_pubkey _params['bls_proof'] = params['bls_proof'] or bls_proof _params['pri_key'] = private_key[2:] _params['reward_per'] = params['reward_per'] if isinstance(params['transaction_cfg'], dict): _params['transaction_cfg'] = params['transaction_cfg'] except KeyError as e: cust_print('Key {} does not exist in file {},please check!'.format(e, file), fg='r') sys.exit(1) try: if offline: data = rlp_params(tuple(_params.values()), hrp) params['to_type'] = 'staking' transaction_dict = un_sign_data(data, params, ppos, _params['pri_key']) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_staking_create_{}.csv".format(get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: tx_hash = ppos.createStaking(*_params.values()) cust_print('createStaking send transfer transaction successful, tx hash:{}.'.format(tx_hash), fg='g') except ValueError as e: cust_print('createStaking send transfer transaction fail,error info:{}'.format(e)) sys.exit(1)
def __init__(self): super(MenuInterface, self).__init__() '''Window settings''' self.resize(700, 400) self.setWindowTitle("") self.path = '' self.setWindowModality(QtCore.Qt.ApplicationModal) '''Path configurations''' self.dict_configuration_path = get_configuration_path() self.json_templates_path = self.dict_configuration_path[ "json_templates_path"] self.excel_templates_path = self.dict_configuration_path[ "excel_templates_path"] self.json_files_path = self.dict_configuration_path["json_files_path"] self.excel_files_path = self.dict_configuration_path[ "excel_files_path"] self.hierarchy_path = self.dict_configuration_path["hierarchy_path"] self.post_files_path = self.dict_configuration_path["post_files_path"] '''LOAD EXTERNAL CSS STYLESHEET''' self.stylesheet = open('stylesheet.css').read() self.setStyleSheet(self.stylesheet) '''Load external font''' font_db = QtGui.QFontDatabase() font_id = font_db.addApplicationFont(join("font", "CaviarDreams.ttf")) font_family = font_db.applicationFontFamilies(font_id)[0] '''Font for widgets''' self.font = QtGui.QFont(font_family) self.font.setPointSize(20) '''Folder path for treeview''' self.folder_path_tree_view = "" '''Treeview''' self.treeview = QtWidgets.QTreeView() self.treeview.clicked.connect(self.on_select_treeview) file_system = QtWidgets.QFileSystemModel(self.treeview) file_system.setReadOnly(True) file_system.setRootPath(realpath('')) self.treeview.setModel(file_system) self.treeview.setRootIndex(file_system.index(self.json_files_path)) self.treeview.header().resizeSection(0, 800) self.treeview.setAnimated(True) '''text''' self.email_text = QtWidgets.QLineEdit() '''Load templates''' self.list_json_templates = create_file_list( join(realpath(''), "json_templates"), ".json") self.list_check = [] '''Create checkbox list for templates''' for template in self.list_json_templates: self.list_check.append(QtWidgets.QCheckBox(template, self)) '''Load hierarchies''' self.list_hierarchies = create_file_list( join(realpath(''), "hierarchy"), ".xml") '''Create checkbox list for herarchies''' for hierarchy in self.list_hierarchies: self.list_check.append(QtWidgets.QCheckBox(hierarchy, self)) '''Load dict measures''' self.dict_measures_id = read_json_file( join(realpath(''), "configuration", "measures_config.json")) '''create checkbox list for trend id''' for measure_id in self.dict_measures_id.keys(): self.list_check.append(QtWidgets.QCheckBox(measure_id, self)) '''Message box''' self.message_box = QtWidgets.QMessageBox() '''Layout''' self.vertical_box = QtWidgets.QVBoxLayout() self.vertical_box_check = QtWidgets.QVBoxLayout() self.horizontal_box = QtWidgets.QHBoxLayout() self.grid_layout = QtWidgets.QGridLayout() self.layout_widget = QtWidgets.QWidget()
def increase(file, address, template, config, offline, style): """ this is staking submodule increase command. """ if template: show_params() return if not os.path.isfile(file): cust_print('file {} not exits! please check!'.format(file), fg='r') sys.exit(1) params = read_json_file(file) wallet_dir = g_dict_dir_config["wallet_dir"] wallet_file_path, private_key, hrp, _ = verify_password( address, wallet_dir) ppos = get_eth_obj(config, 'ppos') _params = {} try: _params['typ'] = params['typ'] _params['node_id'] = params['node_id'] or ppos.admin.nodeInfo.id _params['amount'] = ppos.w3.toWei(str(params['amount']), "ether") _params['pri_key'] = private_key[2:] if isinstance(params['transaction_cfg'], dict): _params['transaction_cfg'] = params['transaction_cfg'] except KeyError as e: cust_print('Key {} does not exist in file {},please check!'.format( e, file), fg='r') sys.exit(1) try: if offline: data = HexBytes( rlp.encode([ rlp.encode(int(1002)), rlp.encode(bytes.fromhex(_params['node_id'])), rlp.encode(_params['typ']), rlp.encode(_params['amount']) ])).hex() params['to_type'] = 'staking' transaction_dict = un_sign_data(data, params, ppos, _params['pri_key']) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_staking_increase_{}.csv".format( get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: tx_hash = ppos.increaseStaking(*_params.values()) cust_print( 'increase staking send transfer transaction successful, tx hash:{}.' .format(tx_hash), fg='g') except ValueError as e: cust_print( 'increase staking send transfer transaction fail,error info:{}'. format(e), fg='r') sys.exit(1)
def createRestrictingPlan(param, address, offline, config, style): """ this is government submodule vote command. """ if not os.path.isfile(param): cust_print('file {} not exits! please check!'.format(param), fg='r') sys.exit(1) params = read_json_file(param) ppos = get_eth_obj(config, 'ppos') try: params['plans'] = [{ 'epoch': plan['epoch'], 'amount': ppos.web3.toWei(str(plan['amount']), "ether") } for plan in params['plans']] _params = {'account': params['account'], 'plans': params['plans']} except KeyError as e: cust_print( 'createRestrictingPlan need params {},but it does not exist,please check!' .format(e), fg='r') sys.exit(1) wallet_dir = g_dict_dir_config["wallet_dir"] _, private_key, hrp, _ = verify_password(address, wallet_dir) try: if offline: account = bech32_address_bytes(hrp)(params['account']) plan_list = [[plan[k] for k in plan] for plan in params['plans']] data = rlp.encode([ rlp.encode(int(4000)), rlp.encode(account), rlp.encode(plan_list) ]) _params['transaction_cfg'] = params.get('transaction_cfg', None) _params['to_type'] = 'restricting' transaction_dict = un_sign_data(data, _params, ppos, private_key[2:]) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_hedge_createRestrictingPlan_{}.csv".format( get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: _params['pri_key'] = private_key[2:] _params['transaction_cfg'] = params.get('transaction_cfg', None) txhash = ppos.createRestrictingPlan(*_params.values()) cust_print( 'send raw transfer transaction successful, tx hash:{}.'.format( txhash), fg='g') except Exception as e: cust_print( 'createRestrictingPlan send transfer transaction fail,error info:{}' .format(e), fg='r') sys.exit(1)
def submitProposal(param, address, offline, module, config, style): """ this is government submodule submitProposal command. """ if not os.path.isfile(param): cust_print('file {} not exits! please check!'.format(param), fg='r') sys.exit(1) params = read_json_file(param) check_params(params) _params = {'verifier': params['verifier'], 'pip_id': params['pIDID']} _module, func = method_module[module] try: if _module == 'submitVersion': _params['new_version'] = params['newVersion'] _params['end_voting_rounds'] = params['endVotingRound'] if _module == 'submitCancel': _params['end_voting_rounds'] = params['endVotingRound'] _params['tobe_canceled_proposal_id'] = params['canceledProposalID'] if _module == 'submitParam': _params['module'] = params['module'] _params['name'] = params['name'] _params['new_value'] = params['newValue'] except KeyError as e: cust_print( '{} need params {},but it does not exist,please check!'.format( module, e), fg='r') sys.exit(1) wallet_dir = g_dict_dir_config["wallet_dir"] _, private_key, _, _ = verify_password(address, wallet_dir) pip = get_eth_obj(config, 'pip') module, func = method_module[module] try: if offline: data = rlp_params(func, *_params.values()) _params['transaction_cfg'] = params.get('transaction_cfg', None) _params['to_type'] = 'pip' transaction_dict = un_sign_data(data, _params, pip, private_key[2:]) unsigned_tx_dir = g_dict_dir_config["unsigned_tx_dir"] check_dir_exits(unsigned_tx_dir) unsigned_file_csv_name = "unsigned_submitProposal_{}_{}.csv".format( module, get_time_stamp()) unsigned_file_path = os.path.join(unsigned_tx_dir, unsigned_file_csv_name) if style == '': write_csv(unsigned_file_path, [transaction_dict]) else: unsigned_file_path = unsigned_file_path.replace('csv', 'jpg') write_QRCode(transaction_dict, unsigned_file_path) cust_print('unsigned_file save to:{}'.format(unsigned_file_path), fg='g') else: _params['pri_key'] = private_key[2:] _params['transaction_cfg'] = params.get('transaction_cfg', None) txhash = getattr(pip, module)(*_params.values()) cust_print( 'send raw transfer transaction successful, tx hash:{}.'.format( txhash), fg='g') except Exception as e: cust_print( 'submitProposal {} send transfer transaction fail,error info:{}'. format(module, e), fg='r') sys.exit(1)