def compile_contracts(self, keep_limits): if not self.solc: print("Error: No valid solc compiler provided") sys.exit(1) print("Compiling the DAO contracts...") dao_contract = os.path.join(self.contracts_dir, "DAO.sol") if not os.path.isfile(dao_contract): print("DAO contract not found at {}".format(dao_contract)) sys.exit(1) dao_contract = edit_dao_source(self.contracts_dir, keep_limits, self.args.proposal_halveminquorum) res = self.compile_contract(dao_contract) contract = res["contracts"]["DAO"] DAOCreator = res["contracts"]["DAO_Creator"] self.creator_abi = DAOCreator["abi"] self.creator_bin = DAOCreator["bin"] self.dao_abi = contract["abi"] self.dao_bin = contract["bin"] offer = os.path.join(self.contracts_dir, "SampleOffer.sol") res = self.compile_contract(offer) self.offer_abi = res["contracts"]["SampleOffer"]["abi"] self.offer_bin = res["contracts"]["SampleOffer"]["bin"] # also delete the temporary created files rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenSaleCopy.sol"))
def compile_contracts(self, keep_limits): if not self.solc: print("Error: No valid solc compiler provided") sys.exit(1) print("Compiling the DAO contracts...") dao_contract = os.path.join(self.contracts_dir, "DAO.sol") if not os.path.isfile(dao_contract): print("DAO contract not found at {}".format(dao_contract)) sys.exit(1) dao_contract = edit_dao_source( self.contracts_dir, keep_limits, self.args.proposal_halveminquorum, self.args.split_execution_period, self.args.scenario == "extrabalance" ) res = self.compile_contract(dao_contract) contract = res["contracts"]["DAO"] DAOCreator = res["contracts"]["DAO_Creator"] self.creator_abi = DAOCreator["abi"] self.creator_bin = DAOCreator["bin"] self.dao_abi = contract["abi"] self.dao_bin = contract["bin"] offer = os.path.join(self.contracts_dir, "SampleOffer.sol") res = self.compile_contract(offer) self.offer_abi = res["contracts"]["SampleOffer"]["abi"] self.offer_bin = res["contracts"]["SampleOffer"]["bin"] # also delete the temporary created files rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenCreationCopy.sol"))
def clean_blockchain(self): """Clean all blockchain data directories apart from the keystore""" print("Cleaning blockchain data directory ...") data_dir = os.path.join(self.tests_dir, "data") shutil.rmtree(os.path.join(data_dir, "chaindata"), ignore_errors=True) shutil.rmtree(os.path.join(data_dir, "dapp"), ignore_errors=True) shutil.rmtree(os.path.join(data_dir, "keystore"), ignore_errors=True) rm_file(os.path.join(data_dir, "nodekey")) rm_file(os.path.join(data_dir, "saved"))
def _delte_order(self, term, child_order_acceptance_id): self.child_orders[term].drop(index=[child_order_acceptance_id], inplace=True) # csvファイルを更新 if len(self.child_orders[term]) == 0: rm_file(self.p_child_orders_path[term]) else: df_to_csv(str(self.p_child_orders_path[term]), self.child_orders[term], index=True) logger.debug(f'{str(self.p_child_orders_path[term])} が更新されました。')
def removeEmptyFile(self, detect_dir): for f in list_dir(detect_dir): # Iterate files while deleting if not os.path.exists(f): continue if os.path.getsize(f) == 0: print 'rm', f rm_file(f) # To remove corresponding trace file if f.endswith('.race'): print 'rm', f.replace('.race', '.trace') rm_file(f.replace('.race', '.trace'))
def prune_stale_reports(self, retention_time=None): """ Remove reports classified as stale, freeing up space on disk :param retention_time: :return: """ if retention_time: self.retention_time = retention_time if not self.retention_time: raise NoRetentionTimeSpecified() stale_files = self.get_prunable_reports() for file_path in stale_files: if destination_exists(file_path): rm_file(file_path) else: logger.debug("FILE_ALREADY_REMOVED:{}".format(file_path)) return True
def compile_contracts(self, keep_limits): if not self.solc: print("Error: No valid solc compiler provided") sys.exit(1) print("Compiling the DAO contracts...") dao_contract = os.path.join(self.contracts_dir, "DAO.sol") if not os.path.isfile(dao_contract): print("DAO contract not found at {}".format(dao_contract)) sys.exit(1) dao_contract = edit_dao_source( self.contracts_dir, keep_limits, 1, # min_proposal_debate 1, # min_proposal_split self.args.proposal_halveminquorum, self.args.split_execution_period, self.scenario_uses_extrabalance(), self.args.scenario == "fuel_fail_extrabalance", self.args.deploy_offer_payment_period) usn = os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol") res = self.compile_contract(usn) contract = res["contracts"]["DAO"] DAOCreator = res["contracts"]["DAO_Creator"] self.creator_abi = DAOCreator["abi"] self.creator_bin = DAOCreator["bin"] self.dao_abi = contract["abi"] self.dao_bin = contract["bin"] self.offer_abi = res["contracts"]["SampleOffer"]["abi"] self.offer_bin = res["contracts"]["SampleOffer"]["bin"] self.usn_abi = res["contracts"]["USNRewardPayOut"]["abi"] self.usn_bin = res["contracts"]["USNRewardPayOut"]["bin"] # also delete the temporary created files rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenCreationCopy.sol")) rm_file(os.path.join(self.contracts_dir, "SampleOfferCopy.sol")) rm_file( os.path.join(self.contracts_dir, "SampleOfferWithoutRewardCopy.sol")) rm_file(os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol"))
def compile_contracts(self, keep_limits): if not self.solc: print("Error: No valid solc compiler provided") sys.exit(1) print("Compiling the DAO contracts...") dao_contract = os.path.join(self.contracts_dir, "DAO.sol") if not os.path.isfile(dao_contract): print("DAO contract not found at {}".format(dao_contract)) sys.exit(1) dao_contract = edit_dao_source( self.contracts_dir, keep_limits, 1, # min_proposal_debate 1, # min_proposal_split self.args.proposal_halveminquorum, self.args.split_execution_period, self.scenario_uses_extrabalance(), self.args.scenario == "fuel_fail_extrabalance", self.args.deploy_offer_payment_period ) usn = os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol") res = self.compile_contract(usn) contract = res["contracts"]["DAO"] DAOCreator = res["contracts"]["DAO_Creator"] self.creator_abi = DAOCreator["abi"] self.creator_bin = DAOCreator["bin"] self.dao_abi = contract["abi"] self.dao_bin = contract["bin"] self.offer_abi = res["contracts"]["RewardOffer"]["abi"] self.offer_bin = res["contracts"]["RewardOffer"]["bin"] self.usn_abi = res["contracts"]["USNRewardPayOut"]["abi"] self.usn_bin = res["contracts"]["USNRewardPayOut"]["bin"] # also delete the temporary created files rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenCreationCopy.sol")) rm_file(os.path.join(self.contracts_dir, "RewardOfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "OfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol"))
def compile_cleanup(self): self.reset_dao_version() rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenCreationCopy.sol")) rm_file(os.path.join(self.contracts_dir, "RewardOfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "OfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "PFOfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol"))
def compile_contracts(self, keep_limits): if not self.solc: print("Error: No valid solc compiler provided") sys.exit(1) # checkout the requested version of the DAO sources self.checkout_dao_version() print("Compiling the DAO contracts...") dao_contract = os.path.join(self.contracts_dir, "DAO.sol") if not os.path.isfile(dao_contract): print("DAO contract not found at {}".format(dao_contract)) sys.exit(1) dao_contract = edit_dao_source( self.contracts_dir, keep_limits, 1, # min_proposal_debate 1, # min_proposal_split self.args.proposal_halveminquorum, self.args.split_execution_period, self.scenario_uses_extrabalance(), self.args.scenario == "fuel_fail_extrabalance", self.args.deploy_offer_payment_period, self.args.deploy_pfoffer_payout_freeze_period) # compile USNRewardPayout and all contracts it depends on usn = os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol") res = self.compile_contract(usn) contract = res["contracts"]["DAO"] DAOCreator = res["contracts"]["DAO_Creator"] self.creator_abi = DAOCreator["abi"] self.creator_bin = DAOCreator["bin"] self.dao_abi = contract["abi"] self.dao_bin = contract["bin"] self.offer_abi = res["contracts"]["RewardOffer"]["abi"] self.offer_bin = res["contracts"]["RewardOffer"]["bin"] self.usn_abi = res["contracts"]["USNRewardPayOut"]["abi"] self.usn_bin = res["contracts"]["USNRewardPayOut"]["bin"] # compile PFOffer pfoffer = os.path.join(self.contracts_dir, "PFOfferCopy.sol") res = self.compile_contract(pfoffer) self.pfoffer_abi = res["contracts"]["PFOffer"]["abi"] self.pfoffer_bin = res["contracts"]["PFOffer"]["bin"] # also delete the temporary created files self.reset_dao_version() rm_file(os.path.join(self.contracts_dir, "DAOcopy.sol")) rm_file(os.path.join(self.contracts_dir, "TokenCreationCopy.sol")) rm_file(os.path.join(self.contracts_dir, "RewardOfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "OfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "PFOfferCopy.sol")) rm_file(os.path.join(self.contracts_dir, "USNRewardPayOutCopy.sol"))
def tearDown(self): rm_file(self.blacklist_filepath)
# print(os.getcwd()) for ___ in os.listdir(os.getcwd()): if not os.path.isdir(___): continue fstack.append(os.getcwd()) os.chdir(os.getcwd() + "\\" + ___) # print(os.getcwd()) for filename in os.listdir(os.getcwd()): try: utils.unzip(filename) res = utils.detect_use_case_oriented( MAIN, CASE, _, __, ___, result) if res != -1: noc += 1 total += 1 utils.rm_file(filename) except PermissionError: print('permissionError') print(_, __, ___) exit() except zipfile.BadZipFile: print('badZipFile') print(_, __, ___) if ___ != '233383': exit() except FileNotFoundError: print('fileNoteFoundError') print(_, __, ___) exit() os.chdir(fstack[-1])