Beispiel #1
0
 def do_review(self, i, move = True, buffer = None):
  """
  Review lines from output and set the review point.
  
  Arguments:
   i - Set and read the review point.
   move = If True, shift the focus.
   buffer - The buffer to move through (defaults to the main output).
  """
  if buffer is None:
   v = self.output.GetValue().strip().split('\n')
  else:
   v = buffer
  n = len(v)
  if i < 0:
   i = n + i
  elif i >= n:
   i = n - 1
  if move:
   self._review = i
  try:
   last_review, last_i, last_buffer = self.last_review
   text = v[i]
   if time() - last_review <= application.config.get('application', 'copy_after') and last_i == i and last_buffer == buffer:
    pyperclip.copy(text)
    text = 'Copied %s' % text
   self.last_review = [time(), i, buffer]
  except IndexError:
   text = 'No text.'
  functions.say(text)
def checkLastTransaction():
	apiUrl = cfg.SERVER_API_URL + 'transaction/last'

	# get last transaction from api (server)
	response = urllib2.urlopen(apiUrl).read()
	jsonData = json.loads(response)

	#say
	voiceMsg = 'Last income transaction details. ' + 'Sender: ' +  jsonData['signer_name'] + '. Amount: ' + str(jsonData['amount_xym']) + ' XYM which is equivalent of $' + str(jsonData['amount_usd']) + '. Message: ' + jsonData['message']
	func.say(voiceMsg)
def checkCoinPrice(coin):
	apiUrl = 'https://min-api.cryptocompare.com/data/price?fsym=' + coin + '&tsyms=USD,BTC'
	try:
		response = urllib2.urlopen(apiUrl).read()
		jsonData = json.loads(response)

		return float(jsonData['USD']) 
	except:
		func.say(voice.API_ERROR_MSG)
		return ''
def checkAccountBalance():
	apiUrl = cfg.SERVER_API_URL + 'account'

	try:
		# get account balance from api (server)
		response = urllib2.urlopen(apiUrl).read()
		jsonData = json.loads(response)

		# say
		voiceMsg = 'Your balance is: ' + jsonData['balance_xym'] + ' XYM which is equivalent of $' + jsonData['balance_usd']
		func.say(voiceMsg)
	except:
		func.say(voice.API_ERROR_MSG)
def loc():
	msg = ''
	
	try:
		apiUrl = 'http://ipinfo.io/json'
		response = urllib2.urlopen(apiUrl).read()
		jsonData = json.loads(response)	
	
		msg = 'Your current location is ' + jsonData['city'] + ', ' + jsonData['org']
	except:
		msg = cfg.API_ERROR_MSG
		
	func.say(msg)
def time():
	msg = 'Time is: ' + datetime.now().strftime('%H:%M:%S')
	func.say(msg)
def exit():
	func.say(voice.EXIT_MSG)
	sys.exit()
def shutdown():
	func.say(voice.SHUTDOWN_MSG)
	os.system('sudo shutdown -h now')
def reboot():
	func.say(voice.REBOOT_MSG)
	os.system('sudo reboot')
Beispiel #10
0
def sendTransaction():
	# select recipient (from saved contacts)
	func.say(voice.SELECT_RECIPIENT_MSG)
	recipient = func.transcribe(3)

	# select amount to send
	func.say(voice.SELECT_AMOUNT_MSG)
	amount = func.transcribe(3)

	# select message
	func.say(voice.SELECT_MESSAGE_MSG)
	message = func.transcribe(3)
	
	# if recipient and amount are not empty
	if recipient and amount:
		# confirm
		confirmVoiceMsg = ''
		if message:
			confirmVoiceMsg = 'Are you sure you want to send ' + str(amount) + ' XYM to ' + recipient + ' with message ' + message + '?'
		else:
			confirmVoiceMsg = 'Are you sure you want to send ' + str(amount) + ' XYM to ' + recipient + '?'

		func.say(confirmVoiceMsg) 
		confirm = func.transcribe(3)

		# if configm, send transaction
		if confirm == 'Yes':
			# gen url to api (server)
			apiUrl = cfg.SERVER_API_URL + 'transaction/send/' + recipient + '/' + str(amount) + '/' + message.replace(' ', '%20')	
			func.say(voice.TRANSACION_SENDED_MSG)

			# send transaction and wait for confirmation
			response = urllib2.urlopen(apiUrl).read()
			jsonData = json.loads(response)

			# say confirmation
			voiceMsg = 'Transaction confirmed. Now your balance is: ' + jsonData['balance_xym'] + ' XYM which is equivalent of $' + jsonData['balance_usd']
			func.say(voiceMsg)
		else:
			func.say(voice.TRANSACTION_NOT_SENDED_MSG)
	else:
		func.say(voice.SEND_TRANSACTION_NOT_UNDERSTAND_MSG)
Beispiel #11
0
        # This splits the resulting input string into an list based on
        # whether or not there is a ' ' character separating input
        commands = prompt.split(" ")

        # This loops through each element in the commands list and
        # strips all whitespace off each string element
        for i in range(len(commands)):
            commands[i] = commands[i].strip()

        # if the command is 'say' then try to print message based on
        # the option, but if the string isn't provided, write an error
        # message
        if commands[0].lower() == "say" or commands[0].lower() == "s":
            try:
                if len(commands) >= 2:
                    fn.say(commands)
                else:
                    raise err.FieldNotProvidedError
            except err.FieldNotProvidedError:
                txt.print_red(
                    "FieldNotProvidedError: Cannot execute: not enough arguments!"
                )
        # if the command is 'say-reverse' then try to print reverse message
        # but if a string isn't provided, print an error message.
        elif commands[0].lower() == "say-reverse" or commands[0].lower(
        ) == "srev":
            try:
                if len(commands) >= 2:
                    fn.say_reverse(commands)
                else:
                    raise err.FieldNotProvidedError