Skip to content

Commit 9237c6a

Browse files
committed
Install missing optional dependencies as needed
1 parent b35e678 commit 9237c6a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

seleniumbase/core/s3_manager.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Methods for uploading/managing files on Amazon S3.
33
"""
44
from seleniumbase.config import settings
5+
from seleniumbase.fixtures import shared_utils
56

67
already_uploaded_files = []
78

@@ -19,15 +20,23 @@ def __init__(
1920
selenium_access_key=settings.S3_SELENIUM_ACCESS_KEY,
2021
selenium_secret_key=settings.S3_SELENIUM_SECRET_KEY,
2122
):
22-
from boto.s3.connection import S3Connection
23+
try:
24+
from boto.s3.connection import S3Connection
25+
except Exception:
26+
shared_utils.pip_install("boto", version="2.49.0")
27+
from boto.s3.connection import S3Connection
2328

2429
self.conn = S3Connection(selenium_access_key, selenium_secret_key)
2530
self.bucket = self.conn.get_bucket(log_bucket)
2631
self.bucket_url = bucket_url
2732

2833
def get_key(self, file_name):
2934
"""Create a new Key instance with the given name."""
30-
from boto.s3.key import Key
35+
try:
36+
from boto.s3.key import Key
37+
except Exception:
38+
shared_utils.pip_install("boto", version="2.49.0")
39+
from boto.s3.key import Key
3140

3241
return Key(bucket=self.bucket, name=file_name)
3342

seleniumbase/fixtures/base_case.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5498,7 +5498,12 @@ def get_pdf_text(
54985498

54995499
with warnings.catch_warnings():
55005500
warnings.simplefilter("ignore", category=UserWarning)
5501-
from pdfminer.high_level import extract_text
5501+
try:
5502+
from pdfminer.high_level import extract_text
5503+
except Exception:
5504+
shared_utils.pip_install("pdfminer.six")
5505+
from pdfminer.high_level import extract_text
5506+
55025507
if not password:
55035508
password = ""
55045509
if not maxpages:
@@ -5723,7 +5728,11 @@ def save_element_as_image_file(
57235728
file.write(element_png)
57245729
# Add a text overlay if given
57255730
if type(overlay_text) is str and len(overlay_text) > 0:
5726-
from PIL import Image, ImageDraw
5731+
try:
5732+
from PIL import Image, ImageDraw
5733+
except Exception:
5734+
shared_utils.pip_install("Pillow")
5735+
from PIL import Image, ImageDraw
57275736

57285737
text_rows = overlay_text.split("\n")
57295738
len_text_rows = len(text_rows)

0 commit comments

Comments
 (0)