Skip to content

Commit b9f925d

Browse files
committed
Refactor code to include --imports option in main.py
1 parent 8fd861b commit b9f925d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ IMG_NAME = "ghcr.io/libertech-fr/sesame-taiga_crawler"
55
BASE_NAME = "sesame"
66
APP_NAME = "sesame-taiga_crawler"
77
PLATFORM = "linux/amd64"
8-
STC_RUN = ""
8+
STC_RUN = "all"
9+
STC_IMPORTS = "all"
910
include .env
1011

1112
.DEFAULT_GOAL := help
@@ -29,7 +30,7 @@ run-crawler-docker: ## Lance le crawler Sesame - Taiga avec python !
2930
--platform $(PLATFORM) \
3031
--name $(APP_NAME) \
3132
-v $(CURDIR):/data \
32-
$(IMG_NAME) python main.py --run=$(STC_RUN)
33+
$(IMG_NAME) python main.py --run=$(STC_RUN) --imports=$(STC_IMPORTS)
3334

3435
run-crawler: ## Lance le crawler Sesame - Taiga avec python !
3536
@python3 main.py

main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
async def main():
9090
parser = argparse.ArgumentParser()
9191
parser.add_argument('--run', help='all | taiga | sesame',default='all')
92+
parser.add_argument('--imports', help='all | ind | pictures',default='all')
9293
parser.add_argument('--an', help='Année universitaire à importer ',default="0")
9394
args = parser.parse_args()
9495
if args.an != 0:
@@ -100,13 +101,21 @@ async def main():
100101
logger.info("Starting Taiga crawler...")
101102
await a_moins_b(url, 0, -1, headers)
102103
collection_tasks = [col.get('function')(url, col, headers) for col in collections]
104+
105+
if args.imports == 'ind' or args.imports == 'all':
106+
collection_tasks = [col.get('function')(url, col, headers) for col in collections if col.get('method') != 'ExportPhotos']
107+
elif args.imports == 'pictures' or args.imports == 'all':
108+
collection_tasks = [col.get('function')(url, col, headers) for col in collections if col.get('method') == 'ExportPhotos']
109+
103110
await asyncio.gather(*collection_tasks)
104111
print("Taiga crawler ended successful !!!")
105112
if args.run == 'sesame' or args.run == 'all':
106113
print("Starting import_ind...")
107114
start_time = datetime.now()
108-
await import_ind()
109-
await import_pictures()
115+
if (args.imports == 'ind' or args.imports == 'all'):
116+
await import_ind()
117+
elif (args.imports == 'pictures' or args.imports == 'all'):
118+
await import_pictures()
110119
end_time = datetime.now()
111120
execution_time = end_time - start_time
112121
print(f"import_ind completed in {execution_time}")

0 commit comments

Comments
 (0)