Example #1
0
def commandLogin(self, command):
    """
		Login as an existing agent
		can login using nick, address or seed.
		display the nickname (if present), address and balance
		check profiles and update or insert
	"""
    if len(command) < 2:
        self.writeConsole(
            'You need to supply some detail for the agent you want to login as.\nCould be the agents nickname, address or seed'
        )
        return
    seed = util.getSeedFromNick(command[1])
    if seed is False:
        self.agentSeed = command[1]
    else:
        self.agentSeed = seed
    util.getAgent(self)
    util.getAddress(self)
    util.getBalance(self)
    self.agentNick = util.getNick(self, self.agentAddress)
    conn = sqlite3.connect('coinflow.db')
    c = conn.cursor()
    c.execute('select id from profiles where seed=?;', (str(self.agentSeed), ))
    id = c.fetchone()
    if id is None:
        c.execute('insert into profiles (nick, seed) values (?,?);',
                  (str(self.agentNick), str(self.agentSeed)))
    else:
        c.execute('update profiles set nick=? where seed=?;',
                  (str(self.agentNick), str(self.agentSeed)))
    conn.commit()
    conn.close()
    self.writeConsole((
        ('Logged in as ' +
         str(self.agentNick)) if len(self.agentNick) > 0 else ('Logged in')) +
                      '.\nAddress is ' + str(self.agentAddress) +
                      '\nBalance is ' + str(self.agentBalance))
    #check for new nicknames
    if util.pollAllPosts(self):
        util.checkNewNicks(self)
    #check for new posts from follows
    if util.pollFollowsPosts(self):
        util.displayFollowsPosts(self)
    #self.poll()
    return
Example #2
0
    def poll(self, value=False):
        """
			This method polls the server to see if there's any new history to take action on
		"""
        if self.agent is None:
            return

        #set the timer to poll every inteval
        #set the clock so that we poll netvend every minute or so to find out new details
        Clock.schedule_interval(self.poll, self.pollInterval)

        #check all posts to see if there has been activity
        #if util.pollAllPosts(self):
        #if there has check the new posts for updatable information
        #util.checkAllPosts(self)

        #check for new posts by our follows
        if util.pollFollowsPosts(self):
            #if there's new ones, display them
            util.displayFollowsPosts(self)
Example #3
0
	def poll(self, value=False):
		"""
			This method polls the server to see if there's any new history to take action on
		"""
		if self.agent is None:
			return
		
		#set the timer to poll every inteval
		#set the clock so that we poll netvend every minute or so to find out new details
		Clock.schedule_interval(self.poll, self.pollInterval)
		
		#check all posts to see if there has been activity
		#if util.pollAllPosts(self):
			#if there has check the new posts for updatable information 
			#util.checkAllPosts(self)
		
		#check for new posts by our follows
		if util.pollFollowsPosts(self):
			#if there's new ones, display them
			util.displayFollowsPosts(self)
Example #4
0
def commandLogin(self, command):
	"""
		Login as an existing agent
		can login using nick, address or seed.
		display the nickname (if present), address and balance
		check profiles and update or insert
	"""
	if len(command) < 2:
		self.writeConsole('You need to supply some detail for the agent you want to login as.\nCould be the agents nickname, address or seed')
		return
	seed = util.getSeedFromNick(command[1])
	if seed is False:
		self.agentSeed = command[1]
	else:
		self.agentSeed = seed
	util.getAgent(self)
	util.getAddress(self)
	util.getBalance(self)
	self.agentNick = util.getNick(self, self.agentAddress)
	conn = sqlite3.connect('coinflow.db')
	c = conn.cursor()
	c.execute('select id from profiles where seed=?;', (str(self.agentSeed),))
	id = c.fetchone()
	if id is None:
		c.execute('insert into profiles (nick, seed) values (?,?);', (str(self.agentNick), str(self.agentSeed)))
	else:
		c.execute('update profiles set nick=? where seed=?;', (str(self.agentNick), str(self.agentSeed)))
	conn.commit()
	conn.close()
	self.writeConsole((('Logged in as ' + str(self.agentNick)) if len(self.agentNick) > 0 else ('Logged in'))  + '.\nAddress is ' + str(self.agentAddress) + '\nBalance is ' + str(self.agentBalance))
	#check for new nicknames
	if util.pollAllPosts(self):
		util.checkNewNicks(self)
	#check for new posts from follows
	if util.pollFollowsPosts(self):
		util.displayFollowsPosts(self)
	#self.poll()
	return