Esempio n. 1
0
 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())
Esempio n. 2
0
 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))
Esempio n. 3
0
 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))
Esempio n. 4
0
 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)
Esempio n. 5
0
    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)
Esempio n. 7
0
 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)
Esempio n. 8
0
    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)
Esempio n. 10
0
 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))
Esempio n. 11
0
 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)
Esempio n. 12
0
 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'))
Esempio n. 13
0
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)
Esempio n. 14
0
 def pre_sys_create(self, a):
     run(self.teclos + ' --url %s create account eosio %s %s' %
         (self.host_address, a.name, a.keypair.public))
Esempio n. 15
0
 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')
Esempio n. 16
0
 def import_key(self, private_key):
     run(self.cleos + ' wallet import --private-key %s' % (private_key))
Esempio n. 17
0
 def import_key(self, private_key):
     run(self.teclos_start + ' wallet import --private-key %s' %
         (private_key))
Esempio n. 18
0
 def stop(self):
     run('pkill -9 keosd')
Esempio n. 19
0
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()
Esempio n. 20
0
 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))