// 논리 연산자 > // 큰다 < // 작다. == // 같다. >= // 크거나 같다 <= // 작거나 같다. != // 같지 않다
// 랜덤 숫자 생성 val diceRange: IntRange = (1..7) val randomNumber = diceRange.random()
fun roll() { val anotherRandomNumber = (1..6).random() println(randomNumber) println(anotherRandomNumber) }
// repeat 함수를 이용한 반복 실행 fun printBorder() { repeat(23) { print("=") } }
// if /else 조건문 fun main() { val num = 4 if (num > 4) { println("The variable is greater than 4") } else if (num == 4) { println("The variable is equal to 4") } else { println("The variable is less than 4") } }
// when 조건문
when (rollResult) { luckyNumber -> println("You won!") 1 -> println("So sorry! You rolled a 1. Try again!") 2 -> println("Sadly, you rolled a 2. Try again!") 3 -> println("Unfortunately, you rolled a 3. Try again!") 4 -> println("No luck! You rolled a 4. Try again!") 5 -> println("Don't cry! You rolled a 5. Try again!") 6 -> println("Apologies! you rolled a 6. Try again!") }
// when 을 활용한 변수 값 할당. val drawableResource = when (diceRoll) { 1 -> R.drawable.dice_1 2 -> R.drawable.dice_2 3 -> R.drawable.dice_3 4 -> R.drawable.dice_4 5 -> R.drawable.dice_5 else -> R.drawable.dice_6 }
// 간단한 클래스 : property와 메서드 class Dice { // class property 선언 var sides = 6
// class method 선언 fun roll() { val randomNumber = (1..6).random() println(randomNumber) } }
// 클래스 파라메터 class Dice (val numSides: Int) { fun roll(): Int { val randomNumber = (1..numSides).random() return randomNumber } }
Traceback (most recent call last):
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py",
line 193, in _run_module_as_main
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py",
line 85, in _run_code
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
cli(prog_name="sam")
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py", line 96, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py", line 62, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\start_api\cli.py", line 86, in cli
parameter_overrides,
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\start_api\cli.py", line 142, in do_cli
aws_profile=ctx.profile,
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\cli_common\invoke_context.py", line 136, in __enter__
if not self._container_manager.is_docker_reachable:
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\manager.py", line 47, in is_docker_reachable
self.docker_client.ping()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\client.py", line 187, in ping
return self.api.ping(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\api\daemon.py", line 166, in ping
return self._result(self._get(self._url('/_ping'))) == 'OK'
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\api\client.py", line 230, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\requests\sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen
chunked=chunked,
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\client.py", line 1252, in request
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\client.py", line 1298, in _send_request
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\client.py", line 1247, in endheaders
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\client.py", line 1026, in _send_output
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\client.py", line 966, in send
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipeconn.py", line 32, in connect
sock.connect(self.npipe_path)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 23, in wrapped
return f(self, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 72, in connect
raise e
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 59, in connect
0
pywintypes.error: (2, 'CreateFile', '지정된 파일을 찾을 수 없습니다.')
위와 같이 에러가 표시되며 실행이 안됐다.
왜 실행이 안되지 하며
다시 설치 과정을 다시 짚어보다가 도커 실치 과정을 봤다.
도커를 실행하고 나니 제대로 서비스가 올라갔다.
Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
You can now browse to the above endpoints to invoke your functions. You do not
need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-09-09 23:25:23 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
도커가 실행되지 않고 있어서 로컬 실행이 안되었던 것이다.
서비스가 올라간 후 해당 서비스로 브라우저로 접속해보면 http://127.0.0.1:3000/hello 아래와 같이 도커 이미지를 마운트 하는 작업을 그때서야 시작하고 도커에서 공유 폴더 수락하겠냐고 경고가 나오면 수락해줬다.