diff --git a/html_cleanup/static/temp/clean_all_gender.png b/html_cleanup/static/temp/clean_all_gender.png deleted file mode 100644 index 23b4f73..0000000 --- a/html_cleanup/static/temp/clean_all_gender.png +++ /dev/null @@ -1,5 +0,0 @@ - - - -untitled - diff --git a/html_cleanup/static/temp/clean_clean_Nantes_anthologie_cinema_viet.htm b/html_cleanup/static/temp/clean_clean_Nantes_anthologie_cinema_viet.htm deleted file mode 100644 index 6a6db1b..0000000 --- a/html_cleanup/static/temp/clean_clean_Nantes_anthologie_cinema_viet.htm +++ /dev/null @@ -1,769 +0,0 @@ - - - -untitled - - - - - - - - - -
- - - - - - - -

- -Festival des 3 Continents, Nantes 24.11 - 3.12 2023

- - - - - - - -

- -Anthologie du cinéma vietnamien

- - - - - - - -

 

- - - - - - - -

19 films vietnamiens - - - -de 1974 à 2022

- - - - - - - -

 

- - - - - - - -We will meet again

- - - - - - - -

We will meet - - - -again / Đến hẹn lại lên - Tran Vu, 1974, 108’

- - - - - - - -

Dimanche 26.11, - - - -18:30 - Vendredi 1.12, 13:45

- - - - - - - -

 

- - - - - - - -

Premier amour - - / Mối tình đầu - Hai Ninh, 1977, 112’

- - - - - - - -

Samedi 25.11, 13:45 - - - -- Jeudi 30.11, 20:30

- - - - - - - -

 

- - - - - - - -

The faces of may - - / Tháng năm, những gương mặt- Dang Nhat Minh, 1975, 37’

- - - - - - - -Nostalgie de la campagne

- - - - - - - -

Nostalgie de la - - - -campagne / Thương nhớ đồng quê - Dang Nhat Minh, - - - -1995, 116’

- - - - - - - -

Mercredi 29.11, - - - -20:30 - Vendredi 1.12, 17:00

- - - - - - - -

 

- - - - - - - -

Chom et Sa - - / Chom và Sa - Pham Ky Nam, 1979, 70’

- - - - - - - -

Dimanche 26.11, - - - -10:00 - Lundi 27.11, 16:15

- - - - - - - -

 

- - - - - - - -

Hanoi through - - - -whose eyes ? / Hà Nội trong mắt ai - Tran Van - - - -Thuy, 1982, 45’

- - - - - - - -

The story of kindness - - - -or How to behave / Chuyện tử tế - Tran Van - - - -Thuy, 1987, 43’

- - - - - - - -

Mardi 28.11, 16:00 - - - - -Dimanche 3.12, 10:30

- - - - - - - -

 

- - - - - - - -

Brothers - - / Anh và em - Nguyen Huu Luyen & Tran Vu, 1986, 87’

- - - - - - - -

Dimanche 26.11, 20:45 - - - -- Jeudi 30.11, 18:30

- - - - - - - -

 

- - - - - - - -

La fille du - - - -fleuve / Cô gái trên sông - Dang Nhat Minh, 1987, 100’

- - - - - - - -

Samedi 25.11, 20:45 - - - -- Jeudi 30.11, 10:15

- - - - - - - -

 

- - - - - - - -

Troupe de cirque - - - -ambulant / Gánh xiếc rong - Viet Linh, 1988, 80’

- - - - - - - -

Lundi 27.11, 17:30 - - - - -Dimanche 3.12, 17:30

- - - - - - - -

 

- - - - - - - -

Fairytale for a - - - -17-year-old girl /  Chuyện cổ tích cho tuổi 17 - - - - -Nguyen Xuan Son, 1988, 77’

- - - - - - - -

Mercredi 29.11, - - - -13 :00 - Samedi 2.12, 13 :00

- - - - - - - -

 

- - - - - - - -

La lampe dans le - - - -rêve / Ngọn đèn trong mơ - Do Minh Tuan, 1988, 75’

- - - - - - - -

Mardi 28.11, 10:15 - - - - -Vendredi 1.12, 18:45

- - - - - - - -

 

- - - - - - - -

Money, - - - -Money ! / Tiền ơi ! - Tran Vu & Nguyen - - - -Huu Luyen, 1989, 93’

- - - - - - - -

Dimanche 26.11, - - - -15:30 - Samedi 2.12, 15:45

- - - - - - - -

 

- - - - - - - -

Enfance orageuse - - / Tuổi thơ dữ dội - Nguyen Vinh Son, 1990, 135’

- - - - - - - -

Lundi 27.11, 13:30 - - - - -Samedi 2.12, 20:30

- - - - - - - -

 

- - - - - - - -

PLease forgive me - - / Hãy tha thứ cho em - Luu Trong Ninh, 1992, 90’

- - - - - - - -

Lundi 27.11, 18:30 - - - - -Mercredi 29.11, 18:15

- - - - - - - -

 

- - - - - - - -

Piège d’amour - - / Cạm bảy tình yêu - Pham Loc, 1992, 82’

- - - - - - - -

Lundi 27.11, 10:30 - - - - -Mercredi 29.11, 14:45

- - - - - - - -

 

- - - - - - - -

In the lane - - / Ngõ hẹp - Bach Diep, 1993, 98’

- - - - - - - -

Samedi 25.11, 10:15 - - - -- Mardi 28.11, 14:00

- - - - - - - -

 

- - - - - - - -L’Immeuble

- - - - - - - -

L’Immeuble - - / Chung cư - Viet Linh, 1999, 90’

- - - - - - - -

Samedi 25.11, 16:15 - - - -- Mercredi 29.11, 15:00

- - - - - - - -

 

- - - - - - - -Dust & metal

- - - -

Dust & metal - - / Cát bụi và kim loại - Esther Johnson, 2022, 83’

- - - - - - - -

Vendredi 1.12, 20:30 - - - -- Dimanche 3.12, 18:00

- - - - - - - -

 

- - - - - - - -

Anthologie du cinéma vietnamien :

- - - - - - - -

- -https://www.3continents.com/fr/programme/2023/anthologie-du-cinema-vietnamien/

- - - - - - - -

Programme 2023, horaires et lieux :

- - - - - - - -

- -https://www.3continents.com/wp-content/uploads/f3c-prog-2023-40p-net-planche.pdf

- - - - - - - -

 

- - - - - - - -

 

- - - - - - - -

 

- - - - - - - -

 

- - - - - - - -
- - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - - - - - - diff --git a/html_cleanup/static/temp/errors_log b/html_cleanup/static/temp/errors_log index 8cbe55c..a3d959e 100644 --- a/html_cleanup/static/temp/errors_log +++ b/html_cleanup/static/temp/errors_log @@ -1,2 +1,3 @@ 2023-11-29 17:22:16 [ Nantes_anthologie_cinema_viet.htm ] *** Cleanup réussi. *** 2023-11-29 17:23:56 [ Screenshot 2023-11-20 at 12.07.54.png ] Le format du fichier n'est pas valide. Téléchargement refusé. +30-11-2023 17:29 [ Nantes_anthologie_cinema_viet.htm ] *** Cleanup réussi. *** diff --git a/html_cleanup/templates/home.jinja2 b/html_cleanup/templates/home.jinja2 index 159d1b8..045a175 100644 --- a/html_cleanup/templates/home.jinja2 +++ b/html_cleanup/templates/home.jinja2 @@ -10,7 +10,7 @@
@@ -35,6 +35,11 @@ Télécharger {% endif %} +
+
+ [ Voir historique ] +
+ {% endblock content %} diff --git a/html_cleanup/templates/view_log.jinja2 b/html_cleanup/templates/view_log.jinja2 index e65443c..f4cce28 100644 --- a/html_cleanup/templates/view_log.jinja2 +++ b/html_cleanup/templates/view_log.jinja2 @@ -1,19 +1,48 @@ {% extends "layout.jinja2" %} {% block content %} - -
- {% for line in lines %} -
{{ line }}
- {% endfor %} -
- - {%if lines %} -
-
- + {% if message %} +
+ {{ message }}
- {% endif %} + +
+ + {% if not lines %} +
+ +
+ +
+ +
+ {% else %} +
+ {% for line in lines %} +
{{ line }}
+ {% endfor %} +
+
+ + Retour + +
+ +

Contenu du dossier TEMP

+ + {% for entry in files_list %} + + + + + + {% endfor %} +
{{ entry[1] }}{{ entry[0] }}{{ entry[2] }}
+ {% endif %} + +
+ {% endblock content %} diff --git a/html_cleanup/views/default.py b/html_cleanup/views/default.py index 5e16392..7ca2db3 100644 --- a/html_cleanup/views/default.py +++ b/html_cleanup/views/default.py @@ -5,6 +5,7 @@ import shutil import magic import sys import datetime +import time @view_config(route_name='home', renderer='html_cleanup:templates/home.jinja2') def home(request): @@ -34,14 +35,14 @@ def process_file(request, input_file, input_name): # Check file mime type and size # and if OK, process file message = '' - ext_allowed = ['text/html'] - max_size = 5 * (1024 ** 2) # 10 Mb + EXT_ALLOWED = ['text/html'] + MAX_SIZE = 10 * (1024 ** 2) # 10 Mb temp_folder = request.registry.settings['temp_folder'] logfile_name = os.path.join(temp_folder, 'errors_log') mime = magic.from_buffer(input_file.read(), mime=True) # types de fichiers autorisés ? - if mime not in ext_allowed: + if mime not in EXT_ALLOWED: message = "Le format du fichier n'est pas valide. Téléchargement refusé." add_error2log(logfile_name, input_name, message) else: @@ -50,7 +51,7 @@ def process_file(request, input_file, input_name): filesize = input_file.tell() input_file.seek(0) # back to original position # controler la taille du fichier - if filesize > max_size: + if filesize > MAX_SIZE: message = "La taille du fichier dépasse la limite autorisée. Téléchargement refusé." add_error2log(logfile_name, input_name, message) else: @@ -165,7 +166,7 @@ def add_error2log(logfile_name, input_name, message): # Get the current date and time now = datetime.datetime.now() with open(logfile_name, 'a', encoding='utf-8') as file: - line = now.strftime("%Y-%m-%d %H:%M:%S") + ' [ ' + input_name + ' ] ' + f'{message}\n' + line = now.strftime("%d-%m-%Y %H:%M") + ' [ ' + input_name + ' ] ' + f'{message}\n' file.write(line) @view_config(route_name='view_log', renderer='html_cleanup:templates/view_log.jinja2') @@ -174,22 +175,43 @@ def view_log(request): message = '' temp_folder = request.registry.settings['temp_folder'] logfile_name = os.path.join(temp_folder, 'errors_log') + users = ['minh','hvtien','dinh','giao','ctphuoc','TamCauDePiR','VHN','zidol','sautam'] lines = [] + files_list = [] + username = '' if 'form.submitted' in request.params: + username = request.POST.get('username') + if username in users: + # lire et affiche le fichier log + try: + file = open(logfile_name, "r") + lines = file.readlines() + file.close() + except Exception as e: + pass + + # lire tous les fichiers du dossier + for f in os.scandir(temp_folder): + if f.name[0] != '.' and f.name != 'errors_log': + f_path = temp_folder + f.name + nbs = os.path.getmtime(f_path) # en nombre de secondes + + file = [] + file.append(time.strftime("%d/%m/%Y %H:%M",time.gmtime(nbs))) + file.append(f.name) + file.append('%s Ko' % round(os.path.getsize(f_path) / 1024, 1)) + files_list.append(file) + else: + message = "Identifiant invalide !" + + if 'form.erased' in request.params: if os.path.exists(logfile_name): os.remove(logfile_name) - # Ouvrir le fichier en lecture seule - try: - file = open(logfile_name, "r") - lines = file.readlines() - file.close() - except Exception as e: - pass - return { - 'page_title': "HTML cleanup log", + 'page_title': "Journal de Cleanup", 'message': message, 'lines': lines, + 'files_list': files_list, }