BloodyInside commited on
Commit
43a9eda
·
1 Parent(s): 704d219
backend/invoke_worker/chapter_queue.py CHANGED
@@ -13,7 +13,7 @@ from asgiref.sync import async_to_sync
13
 
14
  from django.db.models import Count
15
 
16
- import requests, environ, os, subprocess, shutil, zipfile, uuid
17
 
18
  env = environ.Env()
19
 
@@ -56,7 +56,7 @@ class Job(Thread):
56
  if (options.get("translate").get("state")):
57
  target_lang = options.get("translate").get("target")
58
  else: target_lang = ""
59
- print(options)
60
  stored = ComicStorageCache.objects.filter(
61
  source=source,
62
  comic_id=comic_id,
@@ -99,20 +99,20 @@ class Job(Thread):
99
 
100
  job = web_scrap.source_control[source].get_chapter.scrap(comic_id=comic_id,chapter_id=chapter_id,output_dir=input_dir)
101
  if job.get("status") == "success":
102
- print("IT REACHED HERE???")
103
- with open(os.path.join(LOG_DIR,"image_translator_output.log"), "w") as file:
104
- result = subprocess.run(
105
- script,
106
- cwd=os.path.join(BASE_DIR, "backend", "module", "utils", "image_translator"),
107
- check=True,
108
- stdout=file,
109
- stderr=file,
110
- text=True,
111
- )
112
-
113
- print("IT DONE AND PRINT OUTPUT???")
114
- with open(os.path.join(LOG_DIR,"image_translator_output.log"), "r") as file:
115
- print(file.read())
116
  if result.returncode != 0: raise Exception("Image Translator Execution error!")
117
  os.makedirs(managed_output_dir,exist_ok=True)
118
  shutil.rmtree(input_dir)
@@ -235,10 +235,10 @@ class UpdateSocketQueue(Thread):
235
  MAX_QUEUE = SocketRequestChapterQueueCache.objects.count()
236
 
237
  if (MAX_QUEUE):
238
- query_result = list(set(SocketRequestChapterQueueCache.objects.order_by("datetime").values_list('socket_id', flat=True).distinct()))
239
  for socket_id in query_result:
240
  object = {}
241
- query_result_2 = SocketRequestChapterQueueCache.objects.filter(socket_id=socket_id).order_by("datetime").values("source","comic_id","chapter_idx")
242
 
243
  for item in query_result_2:
244
  source = item.get("source")
 
13
 
14
  from django.db.models import Count
15
 
16
+ import requests, environ, os, subprocess, shutil, zipfile, uuid, sys
17
 
18
  env = environ.Env()
19
 
 
56
  if (options.get("translate").get("state")):
57
  target_lang = options.get("translate").get("target")
58
  else: target_lang = ""
59
+
60
  stored = ComicStorageCache.objects.filter(
61
  source=source,
62
  comic_id=comic_id,
 
99
 
100
  job = web_scrap.source_control[source].get_chapter.scrap(comic_id=comic_id,chapter_id=chapter_id,output_dir=input_dir)
101
  if job.get("status") == "success":
102
+
103
+ # with open(os.path.join(LOG_DIR,"image_translator_output.log"), "w") as file:
104
+ result = subprocess.run(
105
+ script,
106
+ cwd=os.path.join(BASE_DIR, "backend", "module", "utils", "image_translator"),
107
+ check=True,
108
+ shell=False if sys.platform.startswith('linux') else True,
109
+ # stdout=file,
110
+ # stderr=file,
111
+ text=True,
112
+ )
113
+
114
+
115
+
116
  if result.returncode != 0: raise Exception("Image Translator Execution error!")
117
  os.makedirs(managed_output_dir,exist_ok=True)
118
  shutil.rmtree(input_dir)
 
235
  MAX_QUEUE = SocketRequestChapterQueueCache.objects.count()
236
 
237
  if (MAX_QUEUE):
238
+ query_result = list(set(SocketRequestChapterQueueCache.objects.order_by("-datetime").values_list('socket_id', flat=True).distinct()))
239
  for socket_id in query_result:
240
  object = {}
241
+ query_result_2 = SocketRequestChapterQueueCache.objects.filter(socket_id=socket_id).order_by("-datetime").values("source","comic_id","chapter_idx")
242
 
243
  for item in query_result_2:
244
  source = item.get("source")