diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d902845 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,37 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.10, ... +ARG VARIANT=3 +FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131 + && apt-get purge -y imagemagick imagemagick-6-common \ + # Install common packages, non-root user + # && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ + # Clean up + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + +# [Option] Install Node.js +# ARG INSTALL_NODE="false" +# ARG NODE_VERSION="lts/*" +# RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Allow the vscode user to pip install globally w/o sudo +# ENV PIP_TARGET=/usr/local/pip-global +# ENV PYTHONPATH=${PIP_TARGET}:${PYTHONPATH} +# ENV PATH=${PIP_TARGET}/bin:${PATH} +# RUN mkdir -p ${PIP_TARGET} \ +# && chown vscode:root ${PIP_TARGET} \ +# && echo "if [ \"\$(stat -c '%U' ${PIP_TARGET})\" != \"vscode\" ]; then chown -R vscode:root ${PIP_TARGET}; fi" \ +# | tee -a /root/.bashrc /home/vscode/.bashrc /root/.zshrc >> /home/vscode/.zshrc + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update \ +# && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..ef364a3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// Docu: https://containers.dev/implementors/json_reference/ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + //Update 'VARIANT' to pick a Python version: 3, 3.10, ... + "args": { + "VARIANT": "3.10" + } + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python" + ], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": + "python -m pip install --upgrade pip; pip install -r requirements-dev.txt; pip install -r requirements.txt", + "postStartCommand": "echo 'Happy coding'" + // Comment out to connect as root instead. + // "remoteUser": "vscode" +} diff --git a/.gitignore b/.gitignore index 8fa074b..c7b37bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,15 @@ -generated_python/__pycache__/ +__pycache__/ qr/ venv/ -*.csv -*.json +/*.csv +/*.json !devbox.json !example_output.json !example_output.csv !.github/ !.flake8 +.vscode !.vscode/settings.json +!.devcontainer/ +!.devcontainer/*.json diff --git a/README.md b/README.md index aeac0bd..8b404e5 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,26 @@ pipenv shell python extract_otp_secret_keys.py example_export.txt ``` +### Visual Studio Code Remote - Containers / VSCode devcontainer + +You can you use [VSCode devcontainer](https://code.visualstudio.com/docs/remote/containers-tutorial) for running extract_otp_secret_keys. + +Requirement: Docker + +1. Start VSCode +2. Open extract_otp_secret_keys.code-workspace +3. Open VSCode command palette (Ctrl-Shift-P) +4. Type command "Remote-Containers: Reopen in Container" +5. Open integrated bash terminal in VSCode +6. Execute: python extract_otp_secret_keys.py example_export.txt + ### venv Alternatively, you can use a python virtual env for the dependencies: python -m venv venv . venv/bin/activate - pip install -r requirements-buildenv.txt + pip install -r requirements-dev.txt pip install -r requirements.txt The requirements\*.txt files contain all the dependencies (also the optional ones). diff --git a/extract_otp_secret_keys.code-workspace b/extract_otp_secret_keys.code-workspace new file mode 100644 index 0000000..362d7c2 --- /dev/null +++ b/extract_otp_secret_keys.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "." + } + ] +} \ No newline at end of file diff --git a/requirements-buildenv.txt b/requirements-buildenv.txt deleted file mode 100644 index 2309722..0000000 --- a/requirements-buildenv.txt +++ /dev/null @@ -1 +0,0 @@ -wheel diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..8202127 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +wheel +pytest +flake8 +pylint