Skip to content

Commit 195bc36

Browse files
author
Vladimir Kotal
committed
be more careful with getcwd() and properly log failures
1 parent 0a9763a commit 195bc36

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/sync/command.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,20 @@ def close(self):
100100

101101
orig_work_dir = None
102102
if self.work_dir:
103-
orig_work_dir = os.getcwd()
103+
try:
104+
orig_work_dir = os.getcwd()
105+
except OSError as e:
106+
self.state = Command.ERRORED
107+
self.logger.error("Cannot get working directory",
108+
exc_info=True)
109+
return
110+
104111
try:
105112
os.chdir(self.work_dir)
106113
except OSError as e:
107114
self.state = Command.ERRORED
108115
self.logger.error("Cannot change working directory to {}".
109-
format(self.work_dir))
116+
format(self.work_dir), exc_info=True)
110117
return
111118

112119
othr = OutputThread()
@@ -123,11 +130,11 @@ def close(self):
123130
stdout=othr)
124131
p.wait()
125132
except KeyboardInterrupt as e:
126-
self.logger.debug("Got KeyboardException while processing ",
127-
exc_info=True)
133+
self.logger.info("Got KeyboardException while processing ",
134+
exc_info=True)
128135
self.state = Command.INTERRUPTED
129136
except OSError as e:
130-
self.logger.debug("Got OS error", exc_info=True)
137+
self.logger.error("Got OS error", exc_info=True)
131138
self.state = Command.ERRORED
132139
else:
133140
self.state = Command.FINISHED

0 commit comments

Comments
 (0)