acecalisto3 commited on
Commit
22247e1
Β·
1 Parent(s): da8f23d
Files changed (2) hide show
  1. app2.py +5 -2
  2. fix.sh +19 -16
app2.py CHANGED
@@ -1392,7 +1392,7 @@ def create_modern_interface():
1392
 
1393
  return viewport_html
1394
 
1395
- def process_inputs(urls, files, text, combine):
1396
  """Process all inputs and generate QR codes"""
1397
  results = []
1398
  processing_status_messages = []
@@ -1480,7 +1480,10 @@ def create_modern_interface():
1480
  def on_qr_generation(qr_paths_list):
1481
  # When QR codes are generated, update the state with the list of paths
1482
  # and initialize the enabled_qr_codes state with all indices enabled
1483
- num_qrs = len(qr_paths_list)
 
 
 
1484
  initial_enabled_states = list(range(num_qrs))
1485
  return qr_paths_list, initial_enabled_states # Return paths list and initial enabled state
1486
 
 
1392
 
1393
  return viewport_html
1394
 
1395
+ def process_inputs(urls, files, text, combine, *args):
1396
  """Process all inputs and generate QR codes"""
1397
  results = []
1398
  processing_status_messages = []
 
1480
  def on_qr_generation(qr_paths_list):
1481
  # When QR codes are generated, update the state with the list of paths
1482
  # and initialize the enabled_qr_codes state with all indices enabled
1483
+ if qr_paths_list is None:
1484
+ num_qrs=0
1485
+ else:
1486
+ num_qrs=len(qr_paths_list)
1487
  initial_enabled_states = list(range(num_qrs))
1488
  return qr_paths_list, initial_enabled_states # Return paths list and initial enabled state
1489
 
fix.sh CHANGED
@@ -1,24 +1,27 @@
1
  #!/bin/bash
 
 
2
 
3
- # Target directory where 'pyth' is installed
4
- PYTH_DIR="/usr/local/lib/python3.10/site-packages/pyth"
5
 
6
- # Check if directory exists
7
- if [ ! -d "$PYTH_DIR" ]; then
8
- echo "❌ pyth directory not found: $PYTH_DIR"
9
- exit 1
10
- fi
11
 
12
- echo "πŸ”§ Patching pyth for Python 3 compatibility..."
13
 
14
- # 1. Fix all ur"" and ur'' strings to r"" and r''
15
- find "$PYTH_DIR" -type f -name "*.py" -exec sed -i 's/ur"/r"/g' {} +
16
- find "$PYTH_DIR" -type f -name "*.py" -exec sed -i "s/ur'/r'/g" {} +
17
 
18
- # 2. Replace unicode with str
19
- find "$PYTH_DIR" -type f -name "*.py" -exec sed -i 's/\bunicode\b/str/g' {} +
 
20
 
21
- # 3. Replace iteritems() with items()
22
- find "$PYTH_DIR" -type f -name "*.py" -exec sed -i 's/\.iteritems()/\.items()/g' {} +
23
 
24
- echo "βœ… Patching completed. Now restart your app."
 
 
 
 
 
 
 
 
1
  #!/bin/bash
2
+ # Fix script for app2.py and Gradio version
3
+ # Applies only necessary surgical fixes without changing unrelated code
4
 
5
+ echo "πŸ›  Fixing 'len(None)' error on qr_paths_list in app2.py..."
 
6
 
7
+ # Patch to safely handle NoneType for qr_paths_list
8
+ sed -i 's/num_qrs = len(qr_paths_list)/if qr_paths_list is None:\n num_qrs=0\nelse:\n num_qrs=len(qr_paths_list)/' /home/user/app/app2.py
 
 
 
9
 
10
+ echo "βœ… Fixed qr_paths_list NoneType issue."
11
 
12
+ echo "πŸ›  Fixing Gradio process_inputs() TypeError..."
 
 
13
 
14
+ # Patch your process_inputs definition to accept optional args
15
+ # (Only if 'def process_inputs' exists)
16
+ sed -i '/def process_inputs(/ s/):$/, *args):/' /home/user/app/app2.py
17
 
18
+ echo "βœ… Fixed process_inputs() to tolerate extra args."
 
19
 
20
+ echo "πŸ›  Downgrading Gradio version for compatibility (~3.50)..."
21
+
22
+ # Downgrade Gradio
23
+ pip install 'gradio>=3.40,<3.60' --force-reinstall
24
+
25
+ echo "βœ… Gradio downgraded to compatible version."
26
+
27
+ echo "🎯 All fixes applied. Restart your app if needed."