def unlock(self): if not self.exists(): #print('No existing wallet, creating default wallet') self.create() elif self.is_locked(): run(self.teclos_start + ' wallet unlock --password ' + self.get_pw())
def create_allotment_tip5(self, contract, recipient, tokens): cmd = 'teclos push action allot \'%s\' -p %s@active' j = json.dumps({ "owner": contract, "recipient": recipient, "tokens": tokens }) run(cmd % (j, contract))
def transferfrom_tip5(self, contract, recipient, tokens): cmd = 'teclos push action transferfrom \'%s\' -p %s@active' j = json.dumps({ "owner": contract, "recipient": recipient, "tokens": tokens }) run(cmd % (j, contract))
def boot_strap_node(self, address): self.set_host_address(address) #TODO: Make sure full node has eosio root key in wallet self.account_factory.create_system_accounts(self.systemAccounts) self.set_system_contracts(self.systemContracts) self.issue_token(self.token_supply, self.token_issue) system_contract = join(join(self.telos_dir, self.contracts), 'eosio.system') run(self.teclos_dir + ' --url %s set contract eosio %s -p eosio' % (self.host_address, system_contract)) run(self.teclos_dir + ' --url %s push action eosio setpriv \'[\"eosio.msig\", 1]\' -p eosio@active' % self.host_address)
def push_transaction(self, actions): trx = { 'max_net_usage_words': 0, 'max_cpu_usage_ms': 0, 'delay_sec': 0, 'context_free_actions': [], 'actions': actions, 'transaction_extensions': [], 'signatures': [], 'context_free_data': [] } trx = {**trx, **self.get_trx_header()} run("cleos push transaction '{}'".format(toJson(trx)))
def run_macaulay_script(G): macaulay_outfile = '{}/{}_{}.txt'.format(macaulay_directory, results_file, basic_namer(G)) with open('{}/{}'.format(macaulay_directory, macaulay_scriptfile), 'w') as f: f.write(make_macaulay_script( G, macaulay_outfile )) try: os.remove(macaulay_outfile) except OSError: pass t0 = time.time() run(('m2', '--script', '{}/{}'.format(macaulay_directory, macaulay_scriptfile))) timedelta = time.time()-t0 with open(macaulay_outfile,'r') as f: data = f.read() return (data, timedelta)
def update_auth(self, account, permission, parent, controller): run(self.teclos_dir + ' --url' + self.host_address + ' push action eosio updateauth' + jsonArg({ 'account': account, 'permission': permission, 'parent': parent, 'auth': { 'threshold': 1, 'keys': [], 'waits': [], 'accounts': [{ 'weight': 1, 'permission': { 'actor': controller, 'permission': 'active' } }] } }) + '-p ' + account + '@' + permission)
def boot_strap_node(self, address): self.set_host_address(address) self.account_factory.set_host_address(address) # TODO: Make sure full node has eosio root key in wallet self.account_factory.create_pre_accounts(self.pre_accounts) self.set_system_contracts(self.pre_accounts) self.issue_token(self.token_supply, self.token_issue) system_contract = join(self.contracts_dir, 'eosio.system') res = requests.post( self.host_address + '/v1/producer/schedule_protocol_feature_activations', data=toJson({ 'protocol_features_to_activate': [ "0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd" ] })) print(res) print(res.content) sleep(2) run(self.teclos_dir + ' --url %s set contract eosio %s -p eosio' % (self.host_address, system_contract)) args = toJson([0, "4,TLOS"]) run(self.teclos_dir + ' --url %s push action eosio init \'%s\' -p eosio' % (self.host_address, args)) run(self.teclos_dir + ' --url %s push action eosio setpriv \'[\"eosio.msig\", 1]\' -p eosio@active' % self.host_address) self.account_factory.create_post_accounts(self.post_accounts, self.setup_post_account)
def convert_image(G, loud_commands): if loud_commands: print ('generating {} file for graph {}'.format(graphics_format, G.name)) edge_dic = G.get_edges() data = weighted_image_maker(G.image_dic, edge_dic, scale=3) img_file_base = '{}/{}_img'.format(image_directory, G.filename) with open('{}.tex'.format(img_file_base),'w') as f: f.write(img_start_tex) f.write(data) f.write(img_end_tex) run((compile_command, img_file_base), loud_commands) run((convert_command[0], '{}_img.{}'.format(G.filename, convert_command[1],), '{}/{}.{}'.format(image_directory, G.filename, graphics_format)), loud_commands) run((cleanup_command[0], '{}_img.{}'.format(G.filename, cleanup_command[1])), loud_commands)
def reg_producer(self, a): run(self.teclos_dir + " --url %s system regproducer %s %s %s" % (self.host_address, a.name, a.keypair.public, "http://" + a.name + ".com/" + a.keypair.public))
def resign(self, account, controller): self.update_auth(account, 'owner', '', controller) self.update_auth(account, 'active', 'owner', controller) sleep(1) run(self.teclos_dir + ' get account ' + account)
def create(self): if not os.path.exists(self.wallet_state): os.makedirs(self.wallet_state) run(self.cleos + ' wallet create --file ' + join(self.wallet_state, 'wallet_pw.txt'))
def compile_tex(filename, loud_commands=loud_commands): run((compile_command, filename), loud_commands) run((bib_command, filename), loud_commands) run((compile_command, filename), loud_commands) run((compile_command, filename), loud_commands)
def pre_sys_create(self, a): run(self.teclos + ' --url %s create account eosio %s %s' % (self.host_address, a.name, a.keypair.public))
def lock(self): if not self.exists(): print('No existing wallet, creating default wallet') self.create() elif not self.is_locked(): run(self.teclos_start + ' wallet lock')
def import_key(self, private_key): run(self.cleos + ' wallet import --private-key %s' % (private_key))
def import_key(self, private_key): run(self.teclos_start + ' wallet import --private-key %s' % (private_key))
def stop(self): run('pkill -9 keosd')
def incoming(): """Handle incoming traffic.""" if not utility.kik.verify_signature(request.headers.get('X-Kik-Signature'), request.get_data()): return Response(status=403) messages = messages_from_json(request.json['messages']) try: for message in messages: if isinstance(message, TextMessage): print(message.from_user, ':', message.body) print_sentiment_scores(message) else: utility.handle_secondary_message_types(message) except (IndexError, AttributeError) as error: print("No messages found.", error) return Response(status=200) def print_sentiment_scores(message): """Calculate sentiment score and send it.""" snt = analyzer.polarity_scores(message.body) if snt['compound'] == 0.0: text = "I couldn't find any emotion in this text. :(" else: text = "Your Score: {:.2f}%".format(snt['compound'] * 100) utility.send_messages(message, text_to_send=text) utility.run()
def pre_sys_create(self, a): #self.wallet.import_key(a.keypair.private) run(self.teclos + ' --url %s create account eosio %s %s' % (self.host_address, a.name, a.keypair.public))