示例#1
0
def execute(mytext):
    if (mytext.lower() == 'send email'):
        modules.send_mail()
        return
    elif (mytext.lower() == 'weather update'):
        modules.weather_update()
        return
    elif (mytext.lower() == 'list files'):
        modules.list_files()
        return
    elif (mytext.lower() == 'date'):
        modules.today_date()
        return
    elif (mytext.lower() == 'shutdown'):
        modules.shutdown_now()
        return
    elif (mytext.lower() == 'reboot'):
        modules.reboot_now()
        return
    elif (mytext.lower() == 'create file'):
        modules.create_file()
        return
    elif (mytext.lower() == 'file type'):
        modules.file_type()
        return
    elif (mytext.lower() == 'create user'):
        modules.create_user()
        return
    elif (mytext.lower() == 'delete user'):
        modules.delete_user()
        return
    elif (mytext.lower() == 'current directory'):
        modules.current_working_dir()
        return
    elif (mytext.lower() == 'create directory'):
        modules.create_dir()
        return
    elif (mytext.lower() == 'go back'):
        modules.back()
        return
    elif (mytext.lower() == 'change directory'):
        modules.change_dir()
        return
    elif (mytext.lower() == 'delete file'):
        modules.delete_file()
        return
    elif (mytext.lower() == 'delete directory'):
        modules.delete_dir()
        return
    else:
        formatting.text_box('Invalid Command!')
        return
示例#2
0
文件: server.py 项目: maxsocl/ssc
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))
示例#3
0
文件: session.py 项目: maxsocl/ssc
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))