Example #1
0
    def post(self, *args, **kwargs):
        files = self.request.files.get('file', None)  #获取上传文件数据,返回文件列表

        for file in files:  #可能同一个上传的文件会有多个文件,所以要用for循环去迭代它
            # filename 文件的实际名字,body 文件的数据实体;content_type 文件的类型。 这三个对象属性可以像字典一样支持关键字索引
            save_to = './datasets/mp4/{}'.format(file['filename'])
            #以二进制格式打开一个文件只用于写入。如果该文件已存在则打开文件,并从开头开始编辑,即原有内容会被删除。如果该文件不存在,创建新文件。一般用于非文本文件如图片等。
            with open(save_to, 'wb') as f:  #二进制
                f.write(file['body'])
            start()
        self.redirect('/result')
Example #2
0
File: main.py Project: trivedi/rpg
def menu():
    while True:
        clear()
        print ""
        print t.red(
            "    ___    ____ _    _________   __________  ______  ______   ____  __  ___________________"
        )
        print t.red(
            "   /   |  / __ \ |  / / ____/ | / /_  __/ / / / __ \/ ____/  / __ \/ / / / ____/ ___/_  __/"
        )
        print t.red(
            "  / /| | / / / / | / / __/ /  |/ / / / / / / / /_/ / __/    / / / / / / / __/  \__ \ / /   "
        )
        print t.red(
            " / ___ |/ /_/ /| |/ / /___/ /|  / / / / /_/ / _, _/ /___   / /_/ / /_/ / /___ ___/ // /  "
        )
        print t.red(
            "/_/  |_/_____/ |___/_____/_/ |_/ /_/  \____/_/ |_/_____/   \___\_\____/_____//____//_/"
        )
        print ""
        print t.magenta(
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        )
        print ""
        if name == "posix":
            print "Welcome, %s!" % user
        else:
            print "Welcome!"
        print "Please select an option"
        print ""
        print "Play  -- your adventure awaits"
        print "Story -- read what the adventure is all about"
        print "Exit  -- quit the current session"
        print "About"
        print "Restart"
        print ""
        while True:
            command = prompt()
            if command in ("s", "story", "Story"):
                story()
            elif command in ("p", "play", "Play"):
                start()
            elif command in ("q", "quit", "exit"):
                break
            elif command in ("r", "restart", "Restart"):
                restart()
            elif command in ("a", "about", "About"):
                about()
            else:
                clear()
                menu()
        break
Example #3
0
    def show_start_screen(self):
        #start show
        #shows the start screen
        start()
        self.start_m.play()

        for event in pg.event.get():
            if event.type == pg.KEYDOWN:
                if event.key == pg.K_SPACE:
                    self.running = True

            if event.type == pg.QUIT:
                exit()
Example #4
0
def update(n, L, dist, model, prop, k, m):
    position = start(n, L, dist)
    position_plus_t1 = np.zeros(n)
    counter = 0
    save_positions = [position]
    sqrt_machine_epsilon = np.sqrt(np.finfo(np.float64).eps)
    while any(np.around(position_plus_t1, 3) != np.around(position, 3)):
        counter = counter + 1
        N = np.zeros(n)
        nrN = np.zeros(n)
        if all(position_plus_t1 == np.zeros(n)):
            position = position
        else:
            position = position_plus_t1
        r = radius(n, L, k, m, model, prop, position)
        if counter == 1:
            r_old = r
        if model == "Proportion open":
            r = r_old
    # Find neighbors to the right
        for i in range(n):
            if r[i] == 0:
                N[i] = N[i] + position[i]
                nrN[i] = nrN[i] + 1
                continue
            j = i
            while j < n and position[j] - position[i] <= r[
                    i] + sqrt_machine_epsilon:
                N[i] = N[i] + position[j]
                nrN[i] = nrN[i] + 1
                j = j + 1
    # Find neighbors to the left
        for i in reversed(range(n)):
            if r[i] == 0:
                N[i] = N[i] + position[i]
                nrN[i] = nrN[i] + 1
                continue
            j = i
            while j >= 0 and position[i] - position[j] <= r[
                    i] + sqrt_machine_epsilon:
                N[i] = N[i] + position[j]
                nrN[i] = nrN[i] + 1
                j = j - 1
    # Update
        N = N - position
        nrN = nrN - 1
        position_plus_t1 = N / nrN
        save_positions.append(position_plus_t1)

# Output
    save_positions = np.array(save_positions)
    save_positions = np.around(save_positions, 3)
    save_positions = np.delete(save_positions, counter, 0)

    return save_positions, counter, r


#update(14, 4, 'U(0,L)', 'Proporition closed')
Example #5
0
def start():
    action = input(CRED + "ᵒ" + CYELLOW + "ᵒ" + CEND + "ᵒ MENU | "
                   "Actions: " + CBBLUE + "[sign up]" + CEND + " | " + CBBLUE +
                   "[power off]" + CEND + " ")

    if action == "sign up":
        signUp.signUp()
#    elif action == "login":
#        login_check()
    elif action == "power off":
        boot.boot()
    else:
        print(CRED + "ERR_00: No such action" + CEND)
        time.sleep(2)
        clear.clear()
        start()
    pass
    pass
def run_plot():
    if model.get() == 'Chose model':
        print('Chose model and run again.')
        return

    s, counter, r = update(int(e1.get()), int(e2.get()),
                           str(distribution.get()), str(model.get()),
                           float(e3.get()), float(e4.get()), float(e5.get()))
    nr_clusters = len(np.unique(s[counter - 1, :]))
    print("Number of clusters", nr_clusters)
    if c.get() == 1:
        # Plot radii at t = 0
        start_position = start(int(e1.get()), int(e2.get()),
                               str(distribution.get()))
        rad = radius(int(e1.get()), int(e2.get()), float(e4.get()),
                     float(e5.get()), str(model.get()), float(e3.get()),
                     start_position)
        rad_fig = plt.figure('Radii at t = 0')
        ax = rad_fig.add_subplot(111)
        line, = ax.plot(start_position, rad, lw=2)
        ax.set_xlabel("Agent position (continuous)")
        ax.set_ylabel("Radii (continuous)")

    if p.get() == 1:
        # Plot opinion dynamics
        for i in range(counter):
            plt.figure('Opinion dynamics')
            plt.plot(np.reshape(s[i, 0:int(e1.get())], (1, int(e1.get()))),
                     np.full((1, int(e1.get())), i),
                     'ro',
                     markersize=9)
            plt.plot([0, int(e2.get())], [i, i], '-k')
            plt.xlabel('Agent position (continuous)')
            plt.ylabel('Time (discrete)')
            plt.yticks(np.arange(0, counter, 1))
            values, index, numbers = np.unique(s[i, :],
                                               return_index=True,
                                               return_counts=True)
            if i == 0:
                continue
            for j in range(len(values)):
                plt.text(values[j], i, numbers[j], fontsize=14)
            plt.show

    if p_horizontal.get() == 1:
        plt.figure('Opinion dynamics vertical')
        t = np.linspace(0, counter - 1, counter)
        for agent in range(int(e1.get())):
            plt.plot(t, s[:, agent])
            plt.xlabel('Time (discrete)')
            plt.ylabel('Agent position (continuous)')
        plt.show
Example #7
0
async def on_message(message):
    # no self reply
    if message.author == client.user:
        return

    if message.content.startswith("scan"):
        msg = message.content
        ips = re.findall(r"[0-9]+(?:\.[0-9]+){3}", msg)
        keyword = re.findall(r"^(?:\w+ ){1}", msg)
        reply = "Hello {0.author.mention}! Starting a complete scan on the given IP".format(
            message)
        print("User message is: " + msg + " and the IP to scan is: " +
              str(ips[0]) + " and keyword is: " + str(keyword[0]))
        await message.channel.send(reply)
        start(ips[0], keyword[0])
        await message.channel.send(file=discord.File('output.txt'))

    if message.content.startswith("selfcheck"):
        reply = "Hello {0.author.mention}! Starting self check module. Audit report will be sent once done".format(
            message)
        await message.channel.send(reply)
        selfcheck()
        await message.channel.send(file=discord.File('output.txt'))
Example #8
0
from start import *

ip = str(input("Enter IP address: "))
keyword = str(input("Enter keyterm associated with IP for cloud searches: "))
start(ip, keyword)
Example #9
0
def main():

    from argparse import ArgumentParser, RawTextHelpFormatter
    import os

    parser = ArgumentParser(description="Command line support for the 'aion' project", formatter_class=RawTextHelpFormatter, add_help=False)

    parser.add_argument("command", nargs="+")

    args = parser.parse_args()

    try:
        command = args.command[0].strip()

        if os.path.isfile(command):
            import __init__
            __init__.ExecuteAionFile(command)

        elif command == "help" or command == "-help" or command == "--help":
            print(help)

        elif command == "start" or command == "run":
            os.system("python3 " + atils.aion_path + "/main.py")

        elif command == "install":
            errno = "77227"
            arglen_check(args.command, 2)
            package = args.command[1]
            if package == "aion":
                must_be_sudo()
                Install.aion()
                print("Installed aion")
            elif package == "respeaker":
                must_be_sudo()
                Install.respeaker(yesno("Install in compatibility mode? (installs older kernel version)? (y/n): "))
                print("Installed respeaker")
            elif os.path.exists(package):
                if package.strip() == "skill.aion":
                    Install.skill_from_aion_file(package)
                elif package.strip() == "plugin.aion":
                    Install.plugin_from_aion_file(package)
                elif package.endswith(".skill"):
                    Install.skill_from_skill_file(package)
                elif package.endswith(".plugin"):
                    Install.plugin_from_plugin_file(package)
                else:
                    AionShellError(package + " is an unknowing skill / plugin. Type 'aion help' for help", errno)
            else:
                AionShellError(package + " is an unknowing skill / plugin. Type 'aion help' for help", errno)

        elif args.command in ["kill", "stop"]:  # kist
            arglen_check(args.command, 1)
            is_aion_running(command)
            import variable
            import signal
            avar = variable.Variable()
            os.kill(int(avar.get_value("AION_PID")), signal.SIGKILL)

        elif command == "load":
            arglen_check(args.command, 2, 3)
            import save as asave
            if len(args.command) == 3:
                asave.load_save(str(args.command[1]), str(args.command[2]))
            else:
                asave.load_save(str(args.command[1]))

        elif command == "pack":
            no_skill_plugin_file_errno = "27177"
            no_dir_errno = "27178"
            arglen_check(args.command, 2)
            dir = args.command[1]
            if os.path.isdir(dir):
                if os.path.isfile(dir + "/skill.aion"):
                    Pack.skill(dir)
                elif os.path.isfile(dir + "/plugin.aion"):
                    Pack.plugin(dir)
                else:
                    AionShellError("couldn't find 'skill.aion' or 'plugin.aion' in " + dir + ". See 'create_skill_file' function in 'aionlib.skill' to create a 'skill.aion' file"
                                   "or 'create_plugin_file' function in 'aionlib.plugin' to create a 'plugin.aion' file", no_skill_plugin_file_errno)
            else:
                AionShellError("couldn't find directory " + dir, no_dir_errno)

        elif command == "pid":
            arglen_check(args.command, 1)
            is_aion_running(command)
            import variable
            avar = variable.Variable()
            print(avar.get_value("AION_PID"))

        elif command == "save":
            arglen_check(args.command, 2)
            import save as asave
            asave.save(args.command[1])

        elif command == "saves":
            arglen_check(args.command, 1)
            import save as asave
            print(" ".join(asave.saves()))

        elif command in ["remove", "uninstall"]:  # UnRem
            errno = "07340"
            arglen_check(args.command, 2)
            package = args.command[1]
            if command == "uninstall":
                name = "Uninstall"
            else:
                name = "Remove"
            question = yesno(name + " " + package + "? (y/n): ")
            if name == "Remove":
                name = "Remov"
            if package == "aion":
                if question is True:
                    question = yesno("Should your personal data ('/etc/aion_data/': custom skills / plugins, version saves, language files, ...) deleted as well? (y/n): ")
                    UnRem.aion(question)
                    print(name + "ed aion")
                    print("You should reboot now to complete the " + name.lower() + " process")
            elif package == "aionlib":
                if question is True:
                    UnRem.aionlib()
                    print(name + "ed aionlib")
            elif package == "respeaker":
                if question is True:
                    UnRem.respeaker()
                    print(name + "ed respeaker")
            else:
                package_type = which_package(package, "Type in the number of your package type: ")
                if package_type == -1:
                    AionShellError("couldn't find skill / plugin " + package, errno)
                elif package_type == 0:
                    UnRem.skill(package)
                elif package_type == 1:
                    UnRem.run_after_plugin(package)
                elif package_type == 2:
                    UnRem.run_before_plugin(package)

        elif command in ["run", "start"]:
            arglen_check(args.command, 1)
            import start
            from os import geteuid
            if geteuid() == 0:
                start(True)
            elif geteuid() == 1000:
                start(False)

        elif command == "update":
            errno = "43503"
            arglen_check(args.command, 2)
            package = args.command[1]
            if package == "aion":
                Update.aion()
            elif package == "aionlib":
                Update.aionlib()
            else:
                package_type = which_package(package, "Type in the number of your package type: ")
                if package_type == -1:
                    AionShellError("couldn't find skill / plugin " + package, errno)
                elif package_type == 0:
                    Update.skill(package)
                elif package_type == 1:
                    Update.run_after_plugin(package)
                elif package_type == 2:
                    Update.run_before_plugin(package)

        elif command == "variable":
            arglen_check(args.command, 2)
            command_variable = args.command[1]
            import variable
            avar = variable.Variable()
            print(avar.get_value(command_variable))

        elif command == "version":
            errno = "56297"
            arglen_check(args.command, 2)
            package = args.command[1]
            if package == "aion":
                Version.aion()
            elif package == "aionlib":
                Version.aionlib()
            else:
                package_type = which_package(package, "Type in the number of your package type: ")
                if package_type == -1:
                    AionShellError("couldn't find skill / plugin " + package, errno)
                elif package_type == 0:
                    Version.skill(package)
                elif package_type == 1:
                    Version.run_after_plugin(package)
                elif package_type == 2:
                    Version.run_before_plugin(package)

        else:
            errno = "12345"
            AionShellError(" ".join(args.command) + " isn't a command. Type 'aion help' to get help", errno)

    except KeyboardInterrupt:
        exit(-1)
Example #10
0
__author__ = 'ChrisPOConnell'
'''
Assignment 4
__init__.py
'''
from start import *

start()
Example #11
0
from start import *
from instruction import *
from c_b import *
from ready import *
from scoreBoard import *

import tkinter

mycolor = '#%02x%02x%02x' % (255, 214, 153)
root = tkinter.Tk()
root.title("C&B")
root.geometry("1000x550")
#root.wm_attributes('-transparent', True)
root.configure(bg=mycolor)

startFrame = start(root)
play = player(root)
inst = instruction(root)
rdy = ready(root)
cb = c_b(root)
sb = scoreBoard(root)

cb.setscorBoard(sb)
inst.setpara(startFrame)
startFrame.setpara(inst, play)
play.setpara(rdy)
rdy.setpara(play, cb)

startFrame.display()

root.mainloop()
Example #12
0
def hilo_start(name):
    global A
    A = start()
    pygame.quit()
    sys.exit()
Example #13
0
import pygame
from start import *
from pygame.locals import *
from pygame_functions import *
from random import randrange
if start() == 1:
    hideAll()
    start()
Example #14
0
                    #dead if in contact with enemy
                    if marioprev[6] == "x" or marioprev[
                            7] == "x" or self.__board.getgrid(
                                mariopresent[0] + 1, mariopresent[1]) == "Q":
                        #not updating enemy prev so it shows dead location
                        life -= 1
                        os.system('aplay ./sounds/smb_mariodie.wav')
                        screen.reset(self)

                    #if all lives used up
                    if life <= 0:
                        os.system('clear')
                        print("GAME OVER   ALL LIVES USED")
                        os.system('aplay ./sounds/smb_gameover.wav')
                        break

#----------------------------------------------------------------------------------------

        finally:
            termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)


#running program
if __name__ == "__main__":

    x = start()
    x.run()
    if quit == 0:
        x = screen()
        x.run()
Example #15
0
# =======================================================================
"""


gameLoaded = False

if gameLoaded:
	print('Welcome back commander')


year = 1949

# MUST UNCOMENT FOR FULL GAME

userName = '******'
userName = start(userName,myNation)






"""
# =======================================================================
# =======================================================================
# MAIN MENU MAIN MENU MAIN MENU MAIN MENU MAIN MENU MAIN MENU MAIN MENU 
# =======================================================================
#                           MAIN MENU MODE 
#     1. View Leaderboard
#     2. Finance Beuro
#     3. Ministry of war
Example #16
0
import socket
from start import *

ip = "192.168.1.7"  # IP of Raspberry Pi

# connect to server
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((ip, 8080))
print("CLIENT: connected")

access = start()
print(access)
# send a message
msg = 'Access Denied'
if access:
    msg = 'Access Granted'
client.send(msg.encode())

# recive a message and print it
from_server = client.recv(4096).decode()
print("Recieved: " + from_server)

# exit
client.close()
Example #17
0
 def main(self):
     t = self.chushi()
     while t:
         r = start(self.screen)
         t = r.main()
Example #18
0
def main():
 	print "Hello World"
	KIPR.enable_servos() 
	#POSITION IN START BOX
	tail_up()
	arm_start(50)
	claw_open(50)
	start(2)
	KIPR.shut_down_in(120)
	print("HERE WE GO!!:")
	KIPR.msleep(2000)
#================================================================   
    
 	#GO GET YELLOW CUBE
	#forward(1000, 1600)
	drive_to_black(1000)
	backward(500, 50)
	arm_yellow(50)
	claw_yellow(50)
	arm_up(50)
    #WE GRABBED YELLOW CUBE
	#NOW MOVE TO DROP IT
	backward(500,3000)
	arm_yellow(50)
	claw_open(50)
	arm_up(50)
	back_to_black(1000)
	#WE SCORED YELLOW CUBE!!!!

	backward(600, 175)
	tail_down()
#We hooked the container!!            

	forward(1500, 2300)
	left(1000,1250)
	forward(1300, 2000) #HIT PIPE IN FRONT
	back_to_black(800)
	right(1000, 1050)
	forward(1000, 3400) #HIT PIPE IN FRONT OF SWINGS!!
	backward(1000, 450)
	left(1000, 1000)
	backward(1000, 1100)
	tail_up()
#Container Placed
	right(1000, 1700)
	arm_half(50)
	right(1000, 800)
	arm_up(50)
	claw_close(50)
            
#knocked over conmtainers, get to ramp
	forward(1000,550) #get away from swings
	right(750,650)#turn to face black tape
	drive_to_black(750)
	right(750,850) #turn to face back pipe
	forward(1000, 6500) #hit back pipe
	backward(1000,700)  #get off back pipe a buit
	left(750,1150)  #turn towards ramp
	forward(1000,5500) #hit pipe by ramp
	backward(1000, 500)
	left(1000,1100)
	backward(1000,1000)


	#GO UP THE RAMP
	#forward(1500, 3000)

	linefollowing_bump(1500)
	
	#Bump
	backward(1000, 700)# get off the pipe
	left(1500,600) #turn to the mine
	forward(1500, 700)
	left(1500,500)
	forward (1500, 700)
	arm_half(30)
	linefollow_cliff(1000)
	backward(1000, 1500)
	#ready to go down
	arm_yellow(10)
	claw_open(50)
	forward(900,750)
	arm_deep(50)
	claw_close(70)
	claw_open(70)
	claw_close(70)
	#We got em, get em out now!!
	arm_yellow(10)
	backward(1000, 700)
	arm_half(10)
	backward(1000, 1000)
	#OK, got em out! Now lets dump it on the ramp!
	claw_open(10)
#SCORED!!  NOW MAKE SECOND GRAB!
	claw_close(50)
	left(1000, 50)
	linefollow_grab(1000)
	backward(1000, 1500)
	#ready to go down
	arm_yellow(25)
	forward(900,610)
	claw_open(50)
	arm_deep(10)
	claw_close(70)
	claw_open(70)
	claw_close(70)
	#We got em, get em out now!!
	arm_yellow(25)
	backward(1000, 800)
	arm_half(25)
	backward(1000, 1000)
	#OK, got em out!  Now lets try and dump #1
	backward(500, 1500)

	claw_open(50)
#SCORED!!  NOW MAKE Third GRAB!
	claw_close(50)
	left(600, 50)
	linefollow_grab(1000)
	backward(1000, 1500)
	#ready to go down
	arm_yellow(25)
	forward(1000,620)
	claw_open(50)
	arm_deep(10)
	claw_close(70)
	claw_open(70)
	claw_close(70)
	#We got em, get em out now!!
	arm_yellow(25)
	backward(1000, 800)
	arm_half(25)
	backward(1000, 1000)
	#OK, got em out!  Now lets try and dump #1
	backward(500, 1500)

	claw_open(50)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
try:
    from dotenv import load_dotenv
    load_dotenv()
except Exception:
    pass
# end try

import dwsongs_normal as start
start()