From b0bdb8ce4b64003fc136581f4231f69ed2e77556 Mon Sep 17 00:00:00 2001 From: Taro Matsuzawa Date: Wed, 18 Dec 2019 16:26:49 +0900 Subject: [PATCH] WIP: for python3 --- Dockerfile | 6 +++--- clamav.py | 2 +- scan.py | 4 ++-- scripts/run-scan-lambda | 2 +- scripts/run-update-lambda | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2805b357..871a62d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,11 +12,11 @@ COPY requirements.txt /opt/app/requirements.txt # Install packages RUN yum update -y -RUN yum install -y cpio python2-pip yum-utils zip unzip less +RUN yum install -y cpio python3-pip yum-utils zip unzip less RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # This had --no-cache-dir, tracing through multiple tickets led to a problem in wheel -RUN pip install -r requirements.txt +RUN pip3 install -r requirements.txt RUN rm -rf /root/.cache/pip # Download libraries we need to run in lambda @@ -39,7 +39,7 @@ RUN echo "CompressLocalDatabase yes" >> /opt/app/bin/freshclam.conf WORKDIR /opt/app RUN zip -r9 --exclude="*test*" /opt/app/build/lambda.zip *.py bin -WORKDIR /usr/lib/python2.7/site-packages +WORKDIR /usr/lib/python3.7/site-packages RUN zip -r9 /opt/app/build/lambda.zip * WORKDIR /opt/app diff --git a/clamav.py b/clamav.py index ea83b62a..73fbe16e 100644 --- a/clamav.py +++ b/clamav.py @@ -42,7 +42,7 @@ def current_library_search_path(): - ld_verbose = subprocess.check_output(["ld", "--verbose"]) + ld_verbose = subprocess.check_output(["ld", "--verbose"]).decode('utf-8') rd_ld = re.compile(RE_SEARCH_DIR) return rd_ld.findall(ld_verbose) diff --git a/scan.py b/scan.py index de505b76..c55716d4 100644 --- a/scan.py +++ b/scan.py @@ -16,7 +16,7 @@ import copy import json import os -import urllib +from urllib.parse import unquote_plus from distutils.util import strtobool import boto3 @@ -66,7 +66,7 @@ def event_object(event, event_source="s3"): key_name = s3_obj["object"].get("key", None) if key_name: - key_name = urllib.unquote_plus(key_name.encode("utf8")) + key_name = unquote_plus(key_name) # Ensure both bucket and key exist if (not bucket_name) or (not key_name): diff --git a/scripts/run-scan-lambda b/scripts/run-scan-lambda index 2d6f21b0..c70e1e41 100755 --- a/scripts/run-scan-lambda +++ b/scripts/run-scan-lambda @@ -49,4 +49,4 @@ docker run --rm \ --memory-swap="${MEM}" \ --cpus="${CPUS}" \ --name="${NAME}" \ - lambci/lambda:python2.7 scan.lambda_handler "${EVENT}" + lambci/lambda:python3.7 scan.lambda_handler "${EVENT}" diff --git a/scripts/run-update-lambda b/scripts/run-update-lambda index 66706a89..3d24defa 100755 --- a/scripts/run-update-lambda +++ b/scripts/run-update-lambda @@ -26,4 +26,4 @@ docker run --rm \ --memory-swap="${MEM}" \ --cpus="${CPUS}" \ --name="${NAME}" \ - lambci/lambda:python2.7 update.lambda_handler + lambci/lambda:python3.7 update.lambda_handler