hh-applicant-tool 0.3.8__py3-none-any.whl → 0.3.9__py3-none-any.whl

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.

Potentially problematic release.


This version of hh-applicant-tool might be problematic. Click here for more details.

@@ -102,8 +102,6 @@ class BaseClient:
102
102
  logger.debug("wait %fs before request", delay)
103
103
  time.sleep(delay)
104
104
  has_body = method in ["POST", "PUT"]
105
- user_agent = self.user_agent or self.default_user_agent()
106
- logger.debug(f"{user_agent = }")
107
105
  response = self.session.request(
108
106
  method,
109
107
  url,
@@ -159,11 +159,7 @@ class Operation(BaseOperation):
159
159
  search: str | None = None,
160
160
  reply_message: str | None = None,
161
161
  ) -> None:
162
- # TODO: вынести куда-нибудь в функцию
163
- session = Session()
164
- session.headers["User-Agent"] = "Mozilla/5.0 (HHApplicantTelemetry/1.0)"
165
- session.proxies = dict(api.session.proxies)
166
- telemetry_client = TelemetryClient(session=session)
162
+ telemetry_client = TelemetryClient(proxies=api.proxies)
167
163
  telemetry_data = defaultdict(dict)
168
164
 
169
165
  vacancies = self._get_vacancies(
@@ -4,7 +4,10 @@ from urllib.parse import urljoin
4
4
  import requests
5
5
  from typing import Optional, Dict, Any
6
6
  import logging
7
- import base64
7
+ from functools import partialmethod
8
+ import warnings
9
+
10
+ warnings.filterwarnings('ignore', message='Unverified HTTPS request')
8
11
 
9
12
  logger = logging.getLogger(__package__)
10
13
 
@@ -18,40 +21,42 @@ class TelemetryError(Exception):
18
21
  class TelemetryClient:
19
22
  """Клиент для отправки телеметрии на сервер."""
20
23
 
21
- server_address = base64.b64decode(
22
- "aHR0cDovLzMxLjEzMS4yNTEuMTA3OjU0MTU2"
23
- ).decode()
24
+ server_address: str = "https://hh-applicant-tool.mooo.com:54157/"
24
25
 
25
26
  def __init__(
26
27
  self,
27
28
  server_address: Optional[str] = None,
29
+ *,
28
30
  session: Optional[requests.Session] = None,
31
+ user_agent: str = "Mozilla/5.0 (HHApplicantTelemetry/1.0)",
32
+ proxies: dict | None = None,
29
33
  ) -> None:
30
- """
31
- Инициализация клиента.
32
-
33
- :param server_address: Адрес сервера для отправки телеметрии.
34
- :param session: Сессия для повторного использования соединения.
35
- """
36
- self.session = session or requests.Session()
37
34
  self.server_address = os.getenv(
38
35
  "TELEMETRY_SERVER", server_address or self.server_address
39
36
  )
37
+ self.session = session or requests.Session()
38
+ self.user_agent = user_agent
39
+ self.proxies = proxies
40
40
 
41
- def send_telemetry(
42
- self, endpoint: str, data: Dict[str, Any]
41
+ def request(
42
+ self,
43
+ method: str,
44
+ endpoint: str,
45
+ data: Dict[str, Any] | None = None,
43
46
  ) -> Dict[str, Any]:
44
- """
45
- Отправка телеметрии на сервер.
46
-
47
- :param endpoint: Конечная точка на сервере.
48
- :param data: Данные для отправки.
49
- :return: Ответ сервера в формате JSON.
50
- :raises TelemetryError: Если произошла ошибка при отправке или декодировании JSON.
51
- """
47
+ method = method.upper()
52
48
  url = urljoin(self.server_address, endpoint)
49
+ has_body = method in ["POST", "PUT", "PATCH"]
53
50
  try:
54
- response = self.session.post(url, json=data)
51
+ response = self.session.request(
52
+ method,
53
+ url,
54
+ headers={"User-Agent": self.user_agent},
55
+ proxies=self.proxies,
56
+ params=data if not has_body else None,
57
+ json=data if has_body else None,
58
+ verify=False, # Игнорирование истекшего сертификата
59
+ )
55
60
  # response.raise_for_status()
56
61
  result = response.json()
57
62
  if "error" in result:
@@ -63,3 +68,5 @@ class TelemetryClient:
63
68
  json.JSONDecodeError,
64
69
  ) as ex:
65
70
  raise TelemetryError(str(ex)) from ex
71
+
72
+ send_telemetry = partialmethod(request, "POST")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hh-applicant-tool
3
- Version: 0.3.8
3
+ Version: 0.3.9
4
4
  Summary:
5
5
  Author: Senior YAML Developer
6
6
  Author-email: yamldeveloper@proton.me
@@ -171,6 +171,7 @@ $ hh-applicant-tool refresh-token
171
171
  Через конфиг можно задать дополнительные настройки:
172
172
 
173
173
  | Имя атрибута | Описание |
174
+ | --- | --- |
174
175
  | `user_agent` | Кастомный юзерагент, передаваемый при кажом запросе, например, `Mozilla/5.0 YablanBrowser` |
175
176
  | `proxy_url` | Прокси, используемый для всех запросов, например, `socks5h://127.0.0.1:9050` |
176
177
  | `reply_message` | Сообщение для ответа работодателю при отклике на вакансии, см. формат сообщений |
@@ -1,13 +1,13 @@
1
1
  hh_applicant_tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  hh_applicant_tool/__main__.py,sha256=cwKJAAML0RRKT9Qbzcwf07HHcuSd8oh7kx4P1apndWQ,84
3
3
  hh_applicant_tool/api/__init__.py,sha256=kgFSHibRaAugN2BA3U1djEa20qgKJUUVouwJzjEB0DU,84
4
- hh_applicant_tool/api/client.py,sha256=o_9hDdtCH3xHgBKwqoriNy0wncgUANDR8y--ZxVPQGM,8112
4
+ hh_applicant_tool/api/client.py,sha256=um9NX22hNOtSuPCobCKf1anIFp-jiZlIXm4BuqN-L7k,7997
5
5
  hh_applicant_tool/api/errors.py,sha256=0SoWKnsSUA0K2YgQA8GwGhe-pRMwtfK94MR6_MgbORQ,1722
6
6
  hh_applicant_tool/color_log.py,sha256=gN6j1Ayy1G7qOMI_e3WvfYw_ublzeQbKgsVLhqGg_3s,823
7
7
  hh_applicant_tool/constants.py,sha256=lpgKkP2chWgTnBXvzxbSPWpKcfzp8VxMTlkssFcQhH4,469
8
8
  hh_applicant_tool/main.py,sha256=B_kI9MlaT_064r5CL7Pjlzu76QPB-hXCaMpFtB-BOfg,4596
9
9
  hh_applicant_tool/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- hh_applicant_tool/operations/apply_similar.py,sha256=9dPvO_3o9rGgaUKxEChgc1cL69YpXuJY8tpP_4iD6TY,17249
10
+ hh_applicant_tool/operations/apply_similar.py,sha256=8L0Im0bPRxn-tsteI9X4D5gPpr6PemuzK0x-IszrOis,17021
11
11
  hh_applicant_tool/operations/authorize.py,sha256=TyUTCSOGwSYVJMEd5vSI981LRRI-RZf8hnlVYhtRVwA,3184
12
12
  hh_applicant_tool/operations/call_api.py,sha256=qwPDrWP9tiqHkaYYWYBZtymj9AaxObB86Eny-Bf5q_c,1314
13
13
  hh_applicant_tool/operations/clear_negotiations.py,sha256=98Yuw9xP4dN5sUnUKlZxqfhU40TQ-aCjK4vj4LRTeYo,3894
@@ -15,10 +15,10 @@ hh_applicant_tool/operations/list_resumes.py,sha256=XBrVFTnl45BUtuvjVm70h_CXZrOv
15
15
  hh_applicant_tool/operations/refresh_token.py,sha256=hYTmzBzJFSsb-LDO2_w0Y30WVWsctIH7vTzirkLwzWo,1267
16
16
  hh_applicant_tool/operations/update_resumes.py,sha256=gGxMYMoT9GqJjwn4AgrOAEJCZu4sdhaV0VmPr3jG-q8,1049
17
17
  hh_applicant_tool/operations/whoami.py,sha256=sg0r7m6oKkpMEmGt4QdtYdS-1gf-1KKdnk32yblbRJs,714
18
- hh_applicant_tool/telemetry_client.py,sha256=8R5cdB8971j1rz0v0nhh1TBbqHHD9LYdBUnd5sh-kik,2165
18
+ hh_applicant_tool/telemetry_client.py,sha256=nNNr1drXY9Z01u5tJX---BXxBg1y06nJpNbhU45DmE0,2239
19
19
  hh_applicant_tool/types.py,sha256=q3yaIcq-UOkPzjxws0OFa4w9fTty-yx79_dic70_dUM,843
20
20
  hh_applicant_tool/utils.py,sha256=lHQh94CEwWp14Ty50ecZPcR3YyqLDVlmgmZlrBiBgHQ,2557
21
- hh_applicant_tool-0.3.8.dist-info/METADATA,sha256=8Y-ENQv2YFch_NRkreNl594ZqtAygTcVdNGTxBcHk8M,20561
22
- hh_applicant_tool-0.3.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
23
- hh_applicant_tool-0.3.8.dist-info/entry_points.txt,sha256=Vb7M2YaYLMtKYJZh8chIrXZApMzSRFT1-rQw-U9r10g,65
24
- hh_applicant_tool-0.3.8.dist-info/RECORD,,
21
+ hh_applicant_tool-0.3.9.dist-info/METADATA,sha256=FbQA5oxUmGEGhuUehYcci7vMrUmiad0a8OUqPOHqsG8,20575
22
+ hh_applicant_tool-0.3.9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
23
+ hh_applicant_tool-0.3.9.dist-info/entry_points.txt,sha256=Vb7M2YaYLMtKYJZh8chIrXZApMzSRFT1-rQw-U9r10g,65
24
+ hh_applicant_tool-0.3.9.dist-info/RECORD,,