-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (41 loc) · 1.35 KB
/
Copy pathmain.py
File metadata and controls
50 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
import logging
import sys
import coloredlogs
from api.hh_api_client import HHBotApi
from settings.config import HEADERS, PAYLOAD, PAYLOAD_UP, config
logger = logging.getLogger(__name__)
async def main():
while True:
try:
logger.info(config.LOG_START_MAIN_ROUTINE)
client = HHBotApi(
login_url=config.LOGIN_LINK,
resume_url=config.RESUME_UP_POST_LINK,
headers=HEADERS,
payload=PAYLOAD,
payload_up=PAYLOAD_UP,
)
await client.initialize()
for resume in config.parsed_resume_links:
await client.update_resume(resume)
logger.info(config.LOG_MAIN_ROUTINE_SUCCESS)
except Exception as e:
logger.error(f'{config.LOG_EXCEPTION}: {e}')
await asyncio.sleep(config.SLEEP_TIME)
if __name__ == '__main__':
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('bot.log', encoding='utf-8'),
],
)
coloredlogs.install(
level='INFO',
fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
isatty=True,
stream=sys.stdout,
)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())