hh-applicant-tool 0.3.8__tar.gz → 0.3.9__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.

Potentially problematic release.


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

Files changed (23) hide show
  1. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/PKG-INFO +2 -1
  2. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/README.md +1 -0
  3. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/api/client.py +0 -2
  4. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/apply_similar.py +1 -5
  5. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/telemetry_client.py +29 -22
  6. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/pyproject.toml +1 -1
  7. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/__init__.py +0 -0
  8. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/__main__.py +0 -0
  9. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/api/__init__.py +0 -0
  10. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/api/errors.py +0 -0
  11. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/color_log.py +0 -0
  12. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/constants.py +0 -0
  13. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/main.py +0 -0
  14. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/__init__.py +0 -0
  15. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/authorize.py +0 -0
  16. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/call_api.py +0 -0
  17. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/clear_negotiations.py +0 -0
  18. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/list_resumes.py +0 -0
  19. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/refresh_token.py +0 -0
  20. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/update_resumes.py +0 -0
  21. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/operations/whoami.py +0 -0
  22. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/types.py +0 -0
  23. {hh_applicant_tool-0.3.8 → hh_applicant_tool-0.3.9}/hh_applicant_tool/utils.py +0 -0
@@ -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` | Сообщение для ответа работодателю при отклике на вакансии, см. формат сообщений |
@@ -152,6 +152,7 @@ $ hh-applicant-tool refresh-token
152
152
  Через конфиг можно задать дополнительные настройки:
153
153
 
154
154
  | Имя атрибута | Описание |
155
+ | --- | --- |
155
156
  | `user_agent` | Кастомный юзерагент, передаваемый при кажом запросе, например, `Mozilla/5.0 YablanBrowser` |
156
157
  | `proxy_url` | Прокси, используемый для всех запросов, например, `socks5h://127.0.0.1:9050` |
157
158
  | `reply_message` | Сообщение для ответа работодателю при отклике на вакансии, см. формат сообщений |
@@ -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
  [tool.poetry]
2
2
  name = "hh-applicant-tool"
3
- version = "0.3.8"
3
+ version = "0.3.9"
4
4
  description = ""
5
5
  authors = ["Senior YAML Developer <yamldeveloper@proton.me>"]
6
6
  readme = "README.md"