コード例 #1
0
def renew_from_sql(idnumber):
    url = 'http://' + SERVER + ':' + PORT + '/renewcard'
    data = {'idnumber':str(idnumber)}
    res=requests.get(url,params=data)
    req = res.text
    req = req[3:-4]
    print(req)
    flag_word = req[0]
    info_dict = json.loads(req[2:])
    print(info_dict)
    if flag_word == 'S':
        while (True):
            line = ser.readline()
            print(line)
            if len(line) != 0:
                print("Writing!")
                try:
                    create(info_dict['name'], int(info_dict['sex']), int(info_dict['identifies']), info_dict['department'], 
                            int(info_dict['idnumber']), info_dict['validdate'][0:8], info_dict['validdate'][9:])
                    break
                except:
                    operate_end(ser)
                    print("put the card again")
                else:
                    pass
        return SUCCESS
    else:
        return CONSTRUCTIONERROR
    return FAILED
コード例 #2
0
ファイル: main.py プロジェクト: programowanie/proj_eva
def main():
    #Czas na wybór użytkownika
    choice = input("\nCo chcesz zrobić?: ")
    if choice == "1":
        symulate()
        input()
    elif choice == "2":
        create()
        input()
    elif choice == "3":
        quit()
    else:
        print("\nNie ma takiej opcji!")
        main()
コード例 #3
0
ファイル: main.py プロジェクト: programowanie/proj_eva
def main():
    #Czas na wybór użytkownika
    choice = input("\nCo chcesz zrobić?: ")
    if choice=="1":
        symulate()
        input()
    elif choice=="2":
        create()
        input()
    elif choice=="3":
        quit()
    else:
        print("\nNie ma takiej opcji!")
        main()
コード例 #4
0
def run_game():
    pygame.init()  #初始化pygame
    pygame.display.set_caption("Freecell")  #给框命名
    global screen  #(和下一行)定义screen(窗口)对象
    screen = pygame.display.set_mode((1200, 800))

    #;print('here')#初始化对象(仅参数)

    create()

    while True:
        clock.tick(100)
        check_events()  #检测输入
        var_update()  #更新参数
        screen_update()  #更新显示
コード例 #5
0
def create_new_member(name, sex, ty, department, ID, start_date, end_date):
    #需要对输入进行格式判定
    print(name, sex, ty, department, ID, start_date, end_date)
    if len(name) > 6:
        return CONSTRUCTIONERROR
    if not (sex == 1 or sex == 2 or sex == 3):
        return CONSTRUCTIONERROR
    if not (ty == 1 or ty == 2 or ty == 3):
        return CONSTRUCTIONERROR
    if len(department) > 4:
        return CONSTRUCTIONERROR
    if not len(str(ID)) == 10 or not int(ID / 10000000) == 201:
        return CONSTRUCTIONERROR
    if not (check_date_valid(start_date) and check_date_valid(end_date)):
        return CONSTRUCTIONERROR
    
    url = 'http://' + SERVER + ':' + PORT + '/createcard'
    data = {'name':name, 'sex':str(sex), 'ty':str(ty), 'department':department, 'ID':str(ID), 'startdate':start_date, 'enddate':end_date}
    res=requests.get(url,params=data)
    req = res.text
    req = req[3:-4]
    print(req)
    if req == 'Success!':
        while (True):
            line = ser.readline()
            print(line)
            if len(line) != 0:
                print("Writing!")
                try:
                    create(name, sex, ty, department, ID, start_date, end_date)
                    break
                except:
                    operate_end(ser)
                    print("put the card again")
                else:
                    pass
        return SUCCESS
    else:
        return FAILED
    return FAILED
コード例 #6
0
def stack_vm():
    fetch_image()
    fetch_flavor()
    server = None
    name = '{}-{}'.format(name_prefix, time.time())
    try:
        files = {
            '/root/.ssh/authorized_keys': public_key_file(),
            '/root/bootstrap.sh': content('scripts/bootstrap.sh')
        }
        server = create(name, files=files)
        ping(server)
        log.info('Created server {}'.format(server.name))
        return server
    except KeyboardInterrupt as ex:
        print 'Interrupted'
        sys.exit(0)
コード例 #7
0
def add_list_item():
    json_response = jsonify(create())
def dynamo_document() -> {{cookiecutter.model_name_camel}}Document:
    payload = {
        "created_at": arrow.utcnow().isoformat(),
    }
    instance = {{cookiecutter.model_name_camel}}DocumentSchema().load(payload)
    instance.save()
    return instance


def test_create_{{cookiecutter.model_name_slug}}_document():
    test_uuid = get_uuid(as_string=True)
    payload = {
        "uuid": test_uuid,
    }
    event = {"body": json.dumps(payload)}
    response = create(event, None)
    assert response == {
        "body": {% raw %}f'{{"uuid": "{test_uuid}"}}',{% endraw %}
        "statusCode": 201,
        "headers": {"Access-Control-Allow-Origin": "*"},
    }


@pytest.mark.freeze_time("2020-04-12 12:00:01")
def test_retrieve_{{cookiecutter.model_name_slug}}_document(dynamo_document):
    event = {"pathParameters": {"uuid": dynamo_document.uuid}}
    response = retrieve(event, None)
    assert response["statusCode"] == 200
    body = json.loads(response["body"])
    logger.debug(body)
    assert body["data"] == {
コード例 #9
0
        while (True) :
            print ("======================Menu==================")
            print ("Enter your choice from 1 to 2: ")
            print ("1- display projects ")
            print ("2- search projects ")
            print ("3- create projects ")
            print ("4- delete projects ")
            ch =  raw_input("Enter your choice from 1 to 4: ")
            if ch == "1" :
                    display();

            elif ch == "2" :
                    print ("1- delete by title : ")
                    print ("2- delete by date : ")
                    print ("Enter your choice from 1 to 2: ")
                    choice = raw_input("> ")

                    if choice == "1" :
                        search("title")
                    elif choice == "1":
                        search("date")
                    else:
                        print("wrong choice")

            elif ch == "3" :
                    response = create(user_name)

            elif ch == "4" :
                    delete(user_name)
                
コード例 #10
0
def main(argv):

	loginType = 0

	accounts = []
	transactions = []
	deletions = []
	withdrawals = {}
	
	if (not len(argv) == 2):
		return
	
	# Infinite loop for receiving input.
	while True:
		
		command = input()
		
		# Disallow any actions until login.
		if (not loginType and command != 'login'):
			print "Error, please login before entering other commands."
		
		# Disallow multiple logins.
		elif (loginType and command == 'login'):
			print "You are already logged in."

		# Execute login
		elif command == 'login':
			loginType = login(accounts, argv[0])
		
		# Execute logout
		elif command == 'logout':
			loginType = logout(transactions, argv[1])

		# Disallow create in retail mode
		elif loginType == 2 and command == 'create':
			print "Error, please use agent mode to create accounts."
			
		# Execute create
		elif command == 'create':
			create(accounts, deletions, transactions)
			
		# Disallow delete in retail mode
		elif loginType == 2 and command == 'delete':
			print "Error, please use agent mode to delete accounts."

		# Execute delete
		elif command == 'delete':
			delete(accounts, deletions, transactions)
			
		# Execute deposit
		elif command == 'deposit':
			deposit(loginType, accounts, deletions, transactions)

		# Execute withdraw
		elif command == 'withdraw':
			withdraw(loginType, accounts, deletions, transactions, withdrawals)
			
		# Execute transfer
		elif command == 'transfer':
			transfer(loginType, accounts, deletions, transactions)
			
		else:
			print "Error, command not recognized."
			
        if loginType == 0:
			withdrawals = {}
			deletions = []