Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if numpy_installed:
import numpy as np
if pandas_installed:
import pandas
try:
from PIL import Image
except ImportError:
import Image
IS_PYTHON_2 = version_info[:1] < (3, )
IS_PYTHON_3 = not IS_PYTHON_2
TESSERACT_VERSION = tuple(get_tesseract_version().version) # to skip tests
DATA_DIR = path.join(path.dirname(path.abspath(__file__)), 'data')
TEST_JPEG = path.join(DATA_DIR, 'test.jpg')
pytestmark = pytest.mark.pytesseract # used marker for the module
@pytest.fixture(scope='session')
def test_file():
return TEST_JPEG
@pytest.fixture(scope='session')
def test_file_european():
return path.join(DATA_DIR, 'test-european.jpg')
k: v for k, v in vars(settings).items() if k not in data["BOT_SETTINGS"] and any(char.isupper() for char in k)
})
# Retrieve the users last session (if one exists), and place that json representation
# into our dictionary as well.
session = Session.objects.all().order_by("-start")
if session.count() > 0:
data["LAST_SESSION"] = session.first().json()
# Including some miscellaneous information that can be added to
# and used to include some useful variables.
try:
data["MISCELLANEOUS"].update({
"tesseract": {
"path": settings.TESSERACT_COMMAND,
"version": pytesseract.get_tesseract_version().vstring,
}
})
except Exception:
pass
# We also include some generic data from the users information as well.
# Each instance available may contain different pieces fo information.
# --------------------------------------------------------------------
for instance in BotInstance.objects.all():
# ARTIFACTS.
data["ARTIFACTS"][instance.name] = ArtifactStatistics.objects.grab(instance=instance).json()
# STATISTICS.
data["STATISTICS"][instance.name] = Statistics.objects.grab(instance=instance).json()
for configuration in Configuration.objects.all():
data["CONFIGURATIONS"][configuration.name] = configuration.json(condense=True, hide_sensitive=True)
def extract_time(video,ocr_bool,file_bool,log):
print(pytesseract.get_tesseract_version())
threshold_error=timedelta(hours=1,minutes=0)
ocr_time_failed=False;
file_time_failed=False;
file_name_time=None;
file_name_date=None;
fps=None;
default_time=timedelta(hours=9,minutes=0)
default_date="2020-05-28"
try:
file_name_date,file_name_time=extract_date(video)
except Exception as e:
log.write("ERROR in extracting the date-time from the file_name\n")
log.write(str(e)+"\n")
file_time_failed=True;
print("")
print("Version: " + mss.__version__)
print("")
print(bcolors.BOLD + bcolors.OKGREEN + "MSS working correctly." + bcolors.ENDC)
print(
"_____________________________________________________________________________________"
)
print("")
print(bcolors.OKBLUE + "Testing Pytesseract" + bcolors.ENDC)
print("")
try:
print("pytesseract.get_tesseract_version()")
print(pytesseract.get_tesseract_version())
except (IOError, OSError) as e:
print(bcolors.FAIL + "ERROR" + bcolors.ENDC)
print(e)
else:
print("")
print(
bcolors.BOLD + bcolors.OKGREEN + "Pytesseract working correctly." + bcolors.ENDC
)
def extract_time(video,ocr_bool,file_bool,log):
print(pytesseract.get_tesseract_version())
threshold_error=timedelta(hours=1,minutes=0)
ocr_time_failed=False;
file_time_failed=False;
file_name_time=None;
file_name_date=None;
default_time=timedelta(hours=9,minutes=0)
default_date="2020-05-28"
try:
file_name_date,file_name_time=extract_date(video)
except Exception as e:
log.write("ERROR in extracting the date-time from the file_name\n")
log.write(f"{e}\n")
file_time_failed=True;
try: