cobweb-launcher 1.3.6__tar.gz → 1.3.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cobweb-launcher-1.3.6/cobweb_launcher.egg-info → cobweb-launcher-1.3.8}/PKG-INFO +1 -1
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/__init__.py +9 -9
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/dotting.py +1 -1
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/utils/oss.py +7 -7
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8/cobweb_launcher.egg-info}/PKG-INFO +1 -1
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/setup.py +1 -1
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/LICENSE +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/README.md +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/basic.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/common_queue.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/item.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/log.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/request.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/response.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/base/seed.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/constant.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/crawlers/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/crawlers/crawler.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/db/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/db/api_db.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/db/redis_db.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/exceptions/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/exceptions/oss_db_exception.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/launchers/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/launchers/launcher.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/launchers/launcher_air.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/launchers/launcher_api.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/launchers/launcher_pro.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/pipelines/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/pipelines/pipeline.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/pipelines/pipeline_console.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/pipelines/pipeline_loghub.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/schedulers/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/schedulers/scheduler_api.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/schedulers/scheduler_redis.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/setting.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/utils/__init__.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/utils/bloom.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb/utils/tools.py +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb_launcher.egg-info/SOURCES.txt +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb_launcher.egg-info/dependency_links.txt +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb_launcher.egg-info/requires.txt +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb_launcher.egg-info/top_level.txt +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/setup.cfg +0 -0
- {cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/test/test.py +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import os
|
1
2
|
import time
|
2
3
|
import traceback
|
3
4
|
import threading
|
@@ -12,7 +13,7 @@ from .basic import Seed, Request, Response
|
|
12
13
|
from .item import BaseItem, ConsoleItem
|
13
14
|
# from .seed import Seed
|
14
15
|
from .log import logger
|
15
|
-
|
16
|
+
from .dotting import LoghubDot
|
16
17
|
|
17
18
|
|
18
19
|
class TaskQueue:
|
@@ -25,8 +26,7 @@ class TaskQueue:
|
|
25
26
|
DONE = Queue() # 下载完成队列
|
26
27
|
UPLOAD = Queue() # 任务上传队列
|
27
28
|
DELETE = Queue() # 任务删除队列
|
28
|
-
|
29
|
-
# DOT = LoghubDot()
|
29
|
+
DOT = LoghubDot()
|
30
30
|
|
31
31
|
@staticmethod
|
32
32
|
def is_empty():
|
@@ -43,6 +43,7 @@ class TaskQueue:
|
|
43
43
|
@staticmethod
|
44
44
|
def process_task(it: Union[Seed, Request, Response, BaseItem], crawler_func: Callable):
|
45
45
|
try:
|
46
|
+
start_time = time.time()
|
46
47
|
iterators = crawler_func(it)
|
47
48
|
if not isgenerator(iterators):
|
48
49
|
raise TypeError(f"{crawler_func.__name__} function isn't a generator")
|
@@ -57,12 +58,11 @@ class TaskQueue:
|
|
57
58
|
TaskQueue.SEED.push(tk)
|
58
59
|
else:
|
59
60
|
raise TypeError(f"{crawler_func.__name__} function return type isn't supported")
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# todo: 数据打点
|
61
|
+
TaskQueue.DOT.build(
|
62
|
+
topic=f"{os.getenv('PROJECT')}:{os.getenv('TASK')}",
|
63
|
+
cost_time=round(time.time() - start_time, 2),
|
64
|
+
**tk.to_dict
|
65
|
+
)
|
66
66
|
except Exception as e:
|
67
67
|
it.params.retry += 1
|
68
68
|
if isinstance(it, Request):
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from typing import List
|
1
|
+
# from typing import List
|
2
2
|
from cobweb import setting
|
3
3
|
from requests import Response
|
4
4
|
from oss2 import Auth, Bucket, models, PartIterator
|
5
5
|
from cobweb.exceptions import oss_db_exception
|
6
|
-
from cobweb.base
|
6
|
+
from cobweb.base import Decorators
|
7
7
|
|
8
8
|
|
9
9
|
class OssUtil:
|
@@ -40,17 +40,17 @@ class OssUtil:
|
|
40
40
|
def head(self, key: str) -> models.HeadObjectResult:
|
41
41
|
return self._client.head_object(key)
|
42
42
|
|
43
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBInitPartError)
|
43
|
+
@Decorators.decorator_oss_db(exception=oss_db_exception.OssDBInitPartError)
|
44
44
|
def init_part(self, key) -> models.InitMultipartUploadResult:
|
45
45
|
"""初始化分片上传"""
|
46
46
|
return self._client.init_multipart_upload(key)
|
47
47
|
|
48
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBPutObjError)
|
48
|
+
@Decorators.decorator_oss_db(exception=oss_db_exception.OssDBPutObjError)
|
49
49
|
def put(self, key, data) -> models.PutObjectResult:
|
50
50
|
"""文件上传"""
|
51
51
|
return self._client.put_object(key, data)
|
52
52
|
|
53
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBPutPartError)
|
53
|
+
@Decorators.decorator_oss_db(exception=oss_db_exception.OssDBPutPartError)
|
54
54
|
def put_part(self, key, upload_id, position, data) -> models.PutObjectResult:
|
55
55
|
"""分片上传"""
|
56
56
|
return self._client.upload_part(key, upload_id, position, data)
|
@@ -59,13 +59,13 @@ class OssUtil:
|
|
59
59
|
"""获取分片列表"""
|
60
60
|
return [part_info for part_info in PartIterator(self._client, key, upload_id)]
|
61
61
|
|
62
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBMergeError)
|
62
|
+
@Decorators.decorator_oss_db(exception=oss_db_exception.OssDBMergeError)
|
63
63
|
def merge(self, key, upload_id, parts=None) -> models.PutObjectResult:
|
64
64
|
"""合并分片"""
|
65
65
|
headers = None if parts else {"x-oss-complete-all": "yes"}
|
66
66
|
return self._client.complete_multipart_upload(key, upload_id, parts, headers=headers)
|
67
67
|
|
68
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBAppendObjError)
|
68
|
+
@Decorators.decorator_oss_db(exception=oss_db_exception.OssDBAppendObjError)
|
69
69
|
def append(self, key, position, data) -> models.AppendObjectResult:
|
70
70
|
"""追加上传"""
|
71
71
|
return self._client.append_object(key, position, data)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cobweb-launcher-1.3.6 → cobweb-launcher-1.3.8}/cobweb_launcher.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|