From b07c4de6ecf150037fde2fb0aa4a1942e9d8168f Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Wed, 3 Sep 2025 23:48:10 +0900 Subject: [PATCH 01/11] initial commit From 928958507bc41b4a00245b7044bf257ed30ab21b Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 00:00:31 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[Fix]formatter=E3=81=AE=E9=81=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 26 +++++++++++++++++++------- theta_init.py | 14 +++----------- theta_status.py | 9 ++------- theta_test_capture.py | 20 ++++++++++++-------- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/theta_capture.py b/theta_capture.py index baef8a1..679a2da 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -25,6 +25,7 @@ {"iso": 100, "shutterSpeed": 3.2, "whiteBalance": 5200}, ] + def set_options(iso, shutterSpeed, whiteBalance): options_command = { "name": "camera.setOptions", @@ -33,29 +34,34 @@ def set_options(iso, shutterSpeed, whiteBalance): "iso": iso, "shutterSpeed": shutterSpeed, "whiteBalance": "_colorTemperature", - "colorTemperature": whiteBalance + "colorTemperature": whiteBalance, } - } + }, } resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS) resp.raise_for_status() return resp.json() + def take_picture(): take_command = {"name": "camera.takePicture"} resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) resp.raise_for_status() return resp.json() + def wait_for_completion(command_id): while True: - status_resp = requests.post(STATUS_URL, json={"id": command_id}, headers=HEADERS) + status_resp = requests.post( + STATUS_URL, json={"id": command_id}, headers=HEADERS + ) status_resp.raise_for_status() status = status_resp.json() if status.get("state") == "done": return status.get("results") time.sleep(0.5) + def capture_12(): """設定リストに従って12枚連続撮影""" for idx, s in enumerate(settings_list, start=1): @@ -72,6 +78,7 @@ def capture_12(): else: print("即時撮影結果:", result) + def schedule_shoots(): """午前6時~午後7時まで1時間おきに3回ずつ撮影""" while True: @@ -89,15 +96,20 @@ def schedule_shoots(): print(f"\n=== {hour}時の撮影完了 ===") # 次の「正時」まで待つ - next_hour = (now + datetime.timedelta(hours=1)).replace(minute=0, second=0, microsecond=0) + next_hour = (now + datetime.timedelta(hours=1)).replace( + minute=0, second=0, microsecond=0 + ) wait_sec = (next_hour - datetime.datetime.now()).total_seconds() if wait_sec < 0: - next_hour = (now + datetime.timedelta(hours=2)).replace(minute=0, second=0, microsecond=0) + next_hour = (now + datetime.timedelta(hours=2)).replace( + minute=0, second=0, microsecond=0 + ) wait_sec = (next_hour - datetime.datetime.now()).total_seconds() print(f"{wait_sec/60:.1f} 分後の {next_hour} に再開します…") - for sleepCount in range(0,61): + for sleepCount in range(0, 61): print(f"残り{wait_sec * (60 - sleepCount)/60}秒") - time.sleep(wait_sec/60) + time.sleep(wait_sec / 60) + if __name__ == "__main__": schedule_shoots() diff --git a/theta_init.py b/theta_init.py index 2405c89..26b530c 100755 --- a/theta_init.py +++ b/theta_init.py @@ -5,11 +5,7 @@ payload = { "name": "camera.setOptions", - "parameters": { - "options": { - "captureMode":"image" - } - } + "parameters": {"options": {"captureMode": "image"}}, } resp = requests.post(url, json=payload, headers=headers) @@ -17,12 +13,8 @@ payload = { "name": "camera.setOptions", - "parameters": { - "options": { - "exposureProgram":1 - } - } + "parameters": {"options": {"exposureProgram": 1}}, } resp = requests.post(url, json=payload, headers=headers) -print(resp.json()) \ No newline at end of file +print(resp.json()) diff --git a/theta_status.py b/theta_status.py index 1998a68..e16ab94 100755 --- a/theta_status.py +++ b/theta_status.py @@ -7,13 +7,8 @@ payload = { "name": "camera.getOptions", "parameters": { - "optionNames": [ - "iso", - "shutterSpeed", - "aperture", - "_colorTemperature" - ] - } + "optionNames": ["iso", "shutterSpeed", "aperture", "_colorTemperature"] + }, } resp = requests.post(url, json=payload, headers=headers) diff --git a/theta_test_capture.py b/theta_test_capture.py index fe0982e..fc43d20 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -6,9 +6,7 @@ EXECUTE_URL = f"http://{THETA_IP}/osc/commands/execute" STATUS_URL = f"http://{THETA_IP}/osc/commands/status" -HEADERS = { - "Content-Type": "application/json;charset=utf-8" -} +HEADERS = {"Content-Type": "application/json;charset=utf-8"} # 撮影設定リスト (ISO, ShutterSpeed, f, ColorTemperature) settings_list = [ @@ -26,6 +24,7 @@ {"iso": 100, "shutterSpeed": 3.2, "whiteBalance": 5200}, ] + def set_options(iso, shutterSpeed, whiteBalance): options_command = { "name": "camera.setOptions", @@ -33,38 +32,43 @@ def set_options(iso, shutterSpeed, whiteBalance): "options": { "iso": iso, "shutterSpeed": shutterSpeed, - "_colorTemperature": whiteBalance + "_colorTemperature": whiteBalance, } - } + }, } resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS) resp.raise_for_status() return resp.json() + def take_picture(): take_command = {"name": "camera.takePicture"} resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) resp.raise_for_status() return resp.json() + def wait_for_completion(command_id): while True: - status_resp = requests.post(STATUS_URL, json={"id": command_id}, headers=HEADERS) + status_resp = requests.post( + STATUS_URL, json={"id": command_id}, headers=HEADERS + ) status_resp.raise_for_status() status = status_resp.json() if status.get("state") == "done": return status.get("results") time.sleep(0.5) + # 連続撮影 for idx, s in enumerate(settings_list, start=1): print(f"\n=== 撮影 {idx}/12 ===") set_options(**s) print("設定完了:", s) - + result = take_picture() print("撮影コマンド送信:", result) - + if "id" in result: pic_result = wait_for_completion(result["id"]) print("撮影完了:", pic_result) From c5202e4e1d272365c7a9a9ee4ecac59a6bbd8b13 Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 00:15:17 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[Fix]pylint=E3=81=AB=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E3=82=92=E3=82=A4=E3=83=B3=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pylint.yml | 1 + requirements.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 3ca7b11..723c664 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -18,6 +18,7 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint + pip install -r requirements.txt - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file From 7a150845207633bfa9f332b916a35ee729608e81 Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 07:56:56 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[Fix]=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E3=82=B9=E3=83=8D=E3=83=BC=E3=82=AF=E3=82=B1=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 32 ++++++++++++++++---------------- theta_test_capture.py | 34 ++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/theta_capture.py b/theta_capture.py index 679a2da..22a3635 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -9,32 +9,32 @@ HEADERS = {"Content-Type": "application/json;charset=utf-8"} -# 撮影設定リスト (ISO, ShutterSpeed, ColorTemperature) +# 撮影設定リスト (ISO, shutter_speed, ColorTemperature) settings_list = [ - {"iso": 100, "shutterSpeed": 0.00004, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.00008, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.0003125, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.000625, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.0025, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.005, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.02, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.04, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.16666666, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.33333333, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.625, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 3.2, "whiteBalance": 5200}, + {"iso": 100, "shutter_speed": 0.00004, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.00008, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.0003125, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.000625, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.0025, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.005, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.02, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.04, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.16666666, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.33333333, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.625, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 3.2, "white_balance": 5200}, ] -def set_options(iso, shutterSpeed, whiteBalance): +def set_options(iso, shutter_speed, white_balance): options_command = { "name": "camera.setOptions", "parameters": { "options": { "iso": iso, - "shutterSpeed": shutterSpeed, + "shutterSpeed": shutter_speed, "whiteBalance": "_colorTemperature", - "colorTemperature": whiteBalance, + "colorTemperature": white_balance, } }, } diff --git a/theta_test_capture.py b/theta_test_capture.py index fc43d20..a2f07dd 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -8,31 +8,31 @@ HEADERS = {"Content-Type": "application/json;charset=utf-8"} -# 撮影設定リスト (ISO, ShutterSpeed, f, ColorTemperature) +# 撮影設定リスト (ISO, shutter_speed, f, ColorTemperature) settings_list = [ - {"iso": 100, "shutterSpeed": 0.00004, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.00008, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.0003125, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.000625, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.0025, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.005, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.02, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.04, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.16666666, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.33333333, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 0.625, "whiteBalance": 5200}, - {"iso": 100, "shutterSpeed": 3.2, "whiteBalance": 5200}, + {"iso": 100, "shutter_speed": 0.00004, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.00008, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.0003125, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.000625, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.0025, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.005, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.02, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.04, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.16666666, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.33333333, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 0.625, "white_balance": 5200}, + {"iso": 100, "shutter_speed": 3.2, "white_balance": 5200}, ] -def set_options(iso, shutterSpeed, whiteBalance): +def set_options(iso, shutter_speed, white_balance): options_command = { "name": "camera.setOptions", "parameters": { "options": { "iso": iso, - "shutterSpeed": shutterSpeed, - "_colorTemperature": whiteBalance, + "shutterSpeed": shutter_speed, + "_colorTemperature": white_balance, } }, } @@ -42,6 +42,7 @@ def set_options(iso, shutterSpeed, whiteBalance): def take_picture(): + """Take a picture using the Theta API""" take_command = {"name": "camera.takePicture"} resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) resp.raise_for_status() @@ -49,6 +50,7 @@ def take_picture(): def wait_for_completion(command_id): + """Wait a few seconds to complete""" while True: status_resp = requests.post( STATUS_URL, json={"id": command_id}, headers=HEADERS From 568e81f6fc034900db3ed5f22439ed89938b695e Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 07:59:39 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[Fix]import=E9=A0=86=E3=82=92=E6=AD=A3?= =?UTF-8?q?=E3=81=97=E3=81=8F=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 4 +++- theta_test_capture.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/theta_capture.py b/theta_capture.py index 22a3635..94c40ed 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -1,7 +1,9 @@ -import requests import time import datetime +import requests + + # カメラIP THETA_IP = "192.168.1.1" EXECUTE_URL = f"http://{THETA_IP}/osc/commands/execute" diff --git a/theta_test_capture.py b/theta_test_capture.py index a2f07dd..c9f2424 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -1,6 +1,8 @@ -import requests import time +import requests + + # カメラIP THETA_IP = "192.168.1.1" EXECUTE_URL = f"http://{THETA_IP}/osc/commands/execute" From 9a2d25a458f483ba74fff124b9a2eba0fa449779 Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:01:37 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[Fix]=E3=82=B3=E3=83=BC=E3=83=89=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E3=81=AF=E5=88=A5=E3=81=AE=E8=AA=B2=E9=A1=8C=E3=81=A7?= =?UTF-8?q?=E6=89=B1=E3=81=86=E3=81=9F=E3=82=81=E3=80=81=E3=81=93=E3=81=93?= =?UTF-8?q?=E3=81=A7=E3=81=AFLint=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C?= =?UTF-8?q?=E5=87=BA=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 1 + theta_init.py | 2 ++ theta_status.py | 2 ++ theta_test_capture.py | 1 + 4 files changed, 6 insertions(+) diff --git a/theta_capture.py b/theta_capture.py index 94c40ed..17f76dd 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -3,6 +3,7 @@ import requests +# pylint: disable=duplicate-code # カメラIP THETA_IP = "192.168.1.1" diff --git a/theta_init.py b/theta_init.py index 26b530c..adddc08 100755 --- a/theta_init.py +++ b/theta_init.py @@ -1,5 +1,7 @@ import requests +# pylint: disable=duplicate-code + url = "http://192.168.1.1/osc/commands/execute" headers = {"Content-Type": "application/json;charset=utf-8"} diff --git a/theta_status.py b/theta_status.py index e16ab94..0a4f9de 100755 --- a/theta_status.py +++ b/theta_status.py @@ -1,5 +1,7 @@ import requests +# pylint: disable=duplicate-code + url = "http://192.168.1.1/osc/commands/execute" headers = {"Content-Type": "application/json;charset=utf-8"} diff --git a/theta_test_capture.py b/theta_test_capture.py index c9f2424..eac6c3c 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -2,6 +2,7 @@ import requests +# pylint: disable=duplicate-code # カメラIP THETA_IP = "192.168.1.1" From 40eced40eed74ee971eea121bba5ceb583539aec Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:04:09 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[Fix]DocString=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 3 +++ theta_test_capture.py | 1 + 2 files changed, 4 insertions(+) diff --git a/theta_capture.py b/theta_capture.py index 17f76dd..1eefaf6 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -30,6 +30,7 @@ def set_options(iso, shutter_speed, white_balance): + """オプションを設定""" options_command = { "name": "camera.setOptions", "parameters": { @@ -47,6 +48,7 @@ def set_options(iso, shutter_speed, white_balance): def take_picture(): + """Theta Web APIを用いて撮影""" take_command = {"name": "camera.takePicture"} resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) resp.raise_for_status() @@ -54,6 +56,7 @@ def take_picture(): def wait_for_completion(command_id): + """撮影完了まで処理を停止""" while True: status_resp = requests.post( STATUS_URL, json={"id": command_id}, headers=HEADERS diff --git a/theta_test_capture.py b/theta_test_capture.py index eac6c3c..5c7c44e 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -29,6 +29,7 @@ def set_options(iso, shutter_speed, white_balance): + """オプションを設定""" options_command = { "name": "camera.setOptions", "parameters": { From ea4d2704b96d4d98a300aafeb2cfe55794e7766d Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:05:23 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[Fix]=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE?= =?UTF-8?q?=E5=86=92=E9=A0=AD=E3=81=ABDocString=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 2 ++ theta_init.py | 2 ++ theta_status.py | 2 ++ theta_test_capture.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/theta_capture.py b/theta_capture.py index 1eefaf6..4773857 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -1,3 +1,5 @@ +"""Script for controlling RICOH THETA camera.""" + import time import datetime diff --git a/theta_init.py b/theta_init.py index adddc08..ebc8192 100755 --- a/theta_init.py +++ b/theta_init.py @@ -1,3 +1,5 @@ +"""Script for controlling RICOH THETA camera.""" + import requests # pylint: disable=duplicate-code diff --git a/theta_status.py b/theta_status.py index 0a4f9de..3f10058 100755 --- a/theta_status.py +++ b/theta_status.py @@ -1,3 +1,5 @@ +"""Script for controlling RICOH THETA camera.""" + import requests # pylint: disable=duplicate-code diff --git a/theta_test_capture.py b/theta_test_capture.py index 5c7c44e..ba4a9ba 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -1,3 +1,5 @@ +"""Script for controlling RICOH THETA camera.""" + import time import requests From 7d2177885df1c7c19b398412a133e1cb143a3183 Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:09:31 +0900 Subject: [PATCH 09/11] [Fix]sleepCount -> sleep_count --- theta_capture.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theta_capture.py b/theta_capture.py index 4773857..2d33cef 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -114,8 +114,8 @@ def schedule_shoots(): ) wait_sec = (next_hour - datetime.datetime.now()).total_seconds() print(f"{wait_sec/60:.1f} 分後の {next_hour} に再開します…") - for sleepCount in range(0, 61): - print(f"残り{wait_sec * (60 - sleepCount)/60}秒") + for sleep_count in range(0, 61): + print(f"残り{wait_sec * (60 - sleep_count)/60}秒") time.sleep(wait_sec / 60) From aa3838ce3ba71a25f16fdcb9ab3c15cbf6997878 Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:11:37 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[Fix]=E5=AE=9A=E6=95=B0=E3=82=92=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=91=E3=83=BC=E3=82=B1=E3=83=BC=E3=82=B9=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_init.py | 8 ++++---- theta_status.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/theta_init.py b/theta_init.py index ebc8192..7493ab7 100755 --- a/theta_init.py +++ b/theta_init.py @@ -4,15 +4,15 @@ # pylint: disable=duplicate-code -url = "http://192.168.1.1/osc/commands/execute" -headers = {"Content-Type": "application/json;charset=utf-8"} +URL = "http://192.168.1.1/osc/commands/execute" +HEADERS = {"Content-Type": "application/json;charset=utf-8"} payload = { "name": "camera.setOptions", "parameters": {"options": {"captureMode": "image"}}, } -resp = requests.post(url, json=payload, headers=headers) +resp = requests.post(URL, json=payload, headers=HEADERS) print(resp.json()) payload = { @@ -20,5 +20,5 @@ "parameters": {"options": {"exposureProgram": 1}}, } -resp = requests.post(url, json=payload, headers=headers) +resp = requests.post(URL, json=payload, headers=HEADERS) print(resp.json()) diff --git a/theta_status.py b/theta_status.py index 3f10058..3c9549a 100755 --- a/theta_status.py +++ b/theta_status.py @@ -4,8 +4,8 @@ # pylint: disable=duplicate-code -url = "http://192.168.1.1/osc/commands/execute" -headers = {"Content-Type": "application/json;charset=utf-8"} +URL = "http://192.168.1.1/osc/commands/execute" +HEADERS = {"Content-Type": "application/json;charset=utf-8"} # 確認したいオプションを parameters に必ず入れる payload = { @@ -15,5 +15,5 @@ }, } -resp = requests.post(url, json=payload, headers=headers) +resp = requests.post(URL, json=payload, headers=HEADERS) print(resp.json()) From af7f6b1981b607e94864f87b5ee667651b7cedce Mon Sep 17 00:00:00 2001 From: Sano Chihiro Date: Thu, 4 Sep 2025 08:13:46 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[Fix]post=E3=81=AE=E9=9A=9B=E3=81=AB?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E3=82=A2=E3=82=A6=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theta_capture.py | 6 +++--- theta_init.py | 4 ++-- theta_status.py | 2 +- theta_test_capture.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/theta_capture.py b/theta_capture.py index 2d33cef..c2f2305 100755 --- a/theta_capture.py +++ b/theta_capture.py @@ -44,7 +44,7 @@ def set_options(iso, shutter_speed, white_balance): } }, } - resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS) + resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS, timeout=10) resp.raise_for_status() return resp.json() @@ -52,7 +52,7 @@ def set_options(iso, shutter_speed, white_balance): def take_picture(): """Theta Web APIを用いて撮影""" take_command = {"name": "camera.takePicture"} - resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) + resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS, timeout=10) resp.raise_for_status() return resp.json() @@ -61,7 +61,7 @@ def wait_for_completion(command_id): """撮影完了まで処理を停止""" while True: status_resp = requests.post( - STATUS_URL, json={"id": command_id}, headers=HEADERS + STATUS_URL, json={"id": command_id}, headers=HEADERS, timeout=10 ) status_resp.raise_for_status() status = status_resp.json() diff --git a/theta_init.py b/theta_init.py index 7493ab7..28fd9e6 100755 --- a/theta_init.py +++ b/theta_init.py @@ -12,7 +12,7 @@ "parameters": {"options": {"captureMode": "image"}}, } -resp = requests.post(URL, json=payload, headers=HEADERS) +resp = requests.post(URL, json=payload, headers=HEADERS, timeout=10) print(resp.json()) payload = { @@ -20,5 +20,5 @@ "parameters": {"options": {"exposureProgram": 1}}, } -resp = requests.post(URL, json=payload, headers=HEADERS) +resp = requests.post(URL, json=payload, headers=HEADERS, timeout=10) print(resp.json()) diff --git a/theta_status.py b/theta_status.py index 3c9549a..08a1060 100755 --- a/theta_status.py +++ b/theta_status.py @@ -15,5 +15,5 @@ }, } -resp = requests.post(URL, json=payload, headers=HEADERS) +resp = requests.post(URL, json=payload, headers=HEADERS, timeout=10) print(resp.json()) diff --git a/theta_test_capture.py b/theta_test_capture.py index ba4a9ba..d264817 100755 --- a/theta_test_capture.py +++ b/theta_test_capture.py @@ -42,7 +42,7 @@ def set_options(iso, shutter_speed, white_balance): } }, } - resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS) + resp = requests.post(EXECUTE_URL, json=options_command, headers=HEADERS, timeout=10) resp.raise_for_status() return resp.json() @@ -50,7 +50,7 @@ def set_options(iso, shutter_speed, white_balance): def take_picture(): """Take a picture using the Theta API""" take_command = {"name": "camera.takePicture"} - resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS) + resp = requests.post(EXECUTE_URL, json=take_command, headers=HEADERS, timeout=10) resp.raise_for_status() return resp.json() @@ -59,7 +59,7 @@ def wait_for_completion(command_id): """Wait a few seconds to complete""" while True: status_resp = requests.post( - STATUS_URL, json={"id": command_id}, headers=HEADERS + STATUS_URL, json={"id": command_id}, headers=HEADERS, timeout=10 ) status_resp.raise_for_status() status = status_resp.json()