forked from wodsuz/EasyApplyJobsBot
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrepository_wrapper.py
85 lines (65 loc) · 2.79 KB
/
repository_wrapper.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import utils, models
from typing import List
from dotenv import load_dotenv
initialized = False
backend_api = None
def init():
global initialized, backend_api
utils.logDebugMessage("Initializing repository wrapper...")
initialized, backend_api = import_backend_module()
def import_backend_module():
try:
result = load_dotenv(".env")
print(f"Is .env file loaded = {result}")
from frontend.utils import (
api as backend_api, # Change this line with your backend module
)
utils.logDebugMessage(f"Successfully imported backend module", utils.MessageTypes.SUCCESS)
return True, backend_api
except ImportError as e:
utils.logDebugMessage(f"Could not import backend module: {e}", utils.MessageTypes.WARNING)
return False, None
def verify_jobs(jobs: models.JobForVerification) -> List[models.JobForVerification]:
if initialized:
try:
utils.logDebugMessage(f"Verifying jobs: {jobs}")
jobs = backend_api.verify_jobs(jobs)
except Exception as e:
utils.logDebugMessage(f"Error verifying jobs: {e}", utils.MessageTypes.ERROR)
return jobs
def update_job(job: models.Job):
if initialized:
try:
utils.logDebugMessage(f"Updating job: {job}")
job = backend_api.update_job_with_job_properties(job)
except Exception as e:
utils.logDebugMessage(f"Error updating job: {e}", utils.MessageTypes.ERROR)
return job
def attached_resume_to_job(job: models.Job, resume: str):
if initialized:
try:
utils.logDebugMessage(f"Attaching resume to job: {job}")
backend_api.attached_resume_to_job(job.linkedin_job_id, resume)
except Exception as e:
utils.logDebugMessage(f"Error attaching resume to job: {e}", utils.MessageTypes.ERROR)
def get_answer_by_question(question):
if initialized:
try:
utils.logDebugMessage(f"Getting answer for question: {question}")
# TODO: Implement this
except Exception as e:
utils.logDebugMessage(f"Error getting answer for question: {e}", utils.MessageTypes.ERROR)
def post_question(question):
if initialized:
try:
utils.logDebugMessage(f"Posting question: {question} with answer:")
# TODO: Implement this
except Exception as e:
utils.logDebugMessage(f"Error posting question: {e}", utils.MessageTypes.ERROR)
def applied_to_job(job: models.Job):
if initialized:
try:
utils.logDebugMessage(f"Marking job as applied: {job}")
backend_api.applied_to_job(job.linkedin_job_id)
except Exception as e:
utils.logDebugMessage(f"Error marking job as applied: {e}", utils.MessageTypes.ERROR)