izuemon commited on
Commit
3420216
·
verified ·
1 Parent(s): 8931145

Update turbowarp-server/qr-converter.py

Browse files
Files changed (1) hide show
  1. turbowarp-server/qr-converter.py +11 -11
turbowarp-server/qr-converter.py CHANGED
@@ -20,24 +20,24 @@ def get_var(name):
20
  value = tw.get_variable(name=name, name_literal=False)
21
 
22
  # デバッグ用に生の値を出力
23
- print(f"[DEBUG] Raw value of '{name}': {value} (type: {type(value).__name__})")
24
 
25
  # Noneの場合は"0"として扱う
26
  if value is None:
27
- print(f"[WARNING] Variable '{name}' is None, treating as '0'")
28
  return "0"
29
 
30
  # 様々な型を文字列に変換
31
  if isinstance(value, (int, float)):
32
  value = str(int(value))
33
- print(f"[GET] Variable '{name}' converted from number to string: '{value}'")
34
  elif not isinstance(value, str):
35
  value = str(value)
36
- print(f"[GET] Variable '{name}' converted from {type(value).__name__} to string: '{value}'")
37
 
38
  # 表示用に切り詰め
39
  display_value = value[:50] + "..." if len(value) > 50 else value
40
- print(f"[GET] Variable '{name}' = '{display_value}'")
41
  return value
42
  except Exception as e:
43
  print(f"[ERROR] Failed to get variable '{name}': {e}")
@@ -123,7 +123,7 @@ def generate_image(prompt):
123
  def resize_and_encode(img):
124
  """90x90にリサイズして6桁の数字列に変換(各ピクセル6桁)"""
125
  img = img.resize((90, 90))
126
- print("[INFO] Resized image to 90x90.")
127
 
128
  encoded = ""
129
  total_pixels = 0
@@ -140,7 +140,7 @@ def resize_and_encode(img):
140
  total_pixels += 1
141
 
142
  expected_length = total_pixels * 6
143
- print(f"[INFO] Encoded {total_pixels} pixels to string of length {len(encoded)} (expected: {expected_length})")
144
  return encoded
145
 
146
  def split_packets(data, max_length=9998):
@@ -173,10 +173,10 @@ while True:
173
  n1 = get_var("n1")
174
  n0 = get_var("n0")
175
 
176
- print(f"[DEBUG] n0='{n0}', n1='{n1[:30]}...' if n1 and len(n1)>30 else n1")
177
 
178
  is_n0_free = (n0 == "0")
179
- print(f"[DEBUG] is_n0_free: {is_n0_free}")
180
 
181
  if n1 and len(n1) >= 3 and n1[0] == "0":
182
  user_id = n1[1:3]
@@ -266,10 +266,10 @@ while True:
266
  print(f"[INFO] Set last_processed_id")
267
 
268
  else:
269
- print("[INFO] n0 is busy, waiting...")
270
  else:
271
  if n1:
272
- print(f"[DEBUG] n1 condition not met: first char='{n1[0] if n1 else 'None'}', length={len(n1) if n1 else 0}")
273
  else:
274
  print("[DEBUG] n1 is None or empty")
275
 
 
20
  value = tw.get_variable(name=name, name_literal=False)
21
 
22
  # デバッグ用に生の値を出力
23
+ #print(f"[DEBUG] Raw value of '{name}': {value} (type: {type(value).__name__})")
24
 
25
  # Noneの場合は"0"として扱う
26
  if value is None:
27
+ #print(f"[WARNING] Variable '{name}' is None, treating as '0'")
28
  return "0"
29
 
30
  # 様々な型を文字列に変換
31
  if isinstance(value, (int, float)):
32
  value = str(int(value))
33
+ #print(f"[GET] Variable '{name}' converted from number to string: '{value}'")
34
  elif not isinstance(value, str):
35
  value = str(value)
36
+ #print(f"[GET] Variable '{name}' converted from {type(value).__name__} to string: '{value}'")
37
 
38
  # 表示用に切り詰め
39
  display_value = value[:50] + "..." if len(value) > 50 else value
40
+ #print(f"[GET] Variable '{name}' = '{display_value}'")
41
  return value
42
  except Exception as e:
43
  print(f"[ERROR] Failed to get variable '{name}': {e}")
 
123
  def resize_and_encode(img):
124
  """90x90にリサイズして6桁の数字列に変換(各ピクセル6桁)"""
125
  img = img.resize((90, 90))
126
+ #print("[INFO] Resized image to 90x90.")
127
 
128
  encoded = ""
129
  total_pixels = 0
 
140
  total_pixels += 1
141
 
142
  expected_length = total_pixels * 6
143
+ #print(f"[INFO] Encoded {total_pixels} pixels to string of length {len(encoded)} (expected: {expected_length})")
144
  return encoded
145
 
146
  def split_packets(data, max_length=9998):
 
173
  n1 = get_var("n1")
174
  n0 = get_var("n0")
175
 
176
+ #print(f"[DEBUG] n0='{n0}', n1='{n1[:30]}...' if n1 and len(n1)>30 else n1")
177
 
178
  is_n0_free = (n0 == "0")
179
+ #print(f"[DEBUG] is_n0_free: {is_n0_free}")
180
 
181
  if n1 and len(n1) >= 3 and n1[0] == "0":
182
  user_id = n1[1:3]
 
266
  print(f"[INFO] Set last_processed_id")
267
 
268
  else:
269
+ #print("[INFO] n0 is busy, waiting...")
270
  else:
271
  if n1:
272
+ #print(f"[DEBUG] n1 condition not met: first char='{n1[0] if n1 else 'None'}', length={len(n1) if n1 else 0}")
273
  else:
274
  print("[DEBUG] n1 is None or empty")
275