Skip to content

Commit

Permalink
maj
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Oct 9, 2022
1 parent 7063343 commit 0120638
Show file tree
Hide file tree
Showing 49 changed files with 13,208 additions and 879 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV LC_ALL fr_FR.UTF-8
ENV TZ=Europe/Paris

RUN pip install --upgrade pip
RUN pip install -r /app/requirement.txt
RUN pip install -r /app/requirements.txt
RUN pip install git+https://github.com/influxdata/influxdb-client-python.git@master

CMD ["python", "-u", "/app/main.py"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COMPOSE=docker compose -f docker-compose.dev.yml
debug:
set -x
$(call title,"Debug mode")
$(COMPOSE) run -p 80:80 myelectricaldata_import
$(COMPOSE) run -p 5000:5000 myelectricaldata_import

## Start docker conatiners for dev
up:
Expand Down
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

URL = "https://myelectricaldata.fr"

fail_count = 24
fail_count = 50
cycle_minimun = 3600

DAILY_MAX_DAYS = 1095
150 changes: 137 additions & 13 deletions app/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,149 @@
from models.log import *
from models.cache import Cache
import logging
import os
import sys

from jinja2 import Template

CACHE = Cache()
from config import *

def logo(version):
def debug(message):
logWarn()
if type(message) is list:
for msg in message:
logging.debug(f" {msg}")
else:
logging.debug(f" {message}")
logWarn()

def log(message):
if type(message) is list:
for msg in message:
logging.info(f" {msg}")
else:
logging.info(f" {message}")


def logTitle(message):
logSep()
log("# __ __ ______ _ _ _ _ _____ _ #")
log("# | \/ | | ____| | | | (_) | | __ \ | | #")
log("# | \ / |_ _| |__ | | ___ ___| |_ _ __ _ ___ __ _| | | | | __ _| |_ __ _ #")
log("# | |\/| | | | | __| | |/ _ \/ __| __| '__| |/ __/ _` | | | | |/ _` | __/ _` | #")
log("# | | | | |_| | |____| | __/ (__| |_| | | | (_| (_| | | |__| | (_| | || (_| | #")
log("# |_| |_|\__, |______|_|\___|\___|\__|_| |_|\___\__,_|_|_____/ \__,_|\__\__,_| #")
log("# __/ | #")
log("# |___/ #")
logging.info(f" {message.upper()}")
logSep()


def logDebug(message):
if type(message) is list:
for msg in message:
logging.debug(f" {msg}")
else:
logging.debug(f" {message}")


def logWarning(message):
if type(message) is list:
for msg in message:
logging.warning(f" {msg}")
else:
logging.warning(f" {message}")


def logError(message):
logging.error("═════════════════════════════════•°• :ERREUR: •°•══════════════════════════════════")
logging.error("")
if type(message) is list:
for msg in message:
logging.error(f" {msg}")
else:
logging.error(f" {message}")
logging.error("")
logging.error("═══════════════════════════════════════════════════════════════════════════════════")


def logCritical(message):
if type(message) is list:
for msg in message:
logging.critical(f" {msg}")
else:
logging.critical(f" {message}")
sys.exit()


def logSep():
logging.info("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ◦ ❖ ◦ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")


def logWarn():
logging.info("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ▲ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")


def logo(version):
logSep()
log(f" VERSION : {version}")
logging.info("# __ __ ______ _ _ _ _ _____ _ #")
logging.info("# | \/ | | ____| | | | (_) | | __ \ | | #")
logging.info("# | \ / |_ _| |__ | | ___ ___| |_ _ __ _ ___ __ _| | | | | __ _| |_ __ _ #")
logging.info("# | |\/| | | | | __| | |/ _ \/ __| __| '__| |/ __/ _` | | | | |/ _` | __/ _` | #")
logging.info("# | | | | |_| | |____| | __/ (__| |_| | | | (_| (_| | | |__| | (_| | || (_| | #")
logging.info("# |_| |_|\__, |______|_|\___|\___|\__|_| |_|\___\__,_|_|_____/ \__,_|\__\__,_| #")
logging.info("# __/ | #")
logging.info("# |___/ #")
logSep()
logging.info(f" VERSION : {version}")


if os.environ.get("APPLICATION_PATH") is None:
APPLICATION_PATH = "/app"
else:
APPLICATION_PATH = os.environ.get('APPLICATION_PATH')


def html_return(body, url="/import/0"):
links = ["Forcer l'importation"]
footer = ""
for i, comment in enumerate(links):
footer += f"""
<div id="bouton_enedis" style="">
<a style="text-decoration: none" href="{url}"><div class="btn">{comment}</div></a>
</div>
"""

with open(f'{APPLICATION_PATH}/html/footer.html') as file_:
footer_template = Template(file_.read())
footer = footer_template.render(footer=footer)

with open(f'{APPLICATION_PATH}/html/index.html') as file_:
index_template = Template(file_.read())

html = index_template.render(
body=body,
fullscreen=True,
footer=footer,
homepage_link="/",
footer_height=80,
concent_url=f'{URL}',
swagger_url=f"{URL}/docs/",
redoc_url=f"{URL}/redoc/",
faq_url=f"{URL}/faq/",
code_url=f"{URL}/error_code/",
doc_url=f"{URL}/documentation/",
)
return html


paypal_footer = """
<div style="text-align: center" id="paypal" class="paypal_link">
<form action="https://www.paypal.com/donate" method="post" target="_top" style="height: 30px;" id="paypal_form">
<input type="hidden" name="business" value="FY25JLXDYLXAJ" />
<input type="hidden" name="no_recurring" value="0" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="image" id="paypal_img"
src="/static/paypal.png"
border="0"
name="submit"
title="PayPal - The safer, easier way to pay online!"
alt="Bouton Faites un don avec PayPal"/>
<img alt="" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1" />
</form>
Le service est gratuit, mais si tu souhaites soutenir le projet (serveur & domaine).
</div>
"""

# def is_json(myjson):
# try:
Expand Down
Binary file added app/html/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions app/html/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{ footer }}
</div>
Empty file added app/html/homepage.md
Empty file.
158 changes: 158 additions & 0 deletions app/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<html>
<head>
<title>MyElectricalData</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gasparesganga-jquery-loading-overlay@2.1.7/dist/loadingoverlay.min.js"></script>
<script src="/static/menu.js"></script>
<script src="/static/notif.js"></script>
<script src="/static/nice-select.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/static/main.css">
<link rel="stylesheet" href="/static/menu.css">
<link rel="stylesheet" href="/static/notif.css">
<link rel="stylesheet" href="/static/logo.css">
<link rel="stylesheet" href="/static/nice-select.css">
<script>

$(document).ready(function(){

$( ".paypal_link" ).click(function() {
$("#paypal_form").first().submit();
});

$('code').on('click', (e) => {
var content = e.target.innerText
copyToClipboard(content);
$.notify(" Copie : "+ content.slice(0, 30) + "..." + content.slice(-30), { style: 'enedis', className: 'success'});
});

$.notify.addStyle('enedis', {
html: "<div><span data-notify-text/></div>"
});

$( "#bouton_enedis").click(function() {
$.LoadingOverlay("show");
});

$( ".alert_redirect" ).click(function(e) {
var url = $(this).attr("about")
$.confirm({
columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8',
containerFluid: true, // this will add 'container-fluid' instead of 'container'
boxWidth: '600px',
useBootstrap: false,
title: 'Confirmation',
content: 'Vous allez être rediriger vers '+url,
buttons: {
confirm: {
text: 'OK!',
btnClass: 'btn-blue',
action: function () {
location.href = url;
}
},
cancel: {
text: 'Non merci',
btnClass: 'btn-blue',
},
}
});
});

$("#select_usage_point_id").niceSelect()

$("#select_usage_point_id").change(function() {
location.href = "/usage_point_id/"+$("#select_usage_point_id").val();
});

});


function copyToClipboard(text) {
var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}

</script>
</head>
<body style="margin: 0px">
<div class="side_menu">
<div class="burger_box">
<div class="menu-icon-container">
<a href="#" class="menu-icon js-menu_toggle closed">
<span class="menu-icon_box">
<span class="menu-icon_line menu-icon_line--1"></span>
<span class="menu-icon_line menu-icon_line--2"></span>
<span class="menu-icon_line menu-icon_line--3"></span>
</span>
</a>
</div>
</div>
<div class="container">
<h2 class="menu_title">Menu</h2>
<ul class="list_load">
<li class="list_item"><a href="/">Accueil</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ concent_url }}">Consentement</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ doc_url }}">Documentation</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ swagger_url }}">Swagger</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ redoc_url }}">Redoc</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ code_url }}">Codes d'erreurs</a></li>
<li class="list_item"><a style="cursor: pointer" class="alert_redirect" about="{{ faq_url }}">FAQ</a></li>
</ul>
<div class="spacer_box"><p>Liens</p></div>
<ul id="menu_link" class="list_load">
<li class="list_item"><a href="https://discord.gg/DfVJZme" style="display: inline-block;">
<div>
<img style="vertical-align:middle; width: 18px" src="/static/discord.png" alt="Discord">
<span style="padding-left: 10px;">Discord</span>
</div></a>
</li>
<li class="list_item"><a href="https://mon-compte-client.enedis.fr" style="display: inline-block;">
<div>
<img style="vertical-align:middle; width: 18px" src="/static/enedis.png" alt="Enedis">
<span style="padding-left: 10px;">Enedis</span>
</div></a>
</li>
</ul>
<ul class="list_load">
<li class="list_item">
<div style="text-align: center" id="paypal" class="paypal_link">
<form action="https://www.paypal.com/donate" method="post" target="_top" style="height: 40px;" id="paypal_form">
<input type="hidden" name="business" value="FY25JLXDYLXAJ" />
<input type="hidden" name="no_recurring" value="0" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="image" id="paypal_img"
src="/static/paypal.png"
border="0"
name="submit"
title="PayPal - The safer, easier way to pay online!"
alt="Bouton Faites un don avec PayPal"/>
<img alt="" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1" />
</form>
</div>
</li>
</ul>
</div>
</div>
<div id="content" style="padding-left: 50px;">
<div id="header">
<div id="header_logo" style="float: left;">
<div id="logo" onClick="parent.location='/'">&nbsp;</div>
</div>
</div>
<div id="body" style="padding-bottom: 100px;">{{ body }}</div>
<div id="footer">{{ footer }}</div>
</div>
</body>
</html>
Binary file added app/html/static/discord.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/html/static/enedis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/html/static/enedis_collecte.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/html/static/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/html/static/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/html/static/icon.pbm
Binary file not shown.
Binary file added app/html/static/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0120638

Please sign in to comment.