diff --git a/.gitpod.dockerfile b/.gitpod.dockerfile
index 080523b..cb70866 100644
--- a/.gitpod.dockerfile
+++ b/.gitpod.dockerfile
@@ -1,4 +1,4 @@
-FROM gitpod/workspace-base:latest
+FROM gitpod/workspace-base
RUN echo "CI version from base"
@@ -9,6 +9,7 @@ ENV TRIGGER_REBUILD=1
RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | PROFILE=/dev/null bash \
&& bash -c ". .nvm/nvm.sh \
&& nvm install $NODE_VERSION \
+ && nvm use $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& npm install -g typescript yarn node-gyp" \
&& echo ". ~/.nvm/nvm.sh" >> /home/gitpod/.bashrc.d/50-node
@@ -17,6 +18,7 @@ ENV PATH=$PATH:/home/gitpod/.nvm/versions/node/v${NODE_VERSION}/bin
### Python ###
USER gitpod
RUN sudo install-packages python3-pip
+ENV PYTHON_VERSION 3.12.2
ENV PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH
RUN curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
@@ -24,8 +26,8 @@ RUN curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-ins
echo 'eval "$(pyenv init -)"'; \
echo 'eval "$(pyenv virtualenv-init -)"'; } >> /home/gitpod/.bashrc.d/60-python \
&& pyenv update \
- && pyenv install 3.8.11 \
- && pyenv global 3.8.11 \
+ && pyenv install $PYTHON_VERSION \
+ && pyenv global $PYTHON_VERSION \
&& python3 -m pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir --upgrade \
setuptools wheel virtualenv pipenv pylint rope flake8 \
@@ -36,10 +38,13 @@ ENV PYTHONUSERBASE=/workspace/.pip-modules \
PIP_USER=yes
ENV PATH=$PYTHONUSERBASE/bin:$PATH
-
# Setup Heroku CLI
RUN curl https://cli-assets.heroku.com/install.sh | sh
+RUN wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb && sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb && \
+ sudo rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* /home/gitpod/*.deb && \
+ sudo chown -R gitpod:gitpod /home/gitpod/.cache/heroku/
+
# Setup PostgreSQL
RUN sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list' && \
@@ -55,21 +60,25 @@ RUN mkdir -p ~/.pg_ctl/bin ~/.pg_ctl/sockets \
&& chmod +x ~/.pg_ctl/bin/*
# ENV DATABASE_URL="postgresql://gitpod@localhost"
-ENV PGHOSTADDR="127.0.0.1"
+# ENV PGHOSTADDR="127.0.0.1"
ENV PGDATABASE="postgres"
ENV PATH="/usr/lib/postgresql/12/bin:/home/gitpod/.nvm/versions/node/v${NODE_VERSION}/bin:$HOME/.pg_ctl/bin:$PATH"
-# Create our own config files
# Add aliases
-RUN echo 'alias heroku_config=". $GITPOD_REPO_ROOT/.vscode/heroku_config.sh"' >> ~/.bashrc && \
+RUN echo 'alias run="python3 $GITPOD_REPO_ROOT/manage.py runserver 0.0.0.0:8000"' >> ~/.bashrc && \
+ echo 'alias heroku_config=". $GITPOD_REPO_ROOT/.vscode/heroku_config.sh"' >> ~/.bashrc && \
echo 'alias python=python3' >> ~/.bashrc && \
echo 'alias pip=pip3' >> ~/.bashrc && \
- echo 'alias font_fix="python3 $GITPOD_REPO_ROOT/.vscode/font_fix.py"' >> ~/.bashrc
+ echo 'alias arctictern="python3 $GITPOD_REPO_ROOT/.vscode/arctictern.py"' >> ~/.bashrc && \
+ echo 'alias font_fix="python3 $GITPOD_REPO_ROOT/.vscode/font_fix.py"' >> ~/.bashrc && \
+ echo 'alias set_pg="export PGHOSTADDR=127.0.0.1"' >> ~/.bashrc && \
+ echo 'alias make_url="python3 $GITPOD_REPO_ROOT/.vscode/make_url.py "' >> ~/.bashrc
# Local environment variables
-
ENV PORT="8080"
ENV IP="0.0.0.0"
+
+
diff --git a/.gitpod.yml b/.gitpod.yml
index 7632030..39778f8 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -1,9 +1,9 @@
image:
file: .gitpod.dockerfile
tasks:
- - init: . ${GITPOD_REPO_ROOT}/.vscode/init_tasks.sh
- command: /home/gitpod/.pg_ctl/bin/pg_start > /dev/null
- - command: . ${GITPOD_REPO_ROOT}/.vscode/uptime.sh &
+ - init: . ${GITPOD_REPO_ROOT}/.vscode/init_tasks.sh
+ command: /home/gitpod/.pg_ctl/bin/pg_start > /dev/null
+ - command: . ${GITPOD_REPO_ROOT}/.vscode/uptime.sh &
vscode:
extensions:
- ms-python.python
@@ -11,3 +11,4 @@ vscode:
- eventyret.bootstrap-4-cdn-snippet
- hookyqr.beautify
- matt-rudge.auto-open-preview-panel
+
diff --git a/.vscode/arctictern.py b/.vscode/arctictern.py
new file mode 100644
index 0000000..bd164ce
--- /dev/null
+++ b/.vscode/arctictern.py
@@ -0,0 +1,186 @@
+"""
+arctictern.py
+A little script that does a big migration
+"""
+
+import json
+import os
+import requests
+import shutil
+import subprocess
+import sys
+from os.path import exists
+
+COLOURS = {"red": "\033[31m",
+ "blue": "\033[34m",
+ "green": "\033[32m",
+ "reset": "\033[0m",
+ "bold": "\033[1m"}
+
+BASE_URL = "https://raw.githubusercontent.com/Code-Institute-Org/gitpod-full-template/main/"
+CURRENT_VERSION = 1.0
+THIS_VERSION = 1.0
+
+
+UPGRADE_FILE_LIST = [{"filename": ".vscode/settings.json",
+ "url": ".vscode/settings.json"
+ },
+ {"filename": ".vscode/launch.json",
+ "url": ".vscode/launch.json"
+ },
+ {"filename": ".gitpod.yml",
+ "url": ".gitpod.yml"
+ },
+ {"filename": ".gitpod.dockerfile",
+ "url": ".gitpod.dockerfile"
+ },
+ {"filename": ".vscode/heroku_config.sh",
+ "url": ".vscode/heroku_config.sh"
+ },
+ {"filename": ".vscode/init_tasks.sh",
+ "url": ".vscode/init_tasks.sh"
+ },
+ {"filename": ".vscode/uptime.sh",
+ "url": ".vscode/uptime.sh"
+ },
+ {"filename": ".vscode/make_url.py",
+ "url": ".vscode/make_url.py"
+ },
+ {"filename": ".vscode/arctictern.py",
+ "url": ".vscode/arctictern.py"
+ }]
+
+FINAL_LINES = "\nexport POST_UPGRADE_RUN=1\nsource ~/.bashrc\n"
+
+
+def get_versions():
+
+ if exists(".vscode/version.txt"):
+ with open(".vscode/version.txt", "r") as f:
+ THIS_VERSION = float(f.read().strip())
+ else:
+ with open(".vscode/version.txt", "w") as f:
+ f.write(str(THIS_VERSION))
+
+ r = requests.get(BASE_URL + ".vscode/version.txt")
+ CURRENT_VERSION = float(r.content)
+
+ return {"this_version": THIS_VERSION,
+ "current_version": CURRENT_VERSION}
+
+def needs_upgrade():
+ """
+ Checks the version of the current template against
+ this version.
+ Returns True if upgrade is needed, False if not.
+ """
+
+ versions = get_versions()
+
+ print(f"Upstream version: {versions['current_version']}")
+ print(f"Local version: {versions['this_version']}")
+
+ return versions["current_version"] > versions["this_version"]
+
+
+def write_version():
+
+ versions = get_versions()
+
+ with open(".vscode/version.txt", "w") as f:
+ f.write(str(versions["current_version"]))
+
+
+def build_post_upgrade():
+
+ r = requests.get(BASE_URL + ".vscode/upgrades.json")
+ upgrades = json.loads(r.content.decode("utf-8"))
+ content = ""
+
+ for k,v in upgrades.items():
+ if float(k) > THIS_VERSION:
+ print(f"Adding version changes for {k} to post_upgrade.sh")
+ content += v
+
+ if content:
+ content += FINAL_LINES
+ with open(".vscode/post_upgrade.sh", "w") as f:
+ f.writelines(content)
+
+ print("Built post_upgrade.sh. Restart your workspace for it to take effect.")
+
+
+def process(file, suffix):
+ """
+ Replaces and optionally backs up the files that
+ need to be changed.
+ Arguments: file - a path and filename
+ suffix - the suffix to the BASE_URL
+ """
+
+ if file == ".gitpod.dockerfile" or file == ".gitpod.yml":
+ try:
+ shutil.copyfile(file, f"{file}.tmp")
+ except FileNotFoundError:
+ pass
+
+ with open(file, "wb") as f:
+ r = requests.get(BASE_URL + suffix)
+ f.write(r.content)
+
+ if exists(f"{file}.tmp"):
+ result = os.system(f"diff -q {file} {file}.tmp > /dev/null")
+ if result != 0:
+ os.remove(f"{file}.tmp")
+ return True
+
+ return False
+
+
+def start_migration():
+ """
+ Calls the process function and
+ renames the directory
+ """
+ push_and_recreate = False
+
+ if not os.path.isdir(".vscode"):
+ print("Creating .vscode directory")
+ os.mkdir(".vscode")
+
+ for file in UPGRADE_FILE_LIST:
+ print(f"Processing: {file['filename']}")
+ result = process(file["filename"], file["url"])
+ if result == True:
+ push_and_recreate = True
+
+ if push_and_recreate:
+ write_version()
+
+ if needs_upgrade() and not push_and_recreate:
+ build_post_upgrade()
+
+ print("Changes saved.")
+ print("Please add, commit and push to GitHub.")
+ print("You may need to stop and restart your workspace for")
+ print("the changes to take effect.\n")
+
+ if push_and_recreate:
+ print(f"{COLOURS['red']}{COLOURS['bold']}*** IMPORTANT INFORMATION ***{COLOURS['reset']}")
+ print("The files used to create this workspace have been updated")
+ print("Please download any files that are in .gitignore and")
+ print("recreate this workspace by clicking on the Gitpod button")
+ print("in GitHub. Then, upload your saved files again.\n")
+
+
+if __name__ == "__main__":
+
+ print(f"\n🦠{COLOURS['blue']}{COLOURS['bold']}ArcticTern version 0.3{COLOURS['reset']}")
+ print("CI Template Migration Utility")
+ print("-----------------------------")
+ print("Upgrades the workspace to the latest version.\n")
+
+ if input("Start? Y/N ").lower() == "y":
+ start_migration()
+ else:
+ sys.exit("Migration cancelled by the user")
diff --git a/.vscode/font_fix.py b/.vscode/font_fix.py
deleted file mode 100644
index 81e8816..0000000
--- a/.vscode/font_fix.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Fixes the font issue on Brave browser
-# Matt Rudge
-# August 2021
-
-import json
-import os
-
-BASE_PATH = os.environ.get("GITPOD_REPO_ROOT")
-
-with open(f"{BASE_PATH}/.vscode/settings.json", "r+") as f:
- content = json.loads(f.read())
-
- if "terminal.integrated.fontFamily" not in content:
- print("Adding wider and higher font settings")
- content["terminal.integrated.lineHeight"] = 1.2
- content["terminal.integrated.letterSpacing"] = 2
- else:
- print("Wider and higher font settings already added!")
-
- f.seek(0, os.SEEK_SET)
- f.write(json.dumps(content))
- f.truncate()
diff --git a/.vscode/heroku_config.sh b/.vscode/heroku_config.sh
index f842c96..5056d45 100644
--- a/.vscode/heroku_config.sh
+++ b/.vscode/heroku_config.sh
@@ -22,5 +22,19 @@ if [[ -z "${HEROKU_API_KEY}" ]]; then
. ~/.bashrc > /dev/null
echo Done!
else
- echo API key is already set. Exiting
+ echo API key is already set.
+ echo
+ echo To reset the API key please input "'reset'":
+ read reset_trigger
+ if [[ ${reset_trigger} == reset ]]; then
+ unset HEROKU_API_KEY
+ unset reset_trigger
+ echo
+ echo API key removed!
+ else
+ unset reset_trigger
+ echo API key unchanged.
+ fi
+ echo
+ echo Exiting
fi
diff --git a/.vscode/init_tasks.sh b/.vscode/init_tasks.sh
index 933bf6b..c532e38 100644
--- a/.vscode/init_tasks.sh
+++ b/.vscode/init_tasks.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-# Creates a user record for the current Cloud9 user
# Gives a personalised greeting
# Adds configuration options for SQLite
# Creates run aliases
@@ -8,19 +7,7 @@
echo "Setting the greeting"
sed -i "s/USER_NAME/$GITPOD_GIT_USER_NAME/g" ${GITPOD_REPO_ROOT}/README.md
-echo "Creating the gitpod user in MySQL"
-RESULT="$(mysql -sse "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'gitpod')")"
-if [ "$RESULT" = 1 ]; then
- echo "gitpod already exists"
-else
- mysql -e "CREATE USER 'gitpod'@'%' IDENTIFIED BY '';" -u root
- echo "Granting privileges"
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'gitpod'@'%' WITH GRANT OPTION;" -u root
-fi
echo "Creating .sqliterc file"
echo ".headers on" > ~/.sqliterc
echo ".mode column" >> ~/.sqliterc
echo "Your workspace is ready to use. Happy coding!"
-
-# Open README.md file
-code README.md
diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index d9e387c..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- // Use IntelliSense to learn about possible attributes.
- // Hover to view descriptions of existing attributes.
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Python: Current File (Integrated Terminal)",
- "type": "python",
- "request": "launch",
- "program": "${file}",
- "console": "internalConsole"
- }
- ]
-}
diff --git a/.vscode/make_url.py b/.vscode/make_url.py
new file mode 100644
index 0000000..1a27167
--- /dev/null
+++ b/.vscode/make_url.py
@@ -0,0 +1,14 @@
+# Simple utility for creating the Cloudinary URL from a
+# cloudinary_python.txt file
+# Matt Rudge, November 2021
+
+import re
+
+with open("cloudinary_python.txt") as f:
+ content = f.readlines()
+
+cloud_name = re.findall(r"['](.*?)[']",content[15])[0]
+api_key = re.findall(r"['](.*?)[']",content[16])[0]
+api_secret = re.findall(r"['](.*?)[']",content[17])[0]
+
+print(f"cloudinary://{api_key}:{api_secret}@{cloud_name}")
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 890f2f9..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "python.linting.pylintEnabled": true,
- "python.linting.enabled": true,
- "python.linting.pycodestyleEnabled": false,
- "python.linting.flake8Enabled": true,
- "python.terminal.activateEnvironment": false,
- "python.formatting.autopep8Path": "/home/gitpod/.pyenv/shims/autopep8",
- "python.linting.flake8Path": "/home/gitpod/.pyenv/shims/flake8",
- "cornflakes.linter.executablePath": "/home/gitpod/.pyenv/shims/flake8",
- "files.exclude": {
- "**/.DS_Store": true,
- "**/.git": true,
- "**/.github": true,
- "**/.gitp*": true,
- "**/.hg": true,
- "**/.svn": true,
- "**/.vscode": true,
- "**/core.Microsoft*": true,
- "**/core.mongo*": true,
- "**/core.python*": true,
- "**/CVS": true
- },
- "files.autoSave": "off",
- "workbench.colorTheme": "Visual Studio Dark",
- "editor.defaultFormatter": "HookyQR.beautify"
-}
diff --git a/README.md b/README.md
index fb3339e..ea849c5 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@

-Welcome USER_NAME,
+Welcome,
-This is the Code Institute student template for deploying your third portfolio project, the Python command-line project. The last update to this file was: **August 17, 2021**
+This is the Code Institute student template for deploying your third portfolio project, the Python command-line project. The last update to this file was: **May 14, 2024**
## Reminders
-* Your code must be placed in the `run.py` file
-* Your dependencies must be placed in the `requirements.txt` file
-* Do not edit any of the other files or your code may not deploy properly
+- Your code must be placed in the `run.py` file
+- Your dependencies must be placed in the `requirements.txt` file
+- Do not edit any of the other files or your code may not deploy properly
## Creating the Heroku app
@@ -27,5 +27,6 @@ Connect your GitHub repository and deploy as normal.
The deployment terminal is set to 80 columns by 24 rows. That means that each line of text needs to be 80 characters or less otherwise it will be wrapped onto a second line.
------
-Happy coding!
\ No newline at end of file
+---
+
+Happy coding!
diff --git a/runtime.txt b/runtime.txt
new file mode 100644
index 0000000..b884b0f
--- /dev/null
+++ b/runtime.txt
@@ -0,0 +1 @@
+python-3.12.2
\ No newline at end of file