Spaces:
Sleeping
Sleeping
Update turbowarp-server/qr-converter.py
Browse files
turbowarp-server/qr-converter.py
CHANGED
|
@@ -18,7 +18,20 @@ print("[INFO] Connected successfully.")
|
|
| 18 |
def get_var(name):
|
| 19 |
try:
|
| 20 |
value = tw.get_variable(name=name, name_literal=False)
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
return value
|
| 23 |
except Exception as e:
|
| 24 |
print(f"[ERROR] Failed to get variable '{name}': {e}")
|
|
|
|
| 18 |
def get_var(name):
|
| 19 |
try:
|
| 20 |
value = tw.get_variable(name=name, name_literal=False)
|
| 21 |
+
|
| 22 |
+
# 様々な型を文字列に変換
|
| 23 |
+
if value is None:
|
| 24 |
+
return None
|
| 25 |
+
elif isinstance(value, (int, float)):
|
| 26 |
+
value = str(int(value)) # 浮動小数点の場合は整数に変換してから文字列に
|
| 27 |
+
print(f"[GET] Variable '{name}' converted from number to string")
|
| 28 |
+
elif not isinstance(value, str):
|
| 29 |
+
value = str(value)
|
| 30 |
+
print(f"[GET] Variable '{name}' converted from {type(value).__name__} to string")
|
| 31 |
+
|
| 32 |
+
# 表示用に切り詰め
|
| 33 |
+
display_value = value[:50] + "..." if len(value) > 50 else value
|
| 34 |
+
print(f"[GET] Variable '{name}' = {display_value}")
|
| 35 |
return value
|
| 36 |
except Exception as e:
|
| 37 |
print(f"[ERROR] Failed to get variable '{name}': {e}")
|