Merge lp:~ben-hutchings/ensoft-sextant/cleanup-fix into lp:ensoft-sextant

Proposed by Ben Hutchings
Status: Superseded
Proposed branch: lp:~ben-hutchings/ensoft-sextant/cleanup-fix
Merge into: lp:ensoft-sextant
Prerequisite: lp:~ben-hutchings/ensoft-sextant/wierd-names-clean
Diff against target: 61 lines (+11/-4)
3 files modified
src/sextant/db_api.py (+9/-2)
src/sextant/sshmanager.py (+2/-1)
src/sextant/web/server.py (+0/-1)
To merge this branch: bzr merge lp:~ben-hutchings/ensoft-sextant/cleanup-fix
Reviewer Review Type Date Requested Status
Robert Pending
Review via email: mp+244604@code.launchpad.net

This proposal has been superseded by a proposal from 2014-12-18.

Commit message

Fixed temporary file issue whereby one instance of sextant could delete the temporary files still being used by another instance (run by the same user).

Description of the change

Fixed temporary file issue whereby one instance of sextant could delete the temporary files still being used by another instance (run by the same user).

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sextant/db_api.py'
2--- src/sextant/db_api.py 2014-12-12 15:02:30 +0000
3+++ src/sextant/db_api.py 2014-12-12 15:02:30 +0000
4@@ -144,7 +144,7 @@
5 self._ssh = connection._ssh
6 self._db = connection._db
7
8- self._tmp_dir = '{}-{}'.format(TMP_DIR, getpass.getuser())
9+ self._tmp_dir = '{}-{}{}'.format(TMP_DIR, getpass.getuser(), time())
10
11 # Make the local tmp file - csv files will be written into here.
12 try:
13@@ -293,7 +293,14 @@
14 self.call_writer.file_iter()))
15
16 for path in file_paths:
17- os.remove(path)
18+ try:
19+ os.remove(path)
20+ except OSError as e:
21+ # If the file doesn't exist just keep going.
22+ if e.errno == os.errno.ENOENT:
23+ pass
24+ else:
25+ raise
26
27 try_rmdir(self._tmp_dir)
28 try_rmdir(TMP_DIR)
29
30=== modified file 'src/sextant/sshmanager.py'
31--- src/sextant/sshmanager.py 2014-10-17 15:30:14 +0000
32+++ src/sextant/sshmanager.py 2014-12-12 15:02:30 +0000
33@@ -2,6 +2,7 @@
34 import getpass
35 import logging
36 import subprocess
37+import time
38
39 """Provide a class to manage an SSH tunnel and controller"""
40 __all__ = ('SSHConnectionError', 'SSHCommandError', 'SSHManager')
41@@ -82,7 +83,7 @@
42 self.remote_port = remote_port
43 self.ssh_user = ssh_user
44
45- self._tmp_dir = '{}-{}'.format(TMP_DIR, self.ssh_user or getpass.getuser())
46+ self._tmp_dir = '{}-{}{}'.format(TMP_DIR, self.ssh_user or getpass.getuser(), time.time())
47
48 self._controller_name = 'sextantcontroller{}'.format(local_port)
49 self._is_localhost = is_localhost
50
51=== modified file 'src/sextant/web/server.py'
52--- src/sextant/web/server.py 2014-12-02 14:00:57 +0000
53+++ src/sextant/web/server.py 2014-12-12 15:02:30 +0000
54@@ -209,7 +209,6 @@
55 res_code = RESPONSE_CODE_BAD_REQUEST
56 res_msg = "{}".format(e)
57 print('\tfailed {}'.format(datetime.now()))
58- raise
59
60
61 if res_code is RESPONSE_CODE_OK:

Subscribers

People subscribed via source and target branches