mirror of
				https://github.com/NohamR/PronoteBot.git
				synced 2025-10-30 23:09:46 +00:00 
			
		
		
		
	update (fix crash)
This commit is contained in:
		
							parent
							
								
									578c56d867
								
							
						
					
					
						commit
						3ca9f33989
					
				
							
								
								
									
										
											BIN
										
									
								
								Capture d’écran 2023-12-13 à 19.02.26.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Capture d’écran 2023-12-13 à 19.02.26.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.2 MiB | 
| @ -1,14 +1,9 @@ | ||||
| FROM python:3.10-alpine | ||||
| 
 | ||||
| # Copiez les fichiers nécessaires dans le conteneur | ||||
| COPY getgrades.py . | ||||
| # COPY average.txt . | ||||
| # COPY grades.txt . | ||||
| COPY requirements.txt . | ||||
| COPY .env . | ||||
| 
 | ||||
| # Installez les dépendances | ||||
| RUN pip install --no-cache-dir -r requirements.txt | ||||
| 
 | ||||
| # Commande pour exécuter votre programme Python | ||||
| CMD ["python", "-u", "getgrades.py"] | ||||
							
								
								
									
										54
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | ||||
| name: pronoteapi | ||||
| services: | ||||
|   app: | ||||
|     cpu_shares: 90 | ||||
|     command: [] | ||||
|     deploy: | ||||
|       resources: | ||||
|         limits: | ||||
|           memory: 7943M | ||||
|     image: pronoteapi:latest | ||||
|     labels: | ||||
|       icon: https://camo.githubusercontent.com/3ae516af10d2a609989fece36dda63f4d10ee30cca1dd46564454c5bb07697c9/68747470733a2f2f70726f6e6f746570792e72656164746865646f63732e696f2f656e2f6c61746573742f5f696d616765732f69636f6e2e706e67 | ||||
|     restart: unless-stopped | ||||
|     x-casaos: | ||||
|       envs: | ||||
|         - container: LOG_LEVEL | ||||
|           description: | ||||
|             en_us: Log level | ||||
|         - container: TZ | ||||
|           description: | ||||
|             en_us: Timezone | ||||
|       volumes: | ||||
|         - container: /app/config | ||||
|           description: | ||||
|             en_us: "Container Path: /app/config" | ||||
|     ports: [] | ||||
|     volumes: [] | ||||
|     devices: [] | ||||
|     cap_add: [] | ||||
|     environment: [] | ||||
|     network_mode: bridge | ||||
|     privileged: false | ||||
|     container_name: "" | ||||
| x-casaos: | ||||
|   architectures: | ||||
|     - amd64 | ||||
|     - arm64 | ||||
|   author: nohamr | ||||
|   category: Api | ||||
|   description: | ||||
|     en_us: Recup tes notes sur pronote et les envoie sur un webhooks | ||||
|   developer: nohamr | ||||
|   hostname: 0910626l.index-education.net/pronote/eleve.html?identifiant=rb5yNZw4HrWKHrcK | ||||
|   icon: https://camo.githubusercontent.com/3ae516af10d2a609989fece36dda63f4d10ee30cca1dd46564454c5bb07697c9/68747470733a2f2f70726f6e6f746570792e72656164746865646f63732e696f2f656e2f6c61746573742f5f696d616765732f69636f6e2e706e67 | ||||
|   index: / | ||||
|   main: app | ||||
|   port_map: "" | ||||
|   scheme: https | ||||
|   store_app_id: pronoteapi | ||||
|   tagline: | ||||
|     en_us: Recup tes notes sur pronote et les envoie sur un webhooks | ||||
|   title: | ||||
|     custom: "" | ||||
|     en_us: PronoteApi | ||||
							
								
								
									
										32
									
								
								getgrades.py
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								getgrades.py
									
									
									
									
									
								
							| @ -2,7 +2,6 @@ import pronotepy | ||||
| from pronotepy.ent import ile_de_france | ||||
| from datetime import date | ||||
| from datetime import datetime | ||||
| import schedule | ||||
| import time | ||||
| import json | ||||
| import requests | ||||
| @ -31,6 +30,7 @@ def envoyer_message_webhook(contenu): | ||||
|         print(f"Échec de l'envoi du message. Code d'état : {response.status_code}") | ||||
| 
 | ||||
| def refresh(send): | ||||
|     try : | ||||
|         client = pronotepy.Client('https://0910626l.index-education.net/pronote/eleve.html', | ||||
|                             username=ENT_USERNAME, | ||||
|                             password=ENT_PASSWORD, | ||||
| @ -103,6 +103,10 @@ def refresh(send): | ||||
|         with open(path + 'average.txt', 'w') as file: | ||||
|             json.dump(new_average, file, indent=2) | ||||
| 
 | ||||
|         return 1 | ||||
|     except Exception as e: | ||||
|         return e | ||||
| 
 | ||||
| 
 | ||||
| # schedule.every(20).minutes.do(refresh) | ||||
| # print('refresh: 20') | ||||
| @ -111,19 +115,25 @@ def refresh(send): | ||||
| #     time.sleep(1) | ||||
| 
 | ||||
| 
 | ||||
| try: | ||||
|     refresh(send = 0) | ||||
| except Exception as e: | ||||
|     print(e) | ||||
|     refresh(send = 0) | ||||
| status = 0 | ||||
| while status != 1: | ||||
|     status = refresh(send = 0) | ||||
|     if status != 1 : | ||||
|         print(status) | ||||
|         envoyer_message_webhook(status) | ||||
|         time.sleep(2*60) | ||||
| 
 | ||||
| min = 20 | ||||
| print('refresh rate: ', 20) | ||||
| while True: | ||||
|     try: | ||||
|         refresh(send = 1) | ||||
|     except Exception as e: | ||||
|         print(e) | ||||
|         refresh(send = 1) | ||||
|     status = 0 | ||||
|     while status != 1: | ||||
|         status = refresh(send = 1) | ||||
|         if status != 1 : | ||||
|             print(status) | ||||
|             envoyer_message_webhook(status) | ||||
|             time.sleep(2*60) | ||||
| 
 | ||||
|     time.sleep(min*60) | ||||
| 
 | ||||
| ### debug | ||||
|  | ||||
							
								
								
									
										50
									
								
								test.py
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								test.py
									
									
									
									
									
								
							| @ -1,50 +0,0 @@ | ||||
| import pronotepy | ||||
| from pronotepy.ent import ile_de_france | ||||
| from datetime import date | ||||
| from datetime import datetime | ||||
| import schedule | ||||
| import time | ||||
| import json | ||||
| import requests | ||||
| import os | ||||
| from dotenv import load_dotenv | ||||
| load_dotenv() | ||||
| DISCORD_WEBHOOKS_PRONOTE = os.getenv("DISCORD_WEBHOOKS_PRONOTE") | ||||
| ENT_USERNAME = os.getenv("ENT_USERNAME") | ||||
| ENT_PASSWORD = os.getenv("ENT_PASSWORD") | ||||
| 
 | ||||
| client = pronotepy.Client('https://0910626l.index-education.net/pronote/eleve.html', | ||||
|                         username=ENT_USERNAME, | ||||
|                         password=ENT_PASSWORD, | ||||
|                         ent=ile_de_france) | ||||
| if not client.logged_in: | ||||
|     exit(1) | ||||
| 
 | ||||
| new_average = client.periods[0].overall_average | ||||
| 
 | ||||
| new_grades_list = [] | ||||
| for period in client.periods: | ||||
|     for grade in period.grades: | ||||
|         grade_dict = { | ||||
|             'grade': grade.grade, | ||||
|             'average': grade.average, | ||||
|             'coefficient': grade.coefficient, | ||||
|             'comment': grade.comment, | ||||
|             'date': grade.date, | ||||
|             'default_out_of': grade.default_out_of, | ||||
|             'id': grade.id, | ||||
|             'is_bonus': grade.is_bonus, | ||||
|             'is_optional': grade.is_optionnal, | ||||
|             'is_out_of_20': grade.is_out_of_20, | ||||
|             'max': grade.max, | ||||
|             'min': grade.min, | ||||
|             'out_of': grade.out_of, | ||||
|             'period_id': grade.period.id, | ||||
|             'period_name': grade.period.name, | ||||
|             'subject_id': grade.subject.id, | ||||
|             'subject_groups': grade.subject.groups, | ||||
|             'subject_name': grade.subject.name, | ||||
|             } | ||||
|         new_grades_list.append(grade_dict) | ||||
| 
 | ||||
| print(new_grades_list) | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 √(noham)²
						√(noham)²