THEZYZSTUDIO commited on
Commit
3fc9631
ยท
verified ยท
1 Parent(s): c64056e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -102,6 +102,15 @@ async def _start_session_browser(disp: str) -> "subprocess.Popen | None":
102
 
103
  def _spawn():
104
  try:
 
 
 
 
 
 
 
 
 
105
  return subprocess.Popen(
106
  [BROWSER, "--new-window", "--no-remote", "about:blank"],
107
  env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
@@ -1100,6 +1109,20 @@ async def handle_action(ws: WebSocket, msg: dict):
1100
  if esr_check.returncode != 0:
1101
  fixed_cmd = app_cmd.replace("firefox-esr", BROWSER)
1102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1103
  subprocess.Popen(fixed_cmd, shell=True,
1104
  env={**os.environ, "DISPLAY": DISPLAY_OF()},
1105
  stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
102
 
103
  def _spawn():
104
  try:
105
+ # ุญุฐู ู…ู„ูุงุช ู‚ูู„ Firefox ุงู„ู…ุชุจู‚ูŠุฉ ุฃูˆู„ุงู‹ (ุญุชู‰ ู„ูˆ ูƒู„ ุฌู„ุณุฉ ุนู„ู‰ display ู…ู†ูุตู„ุŒ
106
+ # ุงู„ู€ profile ุนู„ู‰ ุงู„ู‚ุฑุต ู‚ุฏ ูŠูƒูˆู† ู…ุดุชุฑูŽูƒุงู‹ ูˆูŠุญู…ู„ ู‚ูู„ุงู‹ ู…ู† ุฌู„ุณุฉ ุณุงุจู‚ุฉ ู„ู… ุชูุบู„ู‚ ู†ุธูŠูุงู‹)
107
+ try:
108
+ subprocess.run(
109
+ "rm -f ~/.mozilla/firefox/*/lock ~/.mozilla/firefox/*/.parentlock 2>/dev/null",
110
+ shell=True, executable="/bin/bash", timeout=3, capture_output=True
111
+ )
112
+ except Exception:
113
+ pass
114
  return subprocess.Popen(
115
  [BROWSER, "--new-window", "--no-remote", "about:blank"],
116
  env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
 
1109
  if esr_check.returncode != 0:
1110
  fixed_cmd = app_cmd.replace("firefox-esr", BROWSER)
1111
 
1112
+ # โ”€โ”€ ุญู…ุงูŠุฉ ุฅุถุงููŠุฉ: ุญุฐู ู…ู„ูุงุช ู‚ูู„ Firefox ุงู„ู…ุชุจู‚ูŠุฉ ู‚ุจู„ ูุชุญ ู†ุงูุฐุฉ ุฌุฏูŠุฏุฉ โ”€โ”€
1113
+ # ูŠู…ู†ุน ุธู‡ูˆุฑ "Firefox is already running, but is not responding" ุญุชู‰ ู„ูˆ
1114
+ # ู†ุณูŠ ุงู„ุฐูƒุงุก ุชุถู…ูŠู† ู‡ุฐุง ุงู„ุชู†ุธูŠู ููŠ ุฃู…ุฑู‡ ุงู„ุฎุงุต.
1115
+ if any(b in fixed_cmd for b in ("firefox", "Firefox")):
1116
+ def _clean_lock():
1117
+ try:
1118
+ subprocess.run(
1119
+ "rm -f ~/.mozilla/firefox/*/lock ~/.mozilla/firefox/*/.parentlock 2>/dev/null",
1120
+ shell=True, executable="/bin/bash", timeout=3, capture_output=True
1121
+ )
1122
+ except Exception:
1123
+ pass
1124
+ await asyncio.to_thread(_clean_lock)
1125
+
1126
  subprocess.Popen(fixed_cmd, shell=True,
1127
  env={**os.environ, "DISPLAY": DISPLAY_OF()},
1128
  stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)