Skip to content

Commit

Permalink
環境変数チェック
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Mar 20, 2024
1 parent b61e6bc commit df5d96e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
8 changes: 6 additions & 2 deletions examples/src/media/recvonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ def recvonly():
load_dotenv()

# 必須引数
signaling_urls = os.getenv("SORA_SIGNALING_URLS").split(",")
channel_id = os.getenv("SORA_CHANNEL_ID")
if not (raw_signaling_urls := os.getenv("SORA_SIGNALING_URLS")):
raise ValueError("環境変数 SORA_SIGNALING_URLS が設定されていません")
signaling_urls = raw_signaling_urls.split(",")

if not (channel_id := os.getenv("SORA_CHANNEL_ID")):
raise ValueError("環境変数 SORA_CHANNEL_ID が設定されていません")

# オプション引数
metadata = None
Expand Down
12 changes: 8 additions & 4 deletions examples/src/media/sendonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sora_sdk import Sora, SoraConnection, SoraSignalingErrorCode


class SendOnly:
class Sendonly:
def __init__(
self,
# python 3.8 まで対応なので list[str] ではなく List[str] にする
Expand Down Expand Up @@ -125,8 +125,12 @@ def sendonly():
load_dotenv()

# 必須引数
signaling_urls = os.getenv("SORA_SIGNALING_URLS").split(",")
channel_id = os.getenv("SORA_CHANNEL_ID")
if not (raw_signaling_urls := os.getenv("SORA_SIGNALING_URLS")):
raise ValueError("環境変数 SORA_SIGNALING_URLS が設定されていません")
signaling_urls = raw_signaling_urls.split(",")

if not (channel_id := os.getenv("SORA_CHANNEL_ID")):
raise ValueError("環境変数 SORA_CHANNEL_ID が設定されていません")

# オプション引数
metadata = None
Expand All @@ -142,7 +146,7 @@ def sendonly():

openh264_path = os.getenv("OPENH264_PATH")

sendonly = SendOnly(
sendonly = Sendonly(
signaling_urls,
channel_id,
metadata,
Expand Down
12 changes: 9 additions & 3 deletions examples/src/messaging/recvonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ def recvonly():
load_dotenv()

# 必須引数
signaling_urls = os.getenv("SORA_SIGNALING_URLS").split(",")
channel_id = os.getenv("SORA_CHANNEL_ID")
messaging_label = os.getenv("SORA_MESSAGING_LABEL")
if not (raw_signaling_urls := os.getenv("SORA_SIGNALING_URLS")):
raise ValueError("環境変数 SORA_SIGNALING_URLS が設定されていません")
signaling_urls = raw_signaling_urls.split(",")

if not (channel_id := os.getenv("SORA_CHANNEL_ID")):
raise ValueError("環境変数 SORA_CHANNEL_ID が設定されていません")

if not (messaging_label := os.getenv("SORA_MESSAGING_LABEL")):
raise ValueError("環境変数 SORA_MESSAGING_LABEL が設定されていません")

# オプション引数
metadata = None
Expand Down
12 changes: 9 additions & 3 deletions examples/src/messaging/sendonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ def sendonly():
load_dotenv()

# 必須引数
signaling_urls = os.getenv("SORA_SIGNALING_URLS").split(",")
channel_id = os.getenv("SORA_CHANNEL_ID")
messaging_label = os.getenv("SORA_MESSAGING_LABEL", "#example")
if not (raw_signaling_urls := os.getenv("SORA_SIGNALING_URLS")):
raise ValueError("環境変数 SORA_SIGNALING_URLS が設定されていません")
signaling_urls = raw_signaling_urls.split(",")

if not (channel_id := os.getenv("SORA_CHANNEL_ID")):
raise ValueError("環境変数 SORA_CHANNEL_ID が設定されていません")

if not (messaging_label := os.getenv("SORA_MESSAGING_LABEL")):
raise ValueError("環境変数 SORA_MESSAGING_LABEL が設定されていません")

# オプション引数
metadata = None
Expand Down
12 changes: 9 additions & 3 deletions examples/src/messaging/sendrecv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ def sendrecv():
load_dotenv()

# 必須引数
signaling_urls = os.getenv("SORA_SIGNALING_URLS").split(",")
channel_id = os.getenv("SORA_CHANNEL_ID")
messaging_label = os.getenv("SORA_MESSAGING_LABEL")
if not (raw_signaling_urls := os.getenv("SORA_SIGNALING_URLS")):
raise ValueError("環境変数 SORA_SIGNALING_URLS が設定されていません")
signaling_urls = raw_signaling_urls.split(",")

if not (channel_id := os.getenv("SORA_CHANNEL_ID")):
raise ValueError("環境変数 SORA_CHANNEL_ID が設定されていません")

if not (messaging_label := os.getenv("SORA_MESSAGING_LABEL")):
raise ValueError("環境変数 SORA_MESSAGING_LABEL が設定されていません")

# オプション引数
metadata = None
Expand Down

0 comments on commit df5d96e

Please sign in to comment.