Skip to content

Commit ea179ad

Browse files
committed
More diagnostic logs when pulling/pushing to get exceptions
1 parent c5faa42 commit ea179ad

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

mergin/client_pull.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,12 @@ def pull_project_async(mc, directory):
325325
mp.log.info("--- version: " + mc.user_agent_info())
326326
mp.log.info(f"--- start pull {project_path}")
327327

328-
server_info = mc.project_info(project_path, since=local_version)
328+
try:
329+
server_info = mc.project_info(project_path, since=local_version)
330+
except ClientError as err:
331+
mp.log.error("Error getting project info: " + str(err))
332+
mp.log.info("--- pull aborted")
333+
raise
329334
server_version = server_info["version"]
330335

331336
mp.log.info(f"got project info: local version {local_version} / server version {server_version}")
@@ -437,6 +442,8 @@ def pull_project_is_running(job):
437442
"""
438443
for future in job.futures:
439444
if future.done() and future.exception() is not None:
445+
job.mp.log.error("Error while pulling data: " + str(future.exception()))
446+
job.mp.log.info("--- pull aborted")
440447
raise future.exception()
441448
if future.running():
442449
return True
@@ -494,7 +501,7 @@ def pull_project_finalize(job):
494501
# make sure any exceptions from threads are not lost
495502
for future in job.futures:
496503
if future.exception() is not None:
497-
job.mp.log.error("Error while downloading data: " + str(future.exception()))
504+
job.mp.log.error("Error while pulling data: " + str(future.exception()))
498505
job.mp.log.info("--- pull aborted")
499506
raise future.exception()
500507

mergin/client_push.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ def push_project_async(mc, directory):
8484
mp.log.info("--- version: " + mc.user_agent_info())
8585
mp.log.info(f"--- start push {project_path}")
8686

87-
server_info = mc.project_info(project_path)
87+
try:
88+
server_info = mc.project_info(project_path)
89+
except ClientError as err:
90+
mp.log.error("Error getting project info: " + str(err))
91+
mp.log.info("--- push aborted")
92+
raise
8893
server_version = server_info["version"] if server_info["version"] else "v0"
8994

9095
mp.log.info(f"got project info: local version {local_version} / server version {server_version}")
@@ -122,7 +127,12 @@ def push_project_async(mc, directory):
122127
"changes": changes
123128
}
124129

125-
resp = mc.post(f'/v1/project/push/{project_path}', data, {"Content-Type": "application/json"})
130+
try:
131+
resp = mc.post(f'/v1/project/push/{project_path}', data, {"Content-Type": "application/json"})
132+
except ClientError as err:
133+
mp.log.error("Error starting transaction: " + str(err))
134+
mp.log.info("--- push aborted")
135+
raise
126136
server_resp = json.load(resp)
127137

128138
upload_files = data['changes']["added"] + data['changes']["updated"]
@@ -181,6 +191,8 @@ def push_project_is_running(job):
181191
"""
182192
for future in job.futures:
183193
if future.done() and future.exception() is not None:
194+
job.mp.log.error("Error while pushing data: " + str(future.exception()))
195+
job.mp.log.info("--- push aborted")
184196
raise future.exception()
185197
if future.running():
186198
return True
@@ -205,6 +217,8 @@ def push_project_finalize(job):
205217
# make sure any exceptions from threads are not lost
206218
for future in job.futures:
207219
if future.exception() is not None:
220+
job.mp.log.error("Error while pushing data: " + str(future.exception()))
221+
job.mp.log.info("--- push aborted")
208222
raise future.exception()
209223

210224
if job.transferred_size != job.total_size:
@@ -256,6 +270,6 @@ def _do_upload(item, job):
256270
""" runs in worker thread """
257271
if job.is_cancelled:
258272
return
259-
273+
260274
item.upload_blocking(job.mc, job.mp)
261275
job.transferred_size += item.size

0 commit comments

Comments
 (0)