Beispiel #1
0
	def Urmod(self,stmt,cu_args):
		id = stmt.index('(')
		function = stmt[id-1]
		module = stmt[id-3]
		string_args = [""]
		var = ""
		for i in stmt[id+1:-1]:
			if i is not ',':
				if self.arg_nam.count(i) > 0:
					string_args[-1] = "args[" + str(self.arg_nam.index(i)) + "]"
				elif i == 'size':
					size = self.args[self.arg_nam.index(stmt[stmt.index(i)-2])].size
					string_args[-1] = str(size)
				else:
					string_args[-1] += str(i)
			else:
				string_args.append("")
		modules.execute(module,function,string_args,cu_args)
Beispiel #2
0
	def Urmod(self,stmt,cu_args):
		id = stmt.index('(')
		function = stmt[id-1]
		module = stmt[id-3]
		string_args = [""]
		var = ""
		for i in stmt[id+1:-1]:
			if i is not ',':
				if self.arg_nam.count(i) > 0:
					string_args[-1] = "args[" + str(self.arg_nam.index(i)) + "]"
				elif i == 'size':
					size = self.args[self.arg_nam.index(stmt[stmt.index(i)-2])].size
					string_args[-1] = str(size)
				else:
					string_args[-1] += str(i)
			else:
				string_args.append("")
		modules.execute(module,function,string_args,cu_args)
Beispiel #3
0
def main():
    while True:
        try:
            try:
                client, address = s.accept()
                address = '@' + address[0]
                user = client.recv(32)

                if user in ALLOWED_USER:
                    client.send('ok')  # send confirmation to client
                    login_name = client.recv(64)
                    client.send('ok')
                    listSession = client.recv(8)
                else:
                    client.send('Error: User ' + user + ' is not allowed to delete session.')
                    client.close()
                    #write_log(FILE_OUT, user+address, 'Access', 'Not allowed to delete session.')
                    #send_mail(SEND_TO, user+address, 'Access', 'Not allowed to delete session.')
                    send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, {'send_to': ['*****@*****.**']},
                              user + address, 'Access', 'Not allowed to delete session.')
                    continue

            except Exception, failure:
                write_log(FILE_OUT, 'Socket ', 'system', 'Error: ', str(failure))
                #send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, {'send_to': ['*****@*****.**']},
                #          'Error', 'system', str(failure))
                continue

            login_name = correction(login_name)

            if login_name == 'QUIT':
                client.send('Error: Connection lost.')
                client.close()
                s.close()
                break

            if login_test(login_name):
                result = execute(login_name, listSession)
                #write_log(FILE_OUT, user+address, login_name, result.rstrip())
                #send_mail(SEND_TO, user+address, login_name, result.rstrip())
                client.send(result.rstrip())
                client.close()
                send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, {'send_to': ['*****@*****.**']},
                          user + address, login_name, result.rstrip())
            else:
                #write_log(FILE_OUT, user+address, login_name, 'Syntax error.')
                #send_mail(SEND_TO, user+address, login_name, 'Syntax error.')
                client.send('Error: ' + login_name + ' Syntax error.')
                client.close()
                send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, {'send_to': ['*****@*****.**']},
                          user + address, login_name, 'Syntax error.')

        except Exception, failure:
            write_log(FILE_OUT, user+address, login_name, 'Error: ', str(failure))
Beispiel #4
0
def main(ALLOWED_USER, SEND_TO):  # For testing
    for user in ALLOWED_USER:
        try:
            file_path = '/export/home/'+user+'/dinput.txt'
            login_name_list = open_file(file_path)
            if login_name_list is not None:  # If open_file can open file
                for login_name in login_name_list:
                    login_name = correction(login_name)
                    if login_test(login_name): 
                        result = execute(login_name)
                        write_log(FILE_OUT, user, login_name, result.rstrip())
                        send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, SEND_TO, user, login_name, result.rstrip())
                    else:
                        write_log(FILE_OUT, user, login_name, 'Possible syntax or semantic error.')
                        send_mail(SMTP_IP, SMTP_PORT, SEND_FROM, SEND_TO, user, login_name,
                                  'Possible syntax or semantic error.')
                open(file_path, 'wb').close()
        except Exception, failure:
            write_log(FILE_OUT, user, 'system', 'Error: ', str(failure))
            send_mail(SMTP_IP, SMTP_PORT,  SEND_FROM, {'send_to': ['*****@*****.**']},
                      user, 'system', str(failure))
Beispiel #5
0
import sys
import os
import modules

def respond(response):
    print response + "\n"
    os.system("espeak -v en-us -p 0 -s 150 \"" + response + "\"")

exit = False

print # Initialize program with blank line
respond("MY NAME IS FINN. HOW CAN I HELP YOU?")

while exit is not True:

    command = raw_input()

    # set the return value of modules' execute function to a variable so we don't run it more than once
    response = modules.execute(command)

    if(response != None):
        respond(response)
    else:
        if command.lower() == "exit":
            respond("EXITING.")
            exit = True
        elif command != "":
            respond("SORRY, I DON'T UNDERSTAND WHAT YOU MEAN.")

sys.exit(0)