@@ -76,8 +76,8 @@ def refresh_repo(repo_type: RepoType = RepoType.TEMPLATES, scheduled_by: str = "
76
76
"""
77
77
# Acquire lock for devices to make sure no one refreshes the repository
78
78
# while another task is building configuration for devices using repo data
79
- with sqla_session () as session :
80
- job = Job ()
79
+ with sqla_session () as session : # type: ignore
80
+ job : Job = Job ()
81
81
session .add (job )
82
82
session .flush ()
83
83
job .start_job (function_name = "refresh_repo" , scheduled_by = scheduled_by )
@@ -103,7 +103,7 @@ def refresh_repo(repo_type: RepoType = RepoType.TEMPLATES, scheduled_by: str = "
103
103
result = _refresh_repo_task_settings (job_id = job_id )
104
104
else :
105
105
raise ValueError ("Invalid repository" )
106
- job .finish_time = datetime .datetime .utcnow ()
106
+ job .finish_time = datetime .datetime .utcnow () # type: ignore
107
107
job .status = JobStatus .FINISHED
108
108
job .result = {"message" : result , "repository" : repo_type .name }
109
109
try :
@@ -120,7 +120,7 @@ def refresh_repo(repo_type: RepoType = RepoType.TEMPLATES, scheduled_by: str = "
120
120
return result
121
121
except Exception as e :
122
122
logger .exception ("Exception while scheduling job for refresh repo" )
123
- job .finish_time = datetime .datetime .utcnow ()
123
+ job .finish_time = datetime .datetime .utcnow () # type: ignore
124
124
job .status = JobStatus .EXCEPTION
125
125
job .result = {"error" : str (e ), "repository" : repo_type .name }
126
126
try :
@@ -139,7 +139,7 @@ def refresh_repo(repo_type: RepoType = RepoType.TEMPLATES, scheduled_by: str = "
139
139
140
140
def repo_checkout_working (repo_type : RepoType , dry_run : bool = False ) -> bool :
141
141
logger = get_logger ()
142
- with redis_session () as redis :
142
+ with redis_session () as redis : # type: ignore
143
143
hexsha : Optional [str ] = redis .get (repo_type .name + "_working_commit" )
144
144
if hexsha :
145
145
logger .info ("Trying to check out last known working commit for repo {}: {}" .format (repo_type .name , hexsha ))
@@ -163,7 +163,7 @@ def repo_checkout_working(repo_type: RepoType, dry_run: bool = False) -> bool:
163
163
164
164
def repo_save_working_commit (repo_type : RepoType , hexsha : str ):
165
165
logger = get_logger ()
166
- with redis_session () as redis :
166
+ with redis_session () as redis : # type: ignore
167
167
logger .info ("Saving known working commit for repo {} in cache: {}" .format (repo_type .name , hexsha ))
168
168
redis .set (repo_type .name + "_working_commit" , hexsha )
169
169
0 commit comments