jin2li commited on
Commit
8e1ceec
ยท
verified ยท
1 Parent(s): 6a09bfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -849,6 +849,48 @@ def mfds_lookup_one_term_with_retry(page, term):
849
  return [], last_error[:300]
850
 
851
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
852
  def mfds_live_lookup_terms(terms, max_terms=30, headless=True):
853
  if not PLAYWRIGHT_AVAILABLE or sync_playwright is None:
854
  return pd.DataFrame(), "MFDS ์‹ค์‹œ๊ฐ„ ์กฐํšŒ ์‹คํŒจ: playwright ํŒจํ‚ค์ง€ ๋ฏธ์„ค์น˜"
 
849
  return [], last_error[:300]
850
 
851
 
852
+
853
+
854
+ def mfds_launch_chromium(playwright_obj):
855
+ """
856
+ Playwright Chromium ๋ธŒ๋ผ์šฐ์ € ์‹คํ–‰ ํ•จ์ˆ˜.
857
+ ์ผ๋ถ€ ๋ณ‘ํ•ฉ ๊ณผ์ •์—์„œ ๋ˆ„๋ฝ๋˜๋ฉด MFDS ์กฐํšŒ ์‹œ name error๊ฐ€ ๋ฐœ์ƒํ•˜๋ฏ€๋กœ ๋ณ„๋„ ํ•จ์ˆ˜๋กœ ๋ณด์žฅํ•œ๋‹ค.
858
+ """
859
+ return playwright_obj.chromium.launch(
860
+ headless=True,
861
+ args=[
862
+ "--no-sandbox",
863
+ "--disable-setuid-sandbox",
864
+ "--disable-dev-shm-usage",
865
+ "--disable-gpu",
866
+ "--disable-software-rasterizer",
867
+ ],
868
+ )
869
+
870
+
871
+ def mfds_try_install_chromium_once():
872
+ """
873
+ postBuild๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์€ ํ™˜๊ฒฝ์—์„œ Chromium์ด ์—†์„ ๋•Œ 1ํšŒ ์„ค์น˜๋ฅผ ์‹œ๋„ํ•œ๋‹ค.
874
+ ์‹คํŒจํ•˜๋”๋ผ๋„ ์•ฑ ์ „์ฒด๋Š” ์ฃฝ์ง€ ์•Š๊ณ  ๊ตญ๊ฐ€๋ณ„ ํŒŒ์ผ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋Š” ๊ณ„์† ํ‘œ์‹œํ•œ๋‹ค.
875
+ """
876
+ try:
877
+ proc = subprocess.run(
878
+ [sys.executable, "-m", "playwright", "install", "chromium"],
879
+ stdout=subprocess.PIPE,
880
+ stderr=subprocess.PIPE,
881
+ text=True,
882
+ timeout=180,
883
+ )
884
+
885
+ if proc.returncode == 0:
886
+ return True, "Chromium ๋Ÿฐํƒ€์ž„ ์„ค์น˜ ์™„๋ฃŒ"
887
+
888
+ msg = (proc.stderr or proc.stdout or "").strip()
889
+ return False, msg[:500]
890
+ except Exception as e:
891
+ return False, str(e)
892
+
893
+
894
  def mfds_live_lookup_terms(terms, max_terms=30, headless=True):
895
  if not PLAYWRIGHT_AVAILABLE or sync_playwright is None:
896
  return pd.DataFrame(), "MFDS ์‹ค์‹œ๊ฐ„ ์กฐํšŒ ์‹คํŒจ: playwright ํŒจํ‚ค์ง€ ๋ฏธ์„ค์น˜"