Author SHA1 Message Date
pi-ux-ce 87a5e40e3e Update django_code/stash_management/apps.py
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-07-31 18:26:34 +00:00
pi-ux-ce bf7f831c42 Update django_code/dashboard/templates/stash_form.html
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-07-31 18:23:51 +00:00
pi-ux-ce f74a1a7076 🎨 cleanup useless variables
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m42s
2025-07-30 12:48:34 +00:00
pi-ux-ce 6c9c0ffad2 fixing mistake
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m8s
2025-07-29 23:18:28 +00:00
pi-ux-ce 4b1d75b1ba working change
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 4m57s
2025-07-29 23:08:30 +00:00
pi-ux-ce 6f06f7d657 working but work in progress for templating
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m25s
2025-07-29 22:36:50 +00:00
Pierre Geeraert 91c4928ec7 add namespace and purge
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m55s
2025-07-29 11:27:47 +01:00
pi-ux-ce 9ce785014d Merge pull request 'adding new form' (#4) from stash_from into main
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m7s
Reviewed-on: #4
2025-07-29 08:57:36 +00:00
Pierre Geeraert e139dcea35 remove useless files
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m48s
2025-07-29 09:54:07 +01:00
Pierre Geeraert adb18644ee change .gitignore
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6m20s
2025-07-29 09:46:47 +01:00
Pierre Geeraert bccd344aa7 adding new form
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-07-29 09:39:41 +01:00
pierre geeraert 3315fbdb4f change the DB settings and change the policy to restart after build
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m27s
2025-06-22 19:24:22 +01:00
pierre geeraert 5bbe4c5c61 work on the simpsons generator using the DB
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6m57s
2025-06-22 19:14:36 +01:00
Pierre Geeraert 2366d0c2a8 Revert "try without the cache git actions"
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m41s
This reverts commit a4d9f63568.
2025-06-03 11:48:12 +01:00
Pierre Geeraert a4d9f63568 try without the cache git actions
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-06-03 11:46:04 +01:00
Pierre Geeraert 496f2b3bfb modify cache directory
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m56s
2025-06-03 11:39:40 +01:00
Pierre Geeraert cb7a010fb6 modify cache directory
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-06-03 11:20:14 +01:00
Pierre Geeraert 5b5093708d modify cache directory
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2025-06-03 11:12:46 +01:00
Pierre Geeraert 975252656f modify cache directory
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m23s
2025-06-03 11:07:43 +01:00
Pierre Geeraert 0b7da7a5c9 cache works but I want local
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m30s
2025-06-03 10:57:01 +01:00
Pierre Geeraert 4e70e2d28d change key for git action cache
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m19s
2025-06-03 10:48:40 +01:00
Pierre Geeraert 705db14521 commenting ,from=pip_cache 2025-06-03 10:47:34 +01:00
45 changed files with 483 additions and 27 deletions
+12 -4
View File
@@ -21,7 +21,14 @@ jobs:
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: /root/.cache/pip path: /root/.cache/pip
key: pip-{{ hashFiles('requirements*.txt') }} key: pip
restore-keys: pip
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-source: /root/.cache/pip
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@@ -39,12 +46,13 @@ jobs:
push: true push: true
#build-contexts: pip_cache=${{steps.vars.outputs.pip-dir}} #build-contexts: pip_cache=${{steps.vars.outputs.pip-dir}}
tags: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest tags: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
cache-from: type=gha cache-from: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-python:buildcache
cache-to: type=gha,mode=max cache-to: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-python:buildcache,mode=max
- name: drop the pod to force pulling the new image - name: drop the pod to force pulling the new image
uses: actions-hub/kubectl@master uses: actions-hub/kubectl@master
env: env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with: with:
args: delete pod -n django-python --all args: rollout restart deployment django -n django
- run: echo "🍏 This job's status is ${{ job.status }}." - run: echo "🍏 This job's status is ${{ job.status }}."
+3
View File
@@ -1 +1,4 @@
*/__pycache__/* */__pycache__/*
*/.idea
venv/*
*__pycache__*
@@ -0,0 +1,288 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Scaled up</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
@charset "UTF-8";
.m-b-xs {
margin-bottom: 2%;
}
.m-b-md {
margin-bottom: 10%;
}
.m-t-xs {
margin-top: 2%;
}
.m-t-sm {
margin-top: 5%;
}
* {
outline: 0 !important;
}
body {
padding: 2% 0;
background-color: #37404a;
}
h1 {
font-family: "Roboto", sans-serif;
font-size: 2.2em;
font-weight: 300;
color: #85ffc7;
text-transform: uppercase;
}
p {
font-family: "Roboto", sans-serif;
font-size: 1.1em;
font-weight: 300;
color: #fff;
}
a {
color: #fff;
}
a:hover {
text-decoration: none;
color: #fff;
}
#survey-form label,
#survey-form .labels {
display: block;
margin-bottom: 2%;
font-family: "Roboto", sans-serif;
font-size: 1.1em;
font-weight: 300;
color: #fff;
letter-spacing: 0.5px;
}
#survey-form input::-webkit-input-placeholder {
color: transparent !important;
}
#survey-form input::-moz-placeholder {
color: transparent !important;
}
#survey-form input:-ms-input-placeholder {
color: transparent !important;
}
#survey-form input:-moz-placeholder {
color: transparent !important;
}
#survey-form input,
#survey-form select {
display: block;
width: 100%;
overflow: hidden;
outline: none;
border: 2px solid #333;
}
#survey-form input {
margin-top: 1.5%;
padding: 0 0 5px 0;
background: transparent;
border: none;
outline: none;
border-bottom: 2px solid #fff;
font-size: 1.1em;
font-weight: 300;
color: #85ffc7;
}
#survey-form input:focus {
border-color: #85ffc7;
}
#survey-form [type=checkbox],
#survey-form [type=radio] {
display: inline-block;
width: auto;
margin: 0px 10px 0 0;
}
#survey-form [type=checkbox],
#survey-form [type=radio] {
display: inline-block;
margin: 0 10px 0 0 !important;
position: relative;
top: 5px;
right: 0;
bottom: 0;
left: 0;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
height: 23px;
width: 23px;
transition: all 0.15s ease-out 0s;
background: #37404a;
color: #fff;
cursor: pointer;
outline: none;
z-index: 1000;
border: 1px solid #fff;
}
#survey-form [type=checkbox]:hover,
#survey-form [type=radio]:hover {
border-color: #85ffc7;
}
#survey-form [type=checkbox]:checked:before,
#survey-form [type=radio]:checked:before {
display: inline-block;
height: 21px;
width: 21px;
position: relative;
left: 0;
bottom: 0;
content: "";
text-align: center;
font-family: "Glyphicons Halflings";
line-height: 20px;
font-size: 15px;
color: #85ffc7;
}
#survey-form [type=checkbox]:focus,
#survey-form [type=radio]:focus {
outline: none;
border-color: #fff;
}
#survey-form [type=radio] {
border-radius: 50%;
}
#survey-form [type=radio]:after {
border-radius: 50%;
}
#survey-form [type=number] {
width: 45px;
}
#survey-form [type=number]::-webkit-inner-spin-button, #survey-form [type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
}
#survey-form select {
height: 40px;
padding-left: 5px;
background-color: #37404a;
border: 2px solid #fff;
color: #85ffc7;
}
#survey-form select option {
padding: 5px 10px;
font-weight: 300;
cursor: pointer;
}
#survey-form select option:hover {
background-color: #85ffc7;
}
#survey-form textarea {
resize: none;
margin-top: 2%;
padding: 10px 10px 0px 20px;
width: 100%;
height: 90px;
color: #85ffc7;
background-color: #37404a;
border: 2px solid #fff;
}
#survey-form .btn {
display: inline-block;
position: relative;
width: 100%;
margin: 3% 0 0 0;
height: 45px;
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
border: 3px solid #85ffc7;
border-radius: 0;
font-weight: 500;
font-size: 1.2em;
color: #85ffc7;
text-align: center;
background: none;
transition: color 0.25s ease;
}
#survey-form .btn:after {
position: absolute;
content: "";
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: #85ffc7;
transform-origin: left;
transition: width 0.5s ease;
z-index: -1;
}
#survey-form .btn:hover {
color: #37404a;
}
#survey-form .btn:hover:after {
width: 100%;
}
#survey-form fieldset {
margin: 5% 0 0 0;
}
.copyright {
text-align: center;
font-size: 10px;
color: #fff;
}
.copyright i {
color: #ef5350;
}
@media only screen and (max-width: 600px) {
body {
padding: 8% 0;
}
}
</style>
</head>
<main id="main" class="container">
<div class="row">
<div class="col-xs-12 col-lg-offset-3 col-lg-6">
<div class="m-b-md text-center">
<h1 id="title">Stash Form</h1>
<p id="description" class="description" class="text-center">Download form</p>
</div>
<form method="GET" action="/stash/submit-form/" id="survey-form" name="survey-form">
<fieldset>
<label for="name" id="name-label">
Name *
<input class="" type="text" id="name" name="name" placeholder="Enter your name (required)" required />
</label>
</fieldset>
<fieldset>
<label for="url" id="url-label">
URL *
<input class="" type="url" id="url" name="url" placeholder="Enter the URL (required)" required />
</label>
</fieldset>
<fieldset>
<label for="external_galleries">
Any external galleries ?
<textarea id="external_galleries" maxlength="194"></textarea>
</label>
</fieldset>
<button id="submit" type="submit" class="btn">Submit the form</button>
</form>
</div>
</div>
</main>
</html>
+7
View File
@@ -23,6 +23,7 @@ from onenote import apps as onenote
from dashboard import apps as dashboardapp from dashboard import apps as dashboardapp
from dashboard import views as dashboardview from dashboard import views as dashboardview
from kubernetes_connection import apps as kubernetes_connection from kubernetes_connection import apps as kubernetes_connection
from stash_management import apps as stashapp
urlpatterns = [ urlpatterns = [
# path('admin/', admin.site.urls), # path('admin/', admin.site.urls),
@@ -57,6 +58,12 @@ urlpatterns = [
path('kubernetes_connection/scale_up/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_up), path('kubernetes_connection/scale_up/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_up),
path('kubernetes_connection/scale_down/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_down), path('kubernetes_connection/scale_down/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_down),
################## kubernetes_connection#####
path('stash/hello/', stashapp.hello),
path('stash/form/', stashapp.form),
path('stash/submit-form/', stashapp.handle_survey_form, name='submit_form'),
# path('bookstack/', docker_connection.apps.hello), # path('bookstack/', docker_connection.apps.hello),
# path('test/', docker_connection.apps.http_call_test), # path('test/', docker_connection.apps.http_call_test),
# path('proxmox/', docker_connection.apps.proxmox), # path('proxmox/', docker_connection.apps.proxmox),
Binary file not shown.
Binary file not shown.
+64 -20
View File
@@ -3,13 +3,38 @@ from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.shortcuts import redirect from django.shortcuts import redirect
from django.core.files import File from django.core.files import File
#from django.template.loader import render_to_string #from django.template.loader import render_to_string
import time import time
import psycopg2
import random import random
import mimetypes import mimetypes
def DB_generation(host_in,port_in,user_in,password_in,db_in):
#db = pymysql.connect(host=host_in, port=port_in, user=user_in, passwd=password_in,db=db_in)
db = psycopg2.connect(host=host_in, port=port_in, user=user_in, password=password_in,database=db_in)
return db
def Launch_sql_query(sql,db):
#sql query with 1 object returned
cursor = db.cursor()
try:
# Execute the SQL command
cursor.execute(sql)
# Fetch all the rows in a list of lists.
results = cursor.fetchall()
for row in results:
return row[0]
except:
print ("Error: unable to fetch data from the query:")
print (sql)
print("---")
cursor.close()
def hello(request): def hello(request):
return HttpResponse('<h1>Hello Simpsons!</h1>') return HttpResponse('<h1>Hello Simpsons!</h1>')
#<h1>href="{{ STATIC_URL }}/files/somefile</h1>) #<h1>href="{{ STATIC_URL }}/files/somefile</h1>)
@@ -25,8 +50,8 @@ def download_file(request):
# response = HttpResponse(fl, content_type=mime_type) # response = HttpResponse(fl, content_type=mime_type)
# response['Content-Disposition'] = "attachment; filename=%s" % filename # response['Content-Disposition'] = "attachment; filename=%s" % filename
some_file = open('/data/kubernetes/Backup/nextcloud/notes/2024-07-28/Course.md', "r") some_file = open('/data/kubernetes/Backup/nextcloud/notes/2024-07-28/Course.md', "r")
django_file = File(some_file) django_file = File(some_file)
return HttpResponse("<h1>Hello download!</h1><h1><a href='{{ MEDIA_URL }}{{ django_file.relative_path }}'>{{ django_file.name }}</a></h1><h1>bye download!</h1>") return HttpResponse("<h1>Hello download!</h1><h1><a href='{{ MEDIA_URL }}{{ django_file.relative_path }}'>{{ django_file.name }}</a></h1><h1>bye download!</h1>")
# return response # return response
@@ -42,27 +67,46 @@ def download_mo(request,file):
#return HttpResponse('<h1>Hello !</h1>') #return HttpResponse('<h1>Hello !</h1>')
def simpsons(request): def simpsons(request):
# simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-"; #dev settings
simpsons_url = "https://kisscartoon.top/episode/the-simpsons-season-"; #generated_db = DB_generation("192.168.88.50",32345, "django_username", "Suffrage-Moneybags-Illusion7","django")
number_of_seasons = 35 #production settings
seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18] generated_db = DB_generation("django-db-svc",5432, "django_username", "Suffrage-Moneybags-Illusion7","django")
#print(simpsons_url) cursor = generated_db.cursor()
random_seasons = random.randint(1, number_of_seasons) #get max number of season
print("random seasons: "+ str(random_seasons)) maximum_number_of_seasons = Launch_sql_query("SELECT COUNT(DISTINCT season) as result FROM episodes;",generated_db)
#random_seasons-1 because list start at index 0 boolean_restart = True;
print("maximum of episode for this season: "+str(seasons_maximum_number[random_seasons-1])) while (boolean_restart):
random_episode = random.randint(1, seasons_maximum_number[random_seasons-1]) random_seasons = random.randint(1, maximum_number_of_seasons)
print("random season: " + str(random_seasons))
print("random episode: "+ str(random_episode))
final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)# #get max number of epiosde for this season
print(final_url) maximum_number_of_episodes_query = "SELECT COUNT(url) as result FROM episodes WHERE season = " + str(random_seasons) + ";"
return HttpResponse(str(final_url)) maximum_number_of_episodes = Launch_sql_query(maximum_number_of_episodes_query,generated_db)
# time.sleep(10)
# return redirect(str(final_url)) random_episode = random.randint(1, maximum_number_of_episodes)
print("random episode: " + str(random_episode))
#check if the episode was already seen
check_if_already_seen_query = "select seen from episodes where season="+ str(random_seasons) +" and episode = "+ str(random_episode) +";"
if not Launch_sql_query(check_if_already_seen_query, generated_db):
boolean_restart = False
else:
print("episode "+str(random_episode)+" from season "+str(random_seasons)+" already seen")
url_from_episode_season_query = "select url from episodes where season="+ str(random_seasons) +" and episode = "+ str(random_episode) +";"
generated_url = Launch_sql_query(url_from_episode_season_query,generated_db)
#mark as seen
url_from_episode_season_query = "update episodes set seen = True where season=" + str(random_seasons) + " and episode = " + str(random_episode) + ";"
Launch_sql_query(url_from_episode_season_query, generated_db)
generated_db.commit()
generated_db.close()
#return HttpResponse(str(generated_url))
return redirect(str(generated_url))
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+49
View File
@@ -0,0 +1,49 @@
from django.apps import AppConfig
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect
from jinja2 import Environment, FileSystemLoader
from django.core.files import File
from kubernetes import client, config
import time
import random
import mimetypes
import ruamel.yaml
import yaml
import urllib.request
def hello(request):
return HttpResponse('<h1>Hello stash!</h1>')
def form(request):
return render(request, 'stash_form.html',{})
def handle_survey_form(request):
config.load_kube_config(config_file='/kubeconfig/config')
v1 = client.BatchV1Api()
name = request.GET.get('name')
url = request.GET.get('url')
external_galleries = request.GET.get('external_galleries')
with open('django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml', 'r') as file:
#get the manifest in a variable template_manifest from the manifest file
template_manifest = yaml.safe_load(file)
#edit the container name
template_manifest['metadata']['name'] ="stash-pornpics-dowloader"+name
template_manifest['spec']['template']['spec']['containers'][0]['name'] ="stash-pornpics-dowloader-"+name
#edit the command based on the input
command=['bash', '/config/download.sh', '--http_proxy', 'http://gluetun-svc.gluetun.svc:8888', '--BASE_URL', url, '--pornstars', name,'--external_gallery', external_galleries]
template_manifest['spec']['template']['spec']['containers'][0]['command']=command
#execute based on the value
api_response = v1.create_namespaced_job(body=template_manifest,namespace='stash')
return HttpResponse(api_response)
+3
View File
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
@@ -0,0 +1 @@
<h1>Hello template!</h1>
@@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: Job
metadata:
name: stash-pornpics-dowloader-{{ name }}
namespace: stash
spec:
template:
spec:
containers:
- name: stash-pornpics-dowloader-{{ name }}
image: bash
imagePullPolicy: Always
volumeMounts:
- mountPath: /config
name: scripts
- mountPath: /data
mountPropagation: None
name: data-pvc
command:
- bash
- /config/download.sh
- --http_proxy
- "http://gluetun-svc.gluetun.svc:8888"
- --BASE_URL
- "{{ url }}"
- --pornstars
- "{{ name }}"
restartPolicy: Never
volumes:
- configMap:
defaultMode: 0744
name: pornpic-dowloader
name: scripts
- name: data-pvc
persistentVolumeClaim:
claimName: data-pvc
backoffLimit: 4
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+8
View File
@@ -0,0 +1,8 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
def hello(request):
return HttpResponse('<h1>Hello Django!</h1>')
+2 -2
View File
@@ -5,8 +5,8 @@ WORKDIR /code/
COPY requirements.txt ./ COPY requirements.txt ./
COPY django_code ./ COPY django_code ./
RUN --mount=type=cache,target=/root/.cache/pip,from=pip_cache pip install --upgrade pip RUN --mount=type=cache,target=/root/.cache/pip pip install --upgrade pip
RUN --mount=type=cache,target=/root/.cache/pip,from=pip_cache pip install --no-cache-dir -r requirements.txt RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
RUN python django_code/manage.py migrate RUN python django_code/manage.py migrate
+3 -1
View File
@@ -1,8 +1,10 @@
django django
psycopg2
requests requests
proxmoxer proxmoxer
docker docker
kubernetes kubernetes
ruamel.yaml ruamel.yaml
pyyaml pyyaml
django-bootstrap-v5 django-bootstrap-v5
jinja2