testdeep123 commited on
Commit
c362865
·
verified ·
1 Parent(s): 1ac7903

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -667,6 +667,30 @@ def add_background_music(final_video, bg_music_volume=0.10):
667
 
668
 
669
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
 
671
 
672
 
@@ -800,6 +824,7 @@ def generate_video(user_input, resolution, caption_option):
800
 
801
  # Fix ImageMagick policy
802
  fix_success = fix_imagemagick_policy()
 
803
  if not fix_success:
804
  print("Will use alternative methods if needed")
805
 
 
667
 
668
 
669
 
670
+ def fix_imagemagick_policy():
671
+ """Fix ImageMagick security policies."""
672
+ try:
673
+ print("Attempting to fix ImageMagick security policies...")
674
+ policy_paths = [
675
+ "/etc/ImageMagick-6/policy.xml",
676
+ "/etc/ImageMagick-7/policy.xml",
677
+ "/etc/ImageMagick/policy.xml",
678
+ "/usr/local/etc/ImageMagick-7/policy.xml"
679
+ ]
680
+ found_policy = next((path for path in policy_paths if os.path.exists(path)), None)
681
+ if not found_policy:
682
+ print("No policy.xml found. Using alternative subtitle method.")
683
+ return False
684
+ print(f"Modifying policy file at {found_policy}")
685
+ os.system(f"sudo cp {found_policy} {found_policy}.bak")
686
+ os.system(f"sudo sed -i 's/rights=\"none\"/rights=\"read|write\"/g' {found_policy}")
687
+ os.system(f"sudo sed -i 's/<policy domain=\"path\" pattern=\"@\*\"[^>]*>/<policy domain=\"path\" pattern=\"@*\" rights=\"read|write\"/g' {found_policy}")
688
+ os.system(f"sudo sed -i 's/<policy domain=\"coder\" rights=\"none\" pattern=\"PDF\"[^>]*>/<!-- <policy domain=\"coder\" rights=\"none\" pattern=\"PDF\"> -->/g' {found_policy}")
689
+ print("ImageMagick policies updated successfully.")
690
+ return True
691
+ except Exception as e:
692
+ print(f"Error fixing policies: {e}")
693
+ return False
694
 
695
 
696
 
 
824
 
825
  # Fix ImageMagick policy
826
  fix_success = fix_imagemagick_policy()
827
+
828
  if not fix_success:
829
  print("Will use alternative methods if needed")
830