-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
153 lines (124 loc) · 4.44 KB
/
main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
"""
Job Search Automation System
Main entry point for running the job search automation workflow.
"""
import asyncio
import argparse
import logging
from datetime import datetime
from typing import Dict, Any
from src.workflows.job_search import JobSearchWorkflow
from config import load_config, update_config, SEARCH_PREFERENCES
def setup_logging(config: Dict[str, Any]) -> logging.Logger:
"""Configure logging based on settings"""
logging_config = config["logging_config"]
logging.basicConfig(
level=logging_config["level"],
format=logging_config["format"],
filename=logging_config["file"],
filemode="a"
)
logger = logging.getLogger("job_search")
return logger
async def run_job_search(config: Dict[str, Any], logger: logging.Logger) -> None:
"""
Run the job search workflow
Args:
config (dict): Application configuration
logger (logging.Logger): Logger instance
"""
try:
# Initialize workflow
workflow = JobSearchWorkflow()
# Run job search with configured preferences
results = await workflow.run_job_search(config["search_preferences"])
logger.info(
f"Job search completed - Found: {results['jobs_found']}, "
f"Processed: {results['jobs_processed']}, "
f"Applied: {results['applications_sent']}"
)
# Start monitoring for responses
while True:
status = await workflow.check_application_status()
logger.info(
f"Status check - New responses: {status['new_responses']}, "
f"Active: {status['active_applications']}, "
f"Completed: {status['completed_applications']}"
)
# Wait before next check
await asyncio.sleep(3600) # Check every hour
except Exception as e:
logger.error(f"Error in job search workflow: {str(e)}", exc_info=True)
raise
def update_search_preferences(updates: Dict[str, Any]) -> None:
"""Update job search preferences"""
update_config("search_preferences", updates)
def main():
"""Main entry point"""
parser = argparse.ArgumentParser(description="Job Search Automation System")
parser.add_argument(
"--update-preferences",
action="store_true",
help="Update job search preferences"
)
parser.add_argument(
"--keywords",
nargs="+",
help="Job search keywords"
)
parser.add_argument(
"--locations",
nargs="+",
help="Job locations"
)
parser.add_argument(
"--job-types",
nargs="+",
help="Types of jobs to search for"
)
parser.add_argument(
"--experience-levels",
nargs="+",
help="Required experience levels"
)
parser.add_argument(
"--posted-within-days",
type=int,
help="Only consider jobs posted within this many days"
)
args = parser.parse_args()
try:
# Load configuration
config = load_config()
logger = setup_logging(config)
if args.update_preferences:
# Update search preferences if provided
updates = {}
if args.keywords:
updates["keywords"] = args.keywords
if args.locations:
updates["locations"] = args.locations
if args.job_types:
updates["job_types"] = args.job_types
if args.experience_levels:
updates["experience_levels"] = args.experience_levels
if args.posted_within_days:
updates["posted_within_days"] = args.posted_within_days
if updates:
update_search_preferences(updates)
logger.info("Updated search preferences")
print("Search preferences updated successfully")
else:
print("No preference updates provided")
return
# Run the job search workflow
print("Starting job search automation...")
logger.info("Starting job search automation")
asyncio.run(run_job_search(config, logger))
except Exception as e:
print(f"Error: {str(e)}")
if logger:
logger.error("Fatal error in main", exc_info=True)
exit(1)
if __name__ == "__main__":
main()